3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace derp { class Foo {} } namespace herp { class BetterFoo extends \derp\Foo {} class Derp { public function __construct(DerpFoo $foo) {} } class_alias('\derp\Foo', 'DerpFoo'); $f = new Derp(new BetterFoo); }
Output for 7.0.0 - 7.3.0rc4
Fatal error: Uncaught TypeError: Argument 1 passed to herp\Derp::__construct() must be an instance of herp\DerpFoo, instance of herp\BetterFoo given, called in /in/Vg2Y9 on line 20 and defined in /in/Vg2Y9:14 Stack trace: #0 /in/Vg2Y9(20): herp\Derp->__construct(Object(herp\BetterFoo)) #1 {main} thrown in /in/Vg2Y9 on line 14
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Catchable fatal error: Argument 1 passed to herp\Derp::__construct() must be an instance of herp\DerpFoo, instance of herp\BetterFoo given, called in /in/Vg2Y9 on line 20 and defined in /in/Vg2Y9 on line 14
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/Vg2Y9 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/Vg2Y9 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Vg2Y9 on line 3
Process exited with code 255.