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; public static function create() { return new self(); } } B::create();
based on dSCKh
Output for 7.2.0 - 7.3.0rc3
int(42)
Output for 7.0.0 - 7.1.20
Fatal error: Access level to T::__construct() must be public (as in class A) in /in/biID0 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/biID0: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/biID0 on line 17
Process exited with code 255.