3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait T { protected function __construct() { parent::__construct(42); } } class A { public function __construct($v) { var_dump($v); } } class B extends A { use T; } new B();
based on 2gshW
Output for 7.2.0 - 7.2.6
Fatal error: Uncaught Error: Call to protected B::__construct() from invalid context in /in/3XG9X:15 Stack trace: #0 {main} thrown in /in/3XG9X on line 15
Process exited with code 255.
Output for 7.0.0 - 7.1.20
Fatal error: Access level to T::__construct() must be public (as in class A) in /in/3XG9X on line 12
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: Access level to B::__construct() must be public (as in class A) or weaker in /in/3XG9X:12 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Access level to T::__construct() must be public (as in class A) in /in/3XG9X on line 14
Process exited with code 255.