3v4l.org

run code in 200+ php & hhvm versions
<?php trait ATrait { public function a(){ return 'Aa'; } } trait BTrait { public function a(){ return 'Ba'; } } class C { use ATrait{ a as aa; } use BTrait{ a as ba; } public function a() { return static::aa() . static::ba(); } } $o = new C; echo $o->a(), "\n"; class D { use ATrait{ ATrait::a as aa; } use BTrait{ BTrait::a as ba; } public function a() { return static::aa() . static::ba(); } } $o = new D; echo $o->a(), "\n"; class E { use ATrait{ ATrait::a as aa; ATrait::a insteadof BTrait; } use BTrait{ BTrait::a as ba; } public function e() { return static::aa() . static::ba(); } } $o = new E; echo $o->e(), "\n"; class F { use ATrait{ a as aa; } use BTrait{ a as ba; } public function f() { return static::aa() . static::ba(); } } $o = new F; echo $o->f(), "\n";
based on 3aTpi
Output for 7.0.0 - 7.3.1
AaAa AaBa Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; E has a deprecated constructor in /in/mFuQE on line 48 AaBa Fatal error: Trait method a has not been applied, because there are collisions with other trait methods on F in /in/mFuQE on line 65
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: more than one trait contains method 'a' in /in/mFuQE:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: more than one trait contains method 'a' in /in/mFuQE:15 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.38
AaAa AaBa AaBa Fatal error: Trait method a has not been applied, because there are collisions with other trait methods on F in /in/mFuQE on line 76
Process exited with code 255.