3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); class A{ protected $stuff; function __construct(int $foo){ $this->stuff = $foo; } function getStuff(): int{ return $this->stuff; } static function __set_state($data){ return new A($data['stuff']); } } $x = new A(0.0); eval('$y = ' . var_export($x, true) . ';'); var_dump($y->getStuff());
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: A::__construct(): Argument #1 ($foo) must be of type int, float given, called in /in/XIYKh on line 16 and defined in /in/XIYKh:5 Stack trace: #0 /in/XIYKh(16): A->__construct(0.0) #1 {main} thrown in /in/XIYKh on line 5
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Fatal error: Uncaught TypeError: A::__construct(): Argument #1 ($foo) must be of type int, float given, called in /in/XIYKh on line 16 and defined in /in/XIYKh:5 Stack trace: #0 /in/XIYKh(16): A->__construct(0) #1 {main} thrown in /in/XIYKh on line 5
Process exited with code 255.
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to A::__construct() must be of the type int, float given, called in /in/XIYKh on line 16 and defined in /in/XIYKh:5 Stack trace: #0 /in/XIYKh(16): A->__construct(0) #1 {main} thrown in /in/XIYKh on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
Fatal error: Uncaught TypeError: Argument 1 passed to A::__construct() must be of the type integer, float given, called in /in/XIYKh on line 16 and defined in /in/XIYKh:5 Stack trace: #0 /in/XIYKh(16): A->__construct(0) #1 {main} thrown in /in/XIYKh on line 5
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/XIYKh on line 1 Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/XIYKh on line 8
Process exited with code 255.

preferences:
220.58 ms | 402 KiB | 268 Q