3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL|E_STRICT); class Foo {} class Hoge { public function aaa(Foo $foo) { echo 'hoge: ' . PHP_EOL; var_dump($foo); } } class Bar extends Hoge { public function aaa(Foo $foo = null) { echo 'foo: ' . PHP_EOL; var_dump($foo); } } $hoge = new Hoge(); $hoge->aaa(null); $bar = new Bar(); $bar->aaa(new Foo());
based on nQhYD
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to Hoge::aaa() must be an instance of Foo, null given, called in /in/cGhoD on line 26 and defined in /in/cGhoD:9 Stack trace: #0 /in/cGhoD(26): Hoge->aaa(NULL) #1 {main} thrown in /in/cGhoD on line 9
Process exited with code 255.
Output for 5.3.22 - 5.6.28
Catchable fatal error: Argument 1 passed to Hoge::aaa() must be an instance of Foo, null given, called in /in/cGhoD on line 26 and defined in /in/cGhoD on line 9
Process exited with code 255.