xref: /PHP-8.1/ext/spl/tests/bug49263.phpt (revision 11648c00)
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--EXPECT--
19O: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:{}}
20object(SplObjectStorage)#2 (1) {
21  ["storage":"SplObjectStorage":private]=>
22  array(2) {
23    [0]=>
24    array(2) {
25      ["obj"]=>
26      object(stdClass)#1 (0) {
27      }
28      ["inf"]=>
29      array(2) {
30        ["prev"]=>
31        int(2)
32        ["next"]=>
33        object(stdClass)#3 (0) {
34        }
35      }
36    }
37    [1]=>
38    array(2) {
39      ["obj"]=>
40      object(stdClass)#3 (0) {
41      }
42      ["inf"]=>
43      array(1) {
44        ["prev"]=>
45        object(stdClass)#1 (0) {
46        }
47      }
48    }
49  }
50}
51