<?php
class HasProp {
public int $x;
public function __sleep() { return ['x']; }
}
$x = new HasProp();
// string(28) "O:7:"HasProp":1:{s:1:"x";N;}"
var_dump($s = serialize($x));
// Fatal error: Uncaught TypeError: Typed property HasProp::$x must be int, null used in ...
unserialize($s);
Fatal error: Uncaught Error: Typed property HasProp::$x must not be accessed before initialization (in __sleep) in /in/PCLm3:8
Stack trace:
#0 /in/PCLm3(8): serialize(Object(HasProp))
#1 {main}
thrown in /in/PCLm3 on line 8
Process exited with code 255.
Output for 7.4.0 - 7.4.1
Notice: serialize(): "x" returned as member variable from __sleep() but does not exist in /in/PCLm3 on line 8
string(28) "O:7:"HasProp":1:{s:1:"x";N;}"
Fatal error: Uncaught TypeError: Typed property HasProp::$x must be int, null used in /in/PCLm3:10
Stack trace:
#0 /in/PCLm3(10): unserialize('O:7:"HasProp":1...')
#1 {main}
thrown in /in/PCLm3 on line 10
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/PCLm3 on line 3
Process exited with code 255.