File: SplObjectStorage_unserialize_nested.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (46 lines) | stat: -rw-r--r-- 783 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--TEST--
SPL: Test unserializing tested & linked storage
--FILE--
<?php
$o = new StdClass();
$a = new StdClass();

$o->a = $a;

$so = new SplObjectStorage();

$so[$o] = 1;
$so[$a] = 2;

$s = serialize($so);
echo $s."\n";

$so1 = unserialize($s);
var_dump($so1);
?>
--EXPECT--
O:16:"SplObjectStorage":2:{i:0;a:4:{i:0;O:8:"stdClass":1:{s:1:"a";O:8:"stdClass":0:{}}i:1;i:1;i:2;r:4;i:3;i:2;}i:1;a:0:{}}
object(SplObjectStorage)#4 (1) {
  ["storage":"SplObjectStorage":private]=>
  array(2) {
    [0]=>
    array(2) {
      ["obj"]=>
      object(stdClass)#5 (1) {
        ["a"]=>
        object(stdClass)#6 (0) {
        }
      }
      ["inf"]=>
      int(1)
    }
    [1]=>
    array(2) {
      ["obj"]=>
      object(stdClass)#6 (0) {
      }
      ["inf"]=>
      int(2)
    }
  }
}