3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Checker { public function check(): void {} } class A { public function checkThings() { $check1 = new Checker; $check1->check(); } } $a = new A(); $a->checkThings(); class B { public function checkThings(Checker $checker) { $checker->check(); } } $checker = new Checker(); $b = new B(); $b->checkThings( $checker );
based on WIS2q
Output for hhvm-3.21.3 - 3.22.0, 7.1.0 - 7.3.0beta1
Output for 7.0.0 - 7.0.24
Fatal error: Uncaught TypeError: Return value of Checker::check() must be an instance of void, none returned in /in/i2L9f:4 Stack trace: #0 /in/i2L9f(11): Checker->check() #1 /in/i2L9f(16): A->checkThings() #2 {main} thrown in /in/i2L9f on line 4
Process exited with code 255.
Output for hhvm-3.18.5
Fatal error: Uncaught TypeError: Value returned from method Checker::check() must be of type void, null given in /in/i2L9f:4 Stack trace: #0 /in/i2L9f(11): Checker->check() #1 /in/i2L9f(16): A->checkThings() #2 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/i2L9f on line 4
Process exited with code 255.