3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Bar { } class Foo { public function getBar(): Bar { return 10; } } $foo = new Foo(); var_dump($foo->getBar());
based on jqv3P
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Return value of Foo::getBar() must be an instance of Bar, integer returned in /in/qls5E:11 Stack trace: #0 /in/qls5E(17): Foo->getBar() #1 {main} thrown in /in/qls5E on line 11
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/qls5E on line 9
Process exited with code 255.