1--TEST--
2Bug #31402 (unserialize() generates references when it should not)
3--INI--
4error_reporting=E_ALL&~E_STRICT&~E_DEPRECATED
5--FILE--
6<?php
7
8class TestX {
9  var $i;
10
11  function __construct($i) {
12    $this->i = $i;
13  }
14}
15
16class TestY {
17  var $A = array();
18  var $B;
19
20  function __construct() {
21    $this->A[1] = new TestX(1);
22    $this->A[2] = & new TestX(2);
23    $this->A[3] = & $this->A[2];
24    $this->B = $this->A[1];
25  }
26}
27
28$before = new TestY();
29$ser = serialize($before);
30$after = unserialize($ser);
31
32var_dump($before, $after);
33
34?>
35===DONE===
36--EXPECTF--
37object(TestY)#%d (2) {
38  ["A"]=>
39  array(3) {
40    [1]=>
41    object(TestX)#%d (1) {
42      ["i"]=>
43      int(1)
44    }
45    [2]=>
46    &object(TestX)#%d (1) {
47      ["i"]=>
48      int(2)
49    }
50    [3]=>
51    &object(TestX)#%d (1) {
52      ["i"]=>
53      int(2)
54    }
55  }
56  ["B"]=>
57  object(TestX)#%d (1) {
58    ["i"]=>
59    int(1)
60  }
61}
62object(TestY)#%d (2) {
63  ["A"]=>
64  array(3) {
65    [1]=>
66    object(TestX)#%d (1) {
67      ["i"]=>
68      int(1)
69    }
70    [2]=>
71    &object(TestX)#%d (1) {
72      ["i"]=>
73      int(2)
74    }
75    [3]=>
76    &object(TestX)#%d (1) {
77      ["i"]=>
78      int(2)
79    }
80  }
81  ["B"]=>
82  object(TestX)#%d (1) {
83    ["i"]=>
84    int(1)
85  }
86}
87===DONE===
88