File: __serialize_012.phpt

package info (click to toggle)
php-igbinary 3.2.16-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,024 kB
  • sloc: ansic: 3,373; xml: 1,106; pascal: 10; makefile: 2; php: 2; sh: 1
file content (55 lines) | stat: -rw-r--r-- 1,105 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
--TEST--
Test unserialization of classes derived from ArrayIterator
--SKIPIF--
<?php if (PHP_VERSION_ID < 70406) { echo "Skip requires php 7.4.6+"; } ?>
--FILE--
<?php
// based on bug45706.phpt from php-src
//
// NOTE: ArrayIterator::__debugInfo adds a fake private property that doesn't actually exist, which affects var_dump.
// This isn't a bug in the unserializer.
class Foo1 extends ArrayIterator
{
}
class Foo2 {
}
$x = array(new Foo1(),new Foo2);
$s = igbinary_serialize($x);
var_dump(igbinary_unserialize($s));
$s = str_replace("Foo", "Bar", $s);
$y = igbinary_unserialize($s);
var_dump($y);
--EXPECTF--
array(2) {
  [0]=>
  object(Foo1)#3 (1) {
    ["storage":"ArrayIterator":private]=>
    array(0) {
    }
  }
  [1]=>
  object(Foo2)#4 (0) {
  }
}
array(2) {
  [0]=>
  object(__PHP_Incomplete_Class)#4 (5) {
    ["__PHP_Incomplete_Class_Name"]=>
    string(4) "Bar1"
    ["0"]=>
    int(0)
    ["1"]=>
    array(0) {
    }
    ["2"]=>
    array(0) {
    }
    ["3"]=>
    NULL
  }
  [1]=>
  object(__PHP_Incomplete_Class)#3 (1) {
    ["__PHP_Incomplete_Class_Name"]=>
    string(4) "Bar2"
  }
}