1--TEST--
2SplFixedArray serialisation
3--FILE--
4<?php
5
6$array = new SplFixedArray(5);
7
8$obj = new stdClass;
9$obj->prop = 'value';
10
11$array[0] = 'foo';
12$array[2] = 42;
13$array[3] = $obj;
14$array[4] = range(1, 5);
15
16$array->foo = "bar";
17
18$ser = serialize($array);
19echo "$ser\n";
20$unser = unserialize($ser);
21
22printf("count: %d\n", count($unser));
23printf("getSize(): %d\n", $unser->getSize());
24
25var_dump($unser[0], $unser[1], $unser[2], $unser[3], $unser[4]);
26
27$unser[4] = 'quux';
28var_dump($unser[4]);
29var_dump($unser->foo);
30
31// __unserialize is a no-op on a non-empty SplFixedArray
32$array = new SplFixedArray(1);
33$array->__unserialize([
34    [1],
35    [
36        "foo" => "bar",
37    ],
38]);
39var_dump($array);
40
41var_dump($s = serialize(new SplFixedArray));
42var_dump(unserialize($s));
43
44?>
45--EXPECTF--
46Deprecated: Creation of dynamic property SplFixedArray::$foo is deprecated in %s on line %d
47O:13:"SplFixedArray":6:{i:0;s:3:"foo";i:1;N;i:2;i:42;i:3;O:8:"stdClass":1:{s:4:"prop";s:5:"value";}i:4;a:5:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;}s:3:"foo";s:3:"bar";}
48
49Deprecated: Creation of dynamic property SplFixedArray::$foo is deprecated in %s on line %d
50count: 5
51getSize(): 5
52string(3) "foo"
53NULL
54int(42)
55object(stdClass)#4 (1) {
56  ["prop"]=>
57  string(5) "value"
58}
59array(5) {
60  [0]=>
61  int(1)
62  [1]=>
63  int(2)
64  [2]=>
65  int(3)
66  [3]=>
67  int(4)
68  [4]=>
69  int(5)
70}
71string(4) "quux"
72string(3) "bar"
73object(SplFixedArray)#5 (1) {
74  [0]=>
75  NULL
76}
77string(25) "O:13:"SplFixedArray":0:{}"
78object(SplFixedArray)#1 (0) {
79}
80