3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types = 1); class A{ protected $stuff; function __construct(float $foo){ $this->stuff = $foo; } function getStuff(): float{ 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());
based on XIYKh
Output for 7.0.0 - 7.2.0
float(0)
Output for 5.3.19 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/ppk2I on line 1 Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/ppk2I on line 8
Process exited with code 255.