File: igbinary_098.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 (43 lines) | stat: -rw-r--r-- 956 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
--TEST--
Test PHP 8.2 readonly classes
--SKIPIF--
<?php
if (!extension_loaded("igbinary")) print "skip\n";
if (PHP_VERSION_ID < 80200) print "skip php < 8.2\n";
?>
--FILE--
<?php
readonly class C {
    public int $a;
    public static function create() {
        $c = new C();
        $c->a = 8;
        return $c;
    }
}
$c = new C();
$ser = igbinary_serialize($c);
echo urlencode($ser), "\n";
var_dump(igbinary_unserialize($ser));
$c = C::create();
$ser = igbinary_serialize($c);
echo urlencode($ser), "\n";
var_dump(igbinary_unserialize($ser));
$invalid1 = str_replace('a', 'b', $ser);
try {
    var_dump(igbinary_unserialize($invalid1));
} catch (Error $e) {
    printf("%s: %s\n", $e::class, $e->getMessage());
}
--EXPECT--
%00%00%00%02%17%01C%14%01%00
object(C)#2 (0) {
  ["a"]=>
  uninitialized(int)
}
%00%00%00%02%17%01C%14%01%11%01a%06%08
object(C)#1 (1) {
  ["a"]=>
  int(8)
}
Error: Cannot create dynamic property C::$b in igbinary_unserialize