3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait A { public function foo() { echo "foo"; } } trait B { use A { foo as foobar; } public function foo() { foobar(); echo "bar"; } } class AB { use A; public function run() { $this->foo(); } } class ABC extends AB { use B; } $me = new ABC(); $me->run();
based on qtB81
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function foobar() in /in/PkLeQ:9 Stack trace: #0 /in/PkLeQ(15): ABC->foo() #1 /in/PkLeQ(24): AB->run() #2 {main} thrown in /in/PkLeQ on line 9
Process exited with code 255.
Output for 5.4.0 - 5.4.10, 5.4.13 - 5.6.28
Fatal error: Call to undefined function foobar() in /in/PkLeQ on line 9
Process exited with code 255.
Output for 5.4.11 - 5.4.12
Fatal error: Trait method foo has not been applied, because there are collisions with other trait methods on ABC in /in/PkLeQ on line 21
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/PkLeQ on line 3
Process exited with code 255.