xref: /PHP-7.4/ext/spl/tests/bug49263.phpt (revision e2ea0f10)
1--TEST--
2SPL: SplObjectStorage serialization references
3--FILE--
4<?php
5$o1 = new stdClass;
6$o2 = new stdClass;
7
8$s = new splObjectStorage();
9
10$s->attach($o1, array('prev' => 2, 'next' => $o2));
11$s->attach($o2, array('prev' => $o1));
12
13$ss = serialize($s);
14unset($s,$o1,$o2);
15echo $ss."\n";
16var_dump(unserialize($ss));
17?>
18===DONE===
19--EXPECTF--
20O:16:"SplObjectStorage":2:{i:0;a:4:{i:0;O:8:"stdClass":0:{}i:1;a:2:{s:4:"prev";i:2;s:4:"next";O:8:"stdClass":0:{}}i:2;r:6;i:3;a:1:{s:4:"prev";r:3;}}i:1;a:0:{}}
21object(SplObjectStorage)#2 (1) {
22  ["storage":"SplObjectStorage":private]=>
23  array(2) {
24    ["%s"]=>
25    array(2) {
26      ["obj"]=>
27      object(stdClass)#1 (0) {
28      }
29      ["inf"]=>
30      array(2) {
31        ["prev"]=>
32        int(2)
33        ["next"]=>
34        object(stdClass)#3 (0) {
35        }
36      }
37    }
38    ["%s"]=>
39    array(2) {
40      ["obj"]=>
41      object(stdClass)#3 (0) {
42      }
43      ["inf"]=>
44      array(1) {
45        ["prev"]=>
46        object(stdClass)#1 (0) {
47        }
48      }
49    }
50  }
51}
52===DONE===
53