3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL|E_STRICT); class Foo {} class Hoge { public function aaa(Foo $foo, $piyo) { var_dump($foo); } } class Bar extends Hoge { public function aaa($foo = null) { parent::aaa($foo, 'aaa'); } } $hoge = new Hoge(); $hoge->aaa(new Foo(), 'aaa'); $bar = new Bar(); $bar->aaa(new Foo());
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Declaration of Bar::aaa($foo = null) must be compatible with Hoge::aaa(Foo $foo, $piyo) in /in/0EJ6s on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of Bar::aaa($foo = NULL) should be compatible with Hoge::aaa(Foo $foo, $piyo) in /in/0EJ6s on line 17 object(Foo)#2 (0) { } object(Foo)#3 (0) { }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Warning: Declaration of Bar::aaa($foo = NULL) should be compatible with Hoge::aaa(Foo $foo, $piyo) in /in/0EJ6s on line 21 object(Foo)#2 (0) { } object(Foo)#3 (0) { }
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Strict Standards: Declaration of Bar::aaa() should be compatible with Hoge::aaa(Foo $foo, $piyo) in /in/0EJ6s on line 21 object(Foo)#2 (0) { } object(Foo)#3 (0) { }

preferences:
200.49 ms | 402 KiB | 228 Q