3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php error_reporting(-1); ini_set('log_errors','Off'); ini_set('display_errors', 'On'); trait collision { public function collisionMethod() { echo "collision\n"; } public function unusedMethod() { echo "unused\n"; } } trait A { use collision; public function sayA() { $this->collisionMethod(); echo "Aです\n"; } } trait B { use collision; public function sayB() { $this->collisionMethod(); echo "Bです\n"; } } class User { use A; use B; } $user = new User; $user->sayA(); $user->sayB();
Output for 7.3.0
collision Aです collision Bです
Output for 7.0.0 - 7.2.13
Fatal error: Trait method collisionMethod has not been applied, because there are collisions with other trait methods on User in /in/4kqGt on line 40
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Method 'collisionMethod' declared in multiple traits in /in/4kqGt:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.11.1 - 3.21.3
Fatal error: Uncaught Error: Method 'collisionMethod' declared in multiple traits in /in/4kqGt:40 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.1
Fatal error: Method 'collisionMethod' declared in multiple traits in /in/4kqGt on line 40
Process exited with code 255.
Output for 5.4.0 - 5.6.38
Fatal error: Trait method collisionMethod has not been applied, because there are collisions with other trait methods on User in /in/4kqGt on line 43
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/4kqGt on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/4kqGt on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/4kqGt on line 7
Process exited with code 255.