3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface testInterface { public function doAction(); } class Foo implements testInterface { public function doAction() { echo "Action!"; } } class Bar { protected $test = "test"; } class Baz { public function __construct(testInterface $class) { echo "Everything's ok!"; } } $foo = new Foo(); $bar = new Bar(); $baz = new Baz($bar);
based on 9HmDZ
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to Baz::__construct() must implement interface testInterface, instance of Bar given, called in /in/vilbD on line 31 and defined in /in/vilbD:23 Stack trace: #0 /in/vilbD(31): Baz->__construct(Object(Bar)) #1 {main} thrown in /in/vilbD on line 23
Process exited with code 255.
Output for 5.3.19 - 5.6.21
Catchable fatal error: Argument 1 passed to Baz::__construct() must implement interface testInterface, instance of Bar given, called in /in/vilbD on line 31 and defined in /in/vilbD on line 23
Process exited with code 255.