xref: /PHP-7.4/ext/reflection/tests/bug76737.phpt (revision 96da1fe8)
1--TEST--
2Bug #76737: Unserialized reflection objects are broken, they shouldn't be serializable
3--FILE--
4<?php
5
6try {
7    $r = new ReflectionClass('stdClass');
8    var_dump(serialize($r));
9} catch (Exception $e) {
10    echo $e->getMessage(), "\n";
11}
12try {
13    $s = 'C:15:"ReflectionClass":0:{}';
14    var_dump(unserialize($s));
15} catch (Exception $e) {
16    echo $e->getMessage(), "\n";
17}
18try {
19    $s = 'O:15:"ReflectionClass":0:{}';
20    var_dump(unserialize($s));
21} catch (Exception $e) {
22    echo $e->getMessage(), "\n";
23}
24
25?>
26--EXPECTF--
27Serialization of 'ReflectionClass' is not allowed
28Unserialization of 'ReflectionClass' is not allowed
29
30Warning: Erroneous data format for unserializing 'ReflectionClass' in %s on line %d
31
32Notice: unserialize(): Error at offset 26 of 27 bytes in %s on line %d
33bool(false)
34