3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); phpversion() >= "7.0.0" or die(); class Nul { } class C extends Nul { } function m() : C { return new Nul; } var_dump(m());
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.6
Fatal error: Uncaught TypeError: Return value of m() must be an instance of C, instance of Nul returned in /in/LtqQD:14 Stack trace: #0 /in/LtqQD(17): m() #1 {main} thrown in /in/LtqQD on line 14
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.21
Warning: Unsupported declare 'strict_types' in /in/LtqQD on line 1 Parse error: syntax error, unexpected ':', expecting '{' in /in/LtqQD on line 12
Process exited with code 255.

preferences:
58.76 ms | 401 KiB | 47 Q