3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} class B { public function b(A $a) {} } class C extends B { public function b($a) {} } $a = new C();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/UMNlC on line 5 Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/UMNlC on line 13 and exactly 1 expected in /in/UMNlC:6 Stack trace: #0 /in/UMNlC(13): B->b() #1 {main} thrown in /in/UMNlC on line 6
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/UMNlC on line 13 and exactly 1 expected in /in/UMNlC:6 Stack trace: #0 /in/UMNlC(13): B->b() #1 {main} thrown in /in/UMNlC on line 6
Process exited with code 255.
Output for 7.1.0 - 7.1.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/UMNlC on line 5 Warning: Declaration of C::b($a) should be compatible with B::b(A $a) in /in/UMNlC on line 11 Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/UMNlC on line 13 and exactly 1 expected in /in/UMNlC:6 Stack trace: #0 /in/UMNlC(13): B->b() #1 {main} thrown in /in/UMNlC on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/UMNlC on line 5 Warning: Declaration of C::b($a) should be compatible with B::b(A $a) in /in/UMNlC on line 11 Fatal error: Uncaught TypeError: Argument 1 passed to B::b() must be an instance of A, none given, called in /in/UMNlC on line 13 and defined in /in/UMNlC:6 Stack trace: #0 /in/UMNlC(13): B->b() #1 {main} thrown in /in/UMNlC on line 6
Process exited with code 255.
Output for 5.4.4 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Strict Standards: Declaration of C::b() should be compatible with B::b(A $a) in /in/UMNlC on line 11 Catchable fatal error: Argument 1 passed to B::b() must be an instance of A, none given, called in /in/UMNlC on line 13 and defined in /in/UMNlC on line 6
Process exited with code 255.
Output for 5.4.0 - 5.4.3

Process exited with code 139.
Output for 5.3.0 - 5.3.29
Strict Standards: Declaration of C::b() should be compatible with that of B::b() in /in/UMNlC on line 11 Catchable fatal error: Argument 1 passed to B::b() must be an instance of A, none given, called in /in/UMNlC on line 13 and defined in /in/UMNlC on line 6
Process exited with code 255.

preferences:
313.8 ms | 402 KiB | 404 Q