3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Baz { protected $data; function __construct($d) { $this->data = $d; } function getData() { return $this->data; } } trait A { protected $a; function run() { echo $this->a->getData(); } } class Foo { use A; function __construct() { $this->a = new Baz('Hello '); } } class Bar { use A; function __construct() { $this->a = new Foo(); } } (new Foo)->run(); (new Bar)->run();
based on 2tu0f
Output for 7.0.0 - 7.3.0beta1
Hello Fatal error: Uncaught Error: Call to undefined method Foo::getData() in /in/enIAJ:18 Stack trace: #0 /in/enIAJ(39): Bar->run() #1 {main} thrown in /in/enIAJ on line 18
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Hello Fatal error: Call to undefined method Foo::getData() in /in/enIAJ on line 18
Process exited with code 255.