3v4l.org

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