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(); (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/BPdH6 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/BPdH6:9 Stack trace: #0 /in/BPdH6(18): A->test() #1 {main} thrown in /in/BPdH6 on line 9
Process exited with code 255.

preferences:
169.54 ms | 1395 KiB | 36 Q