xref: /php-src/ext/spl/tests/gh10925.phpt (revision 47b3fe47)
1--TEST--
2Properties serialization for SplFixedArray should have updated properties
3--FILE--
4<?php
5#[AllowDynamicProperties]
6class MySplFixedArray extends SplFixedArray {
7    public $x;
8    public int $y = 3;
9}
10
11$x = new MySplFixedArray(2);
12var_dump($x->y);
13$x->y = 2;
14var_dump($x->y);
15$serialized = serialize($x);
16var_dump($serialized);
17var_dump(unserialize($serialized));
18
19$x->dynamic_property = "dynamic_property_value";
20$serialized = serialize($x);
21var_dump($serialized);
22var_dump(unserialize($serialized));
23
24$x->dynamic_property = "dynamic_property_value2";
25$x->y = 4;
26$serialized = serialize($x);
27var_dump($serialized);
28var_dump(unserialize($serialized));
29?>
30--EXPECT--
31int(3)
32int(2)
33string(61) "O:15:"MySplFixedArray":4:{i:0;N;i:1;N;s:1:"x";N;s:1:"y";i:2;}"
34object(MySplFixedArray)#2 (4) {
35  [0]=>
36  NULL
37  [1]=>
38  NULL
39  ["x"]=>
40  NULL
41  ["y"]=>
42  int(2)
43}
44string(115) "O:15:"MySplFixedArray":5:{i:0;N;i:1;N;s:1:"x";N;s:1:"y";i:2;s:16:"dynamic_property";s:22:"dynamic_property_value";}"
45object(MySplFixedArray)#2 (5) {
46  [0]=>
47  NULL
48  [1]=>
49  NULL
50  ["x"]=>
51  NULL
52  ["y"]=>
53  int(2)
54  ["dynamic_property"]=>
55  string(22) "dynamic_property_value"
56}
57string(116) "O:15:"MySplFixedArray":5:{i:0;N;i:1;N;s:1:"x";N;s:1:"y";i:4;s:16:"dynamic_property";s:23:"dynamic_property_value2";}"
58object(MySplFixedArray)#2 (5) {
59  [0]=>
60  NULL
61  [1]=>
62  NULL
63  ["x"]=>
64  NULL
65  ["y"]=>
66  int(4)
67  ["dynamic_property"]=>
68  string(23) "dynamic_property_value2"
69}
70