xref: /PHP-8.2/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  ["x"]=>
36  NULL
37  ["y"]=>
38  int(2)
39  [0]=>
40  NULL
41  [1]=>
42  NULL
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  ["x"]=>
47  NULL
48  ["y"]=>
49  int(2)
50  ["dynamic_property"]=>
51  string(22) "dynamic_property_value"
52  [0]=>
53  NULL
54  [1]=>
55  NULL
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  ["x"]=>
60  NULL
61  ["y"]=>
62  int(4)
63  ["dynamic_property"]=>
64  string(23) "dynamic_property_value2"
65  [0]=>
66  NULL
67  [1]=>
68  NULL
69}
70