3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class A { public function test(): void { return; } public function test2(): void { return null; } } (new A())->test(); echo 'First OK'; (new A())->test2();
Output for 7.1.0 - 7.1.7
Fatal error: A void function must not return a value (did you mean "return;" instead of "return null;"?) in /in/FHhh4 on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught TypeError: Return value of A::test() must be an instance of void, none returned in /in/FHhh4:9 Stack trace: #0 /in/FHhh4(18): A->test() #1 {main} thrown in /in/FHhh4 on line 9
Process exited with code 255.

preferences:
196.24 ms | 1399 KiB | 36 Q