1--TEST--
2serialization: arrays with references to an external variable
3--FILE--
4<?php
5function check(&$a) {
6    var_dump($a);
7    $ser = serialize($a);
8    var_dump($ser);
9
10    $b = unserialize($ser);
11    var_dump($b);
12    $b[0] = "b0.changed";
13    var_dump($b);
14    $b[1] = "b1.changed";
15    var_dump($b);
16    $b[2] = "b2.changed";
17    var_dump($b);
18}
19
20echo "\n\n--- 0 refs external:\n";
21$ext = 1;
22$a = array();
23$a[0] = &$ext;
24$a[1] = 1;
25$a[2] = 1;
26check($a);
27
28echo "\n\n--- 1 refs external:\n";
29$ext = 1;
30$a = array();
31$a[0] = 1;
32$a[1] = &$ext;
33$a[2] = 1;
34check($a);
35
36echo "\n\n--- 2 refs external:\n";
37$ext = 1;
38$a = array();
39$a[0] = 1;
40$a[1] = 1;
41$a[2] = &$ext;
42check($a);
43
44echo "\n\n--- 1,2 ref external:\n";
45$ext = 1;
46$a = array();
47$a[0] = &$ext;
48$a[1] = &$ext;
49$a[2] = 1;
50check($a);
51
52echo "\n\n--- 1,2,3 ref external:\n";
53$ext = 1;
54$a = array();
55$a[0] = &$ext;
56$a[1] = &$ext;
57$a[2] = &$ext;
58check($a);
59
60echo "Done";
61?>
62--EXPECT--
63--- 0 refs external:
64array(3) {
65  [0]=>
66  &int(1)
67  [1]=>
68  int(1)
69  [2]=>
70  int(1)
71}
72string(30) "a:3:{i:0;i:1;i:1;i:1;i:2;i:1;}"
73array(3) {
74  [0]=>
75  int(1)
76  [1]=>
77  int(1)
78  [2]=>
79  int(1)
80}
81array(3) {
82  [0]=>
83  string(10) "b0.changed"
84  [1]=>
85  int(1)
86  [2]=>
87  int(1)
88}
89array(3) {
90  [0]=>
91  string(10) "b0.changed"
92  [1]=>
93  string(10) "b1.changed"
94  [2]=>
95  int(1)
96}
97array(3) {
98  [0]=>
99  string(10) "b0.changed"
100  [1]=>
101  string(10) "b1.changed"
102  [2]=>
103  string(10) "b2.changed"
104}
105
106
107--- 1 refs external:
108array(3) {
109  [0]=>
110  int(1)
111  [1]=>
112  &int(1)
113  [2]=>
114  int(1)
115}
116string(30) "a:3:{i:0;i:1;i:1;i:1;i:2;i:1;}"
117array(3) {
118  [0]=>
119  int(1)
120  [1]=>
121  int(1)
122  [2]=>
123  int(1)
124}
125array(3) {
126  [0]=>
127  string(10) "b0.changed"
128  [1]=>
129  int(1)
130  [2]=>
131  int(1)
132}
133array(3) {
134  [0]=>
135  string(10) "b0.changed"
136  [1]=>
137  string(10) "b1.changed"
138  [2]=>
139  int(1)
140}
141array(3) {
142  [0]=>
143  string(10) "b0.changed"
144  [1]=>
145  string(10) "b1.changed"
146  [2]=>
147  string(10) "b2.changed"
148}
149
150
151--- 2 refs external:
152array(3) {
153  [0]=>
154  int(1)
155  [1]=>
156  int(1)
157  [2]=>
158  &int(1)
159}
160string(30) "a:3:{i:0;i:1;i:1;i:1;i:2;i:1;}"
161array(3) {
162  [0]=>
163  int(1)
164  [1]=>
165  int(1)
166  [2]=>
167  int(1)
168}
169array(3) {
170  [0]=>
171  string(10) "b0.changed"
172  [1]=>
173  int(1)
174  [2]=>
175  int(1)
176}
177array(3) {
178  [0]=>
179  string(10) "b0.changed"
180  [1]=>
181  string(10) "b1.changed"
182  [2]=>
183  int(1)
184}
185array(3) {
186  [0]=>
187  string(10) "b0.changed"
188  [1]=>
189  string(10) "b1.changed"
190  [2]=>
191  string(10) "b2.changed"
192}
193
194
195--- 1,2 ref external:
196array(3) {
197  [0]=>
198  &int(1)
199  [1]=>
200  &int(1)
201  [2]=>
202  int(1)
203}
204string(30) "a:3:{i:0;i:1;i:1;R:2;i:2;i:1;}"
205array(3) {
206  [0]=>
207  &int(1)
208  [1]=>
209  &int(1)
210  [2]=>
211  int(1)
212}
213array(3) {
214  [0]=>
215  &string(10) "b0.changed"
216  [1]=>
217  &string(10) "b0.changed"
218  [2]=>
219  int(1)
220}
221array(3) {
222  [0]=>
223  &string(10) "b1.changed"
224  [1]=>
225  &string(10) "b1.changed"
226  [2]=>
227  int(1)
228}
229array(3) {
230  [0]=>
231  &string(10) "b1.changed"
232  [1]=>
233  &string(10) "b1.changed"
234  [2]=>
235  string(10) "b2.changed"
236}
237
238
239--- 1,2,3 ref external:
240array(3) {
241  [0]=>
242  &int(1)
243  [1]=>
244  &int(1)
245  [2]=>
246  &int(1)
247}
248string(30) "a:3:{i:0;i:1;i:1;R:2;i:2;R:2;}"
249array(3) {
250  [0]=>
251  &int(1)
252  [1]=>
253  &int(1)
254  [2]=>
255  &int(1)
256}
257array(3) {
258  [0]=>
259  &string(10) "b0.changed"
260  [1]=>
261  &string(10) "b0.changed"
262  [2]=>
263  &string(10) "b0.changed"
264}
265array(3) {
266  [0]=>
267  &string(10) "b1.changed"
268  [1]=>
269  &string(10) "b1.changed"
270  [2]=>
271  &string(10) "b1.changed"
272}
273array(3) {
274  [0]=>
275  &string(10) "b2.changed"
276  [1]=>
277  &string(10) "b2.changed"
278  [2]=>
279  &string(10) "b2.changed"
280}
281Done
282