3v4l.org

run code in 200+ 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.2.0 - 7.3.0rc4
Warning: Use of undefined constant childClass - assumed 'childClass' (this will throw an Error in a future version of PHP) 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 7.0.0 - 7.1.20
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.11.1 - 3.17.3
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 in /in/J6NTl:13 Stack trace: #0 /in/J6NTl(18): TestClass->__construct() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.1
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.3.0 - 5.6.30
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.