3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php Interface wut { public function foo( $yolo ); } class dude implements wut { public function foo ( $yolo ): string { echo $yolo; } } $x = new dude(); $x->foo(2);
based on vJP18
Output for 7.0.0 - 7.3.0rc3
2 Fatal error: Uncaught TypeError: Return value of dude::foo() must be of the type string, none returned in /in/YLNLf:10 Stack trace: #0 /in/YLNLf(14): dude->foo(2) #1 {main} thrown in /in/YLNLf on line 10
Process exited with code 255.
Output for hhvm-3.15.4
2 Fatal error: Uncaught TypeError: Value returned from method dude::foo() must be of type string, null given in /in/YLNLf:10 Stack trace: #0 /in/YLNLf(14): dude->foo() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/YLNLf on line 8
Process exited with code 255.