3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait Trait1 { public function init() { echo("Trait1 - init\n"); } } trait Trait2 { public function init() { echo("Trait2 - init\n"); } } class Test { use Trait1 { init as public method1trait1; } use Trait2 { init as public method1trait2; } final public function __construct() { $this->init(); $this->method1trait1(); $this->method1trait2(); } public function init() { echo("Test - init\n"); } } $test = new Test(); $reflection = new ReflectionClass( $test ); foreach($reflection->getTraitAliases() as $k => $v) { echo $k.' => '.$v."\n"; }
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0rc3
Test - init Trait1 - init Trait1 - init method1trait1 => Trait1::init method1trait2 => Trait1::init
Output for hhvm-3.15.4
Fatal error: Uncaught Error: more than one trait contains method 'init' in /in/04E0q:20 Stack trace: #0 {main}
Process exited with code 255.