3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public function foo($a = 1) {;}} class B extends A { public function foo($a) {;}} $b = new B(); function bar(A $a) {$a->foo();} bar($b);
Output for 7.1.0 - 7.2.0
Warning: Declaration of B::foo($a) should be compatible with A::foo($a = 1) in /in/dgdFi on line 4 Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::foo(), 0 passed in /in/dgdFi on line 7 and exactly 1 expected in /in/dgdFi:4 Stack trace: #0 /in/dgdFi(7): B->foo() #1 /in/dgdFi(9): bar(Object(B)) #2 {main} thrown in /in/dgdFi on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Warning: Declaration of B::foo($a) should be compatible with A::foo($a = 1) in /in/dgdFi on line 4 Warning: Missing argument 1 for B::foo(), called in /in/dgdFi on line 7 and defined in /in/dgdFi on line 4
Output for 5.4.0 - 5.6.28
Strict Standards: Declaration of B::foo() should be compatible with A::foo($a = 1) in /in/dgdFi on line 4 Warning: Missing argument 1 for B::foo(), called in /in/dgdFi on line 7 and defined in /in/dgdFi on line 4
Output for 5.3.19 - 5.3.29
Strict Standards: Declaration of B::foo() should be compatible with that of A::foo() in /in/dgdFi on line 4 Warning: Missing argument 1 for B::foo(), called in /in/dgdFi on line 7 and defined in /in/dgdFi on line 4