3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { function foo() : A { } } $a = new A; $a->foo();
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Return value of A::foo() must be an instance of A, none returned in /in/8F0Z0:8 Stack trace: #0 /in/8F0Z0(12): A->foo() #1 {main} thrown in /in/8F0Z0 on line 8
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/8F0Z0 on line 5
Process exited with code 255.