3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface fooAPI{ public function doFoo(); } trait fooable{ protected $foo; public function __construct( $foo ){ $this->_foo = $foo; } public function doFoo(){ return $this->_foo; } } class Foo{ use fooable{ fooable::__construct as _fooable__construct; _fooable__construct as protected; } public function __construct(){ $this->_fooable__construct( "foo" ); } } echo (new Foo)->doFoo();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: The modifiers of the trait method _fooable__construct() are changed, but this method does not exist. Error in /in/YllN2 on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: The modifiers for the trait alias _fooable__construct() need to be changed in the same statement in which the alias is defined. Error in /in/YllN2 on line 13
Process exited with code 255.
Output for 5.4.8 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Fatal error: The modifiers for the trait alias _fooable__construct() need to be changed in the same statment in which the alias is defined. Error in /in/YllN2 on line 21
Process exited with code 255.

preferences:
189.36 ms | 402 KiB | 231 Q