3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace{ class B{} class A{ function test(B $b){} } } namespace NS{ class B extends \B{} class A1 extends \A{ function test(B $b){} } } namespace{ $x = new \NS\A1; $x->test(new \B); $x->test(new \NS\B); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Declaration of NS\A1::test(NS\B $b) must be compatible with A::test(B $b) in /in/Ptq2g on line 13
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of NS\A1::test(NS\B $b) should be compatible with A::test(B $b) in /in/Ptq2g on line 13 Fatal error: Uncaught TypeError: Argument 1 passed to NS\A1::test() must be an instance of NS\B, instance of B given, called in /in/Ptq2g on line 19 and defined in /in/Ptq2g:13 Stack trace: #0 /in/Ptq2g(19): NS\A1->test(Object(B)) #1 {main} thrown in /in/Ptq2g on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33
Warning: Declaration of NS\A1::test(NS\B $b) should be compatible with A::test(B $b) in /in/Ptq2g on line 14 Fatal error: Uncaught TypeError: Argument 1 passed to NS\A1::test() must be an instance of NS\B, instance of B given, called in /in/Ptq2g on line 19 and defined in /in/Ptq2g:13 Stack trace: #0 /in/Ptq2g(19): NS\A1->test(Object(B)) #1 {main} thrown in /in/Ptq2g on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Catchable fatal error: Argument 1 passed to NS\A1::test() must be an instance of NS\B, instance of B given, called in /in/Ptq2g on line 19 and defined in /in/Ptq2g on line 13
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected '{' in /in/Ptq2g on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '{' in /in/Ptq2g on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Ptq2g on line 3
Process exited with code 255.

preferences:
263.6 ms | 401 KiB | 354 Q