3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php abstract class ParentClass {} class ChildClass extends ParentClass {} class TestClass { public function __construct(ParentClass $parentClass) { } } $childClass = new ChildClass(); $test = new TestClass(childClass); ?>
Output for 7.0.0 - 7.1.0
Notice: Use of undefined constant childClass - assumed 'childClass' in /in/J6NTl on line 18 Fatal error: Uncaught TypeError: Argument 1 passed to TestClass::__construct() must be an instance of ParentClass, string given, called in /in/J6NTl on line 18 and defined in /in/J6NTl:10 Stack trace: #0 /in/J6NTl(18): TestClass->__construct('childClass') #1 {main} thrown in /in/J6NTl on line 10
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Notice: Use of undefined constant childClass - assumed 'childClass' in /in/J6NTl on line 18 Catchable fatal error: Argument 1 passed to TestClass::__construct() must be an instance of ParentClass, string given in /in/J6NTl on line 13
Process exited with code 255.
Output for 5.2.17 - 5.6.28
Notice: Use of undefined constant childClass - assumed 'childClass' in /in/J6NTl on line 18 Catchable fatal error: Argument 1 passed to TestClass::__construct() must be an instance of ParentClass, string given, called in /in/J6NTl on line 18 and defined in /in/J6NTl on line 10
Process exited with code 255.