3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php abstract class x { function test($z, x $x) { var_dump($x); } } class y extends x { function test($z, $x = null) { parent::test($x, $x); } } (new y)->test(null);
based on UuE4L
Output for 7.2.0
Fatal error: Uncaught TypeError: Argument 2 passed to x::test() must be an instance of x, null given, called in /in/45tDp on line 13 and defined in /in/45tDp:4 Stack trace: #0 /in/45tDp(13): x->test(NULL, NULL) #1 /in/45tDp(17): y->test(NULL) #2 {main} thrown in /in/45tDp on line 4
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Warning: Declaration of y::test($z, $x = NULL) should be compatible with x::test($z, x $x) in /in/45tDp on line 15 Fatal error: Uncaught TypeError: Argument 2 passed to x::test() must be an instance of x, null given, called in /in/45tDp on line 13 and defined in /in/45tDp:4 Stack trace: #0 /in/45tDp(13): x->test(NULL, NULL) #1 /in/45tDp(17): y->test(NULL) #2 {main} thrown in /in/45tDp on line 4
Process exited with code 255.
Output for 5.4.8 - 5.6.28
Strict Standards: Declaration of y::test() should be compatible with x::test($z, x $x) in /in/45tDp on line 15 Catchable fatal error: Argument 2 passed to x::test() must be an instance of x, null given, called in /in/45tDp on line 13 and defined in /in/45tDp on line 4
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Strict Standards: Declaration of y::test() should be compatible with that of x::test() in /in/45tDp on line 15 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/45tDp on line 17
Process exited with code 255.