3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { private $x ='x'; public function a(self $foo): void { var_dump($foo->x); } } (new Foo())->a(new Foo());
based on huVWG
Output for 7.1.0 - 7.2.6
string(1) "x"
Output for 7.0.0 - 7.0.20
string(1) "x" Fatal error: Uncaught TypeError: Return value of Foo::a() must be an instance of void, none returned in /in/PePK3:9 Stack trace: #0 /in/PePK3(12): Foo->a(Object(Foo)) #1 {main} thrown in /in/PePK3 on line 9
Process exited with code 255.
Output for hhvm-3.15.4
string(1) "x" Fatal error: Uncaught TypeError: Value returned from method Foo::a() must be of type void, null given in /in/PePK3:9 Stack trace: #0 /in/PePK3(12): Foo->a() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/PePK3 on line 6
Process exited with code 255.