3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait X{ function tryA(A $a){ $this->test($a); } function test(A $a){} // can't solve signatures incompatibility... } trait Y{ function tryB(B $b){ $this->test($b); } function test(B $b){} // when arguments are different... } class LOL{ use X, Y{ X::test insteadof Y; // this doesn't actually solve anything... } } class A{} class B{} $x = new LOL; $x->tryA(new A); $x->tryB(new B);
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to LOL::test() must be an instance of A, instance of B given, called in /in/YGjBZ on line 13 and defined in /in/YGjBZ:8 Stack trace: #0 /in/YGjBZ(13): LOL->test(Object(B)) #1 /in/YGjBZ(31): LOL->tryB(Object(B)) #2 {main} thrown in /in/YGjBZ on line 8
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Catchable fatal error: Argument 1 passed to LOL::test() must be an instance of A, instance of B given, called in /in/YGjBZ on line 13 and defined in /in/YGjBZ on line 8
Process exited with code 255.
Output for 5.3.17 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/YGjBZ on line 3
Process exited with code 255.