xref: /PHP-7.3/ext/spl/tests/bug49263.phpt (revision 766ce8bd)
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--
20C:16:"SplObjectStorage":113:{x:i:2;O:8:"stdClass":0:{},a:2:{s:4:"prev";i:2;s:4:"next";O:8:"stdClass":0:{}};r:6;,a:1:{s:4:"prev";r:3;};m: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