3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Foo { public function doStuff(array $a, string $b = null); } class Bar implements Foo { public function doStuff($a, $b = null) { var_dump($a, $b); } } $a = new Bar(); $a->doStuff([1,2,3,4], 'asdsad'); $a->doStuff([5,6,7,8]);
based on DLfHv
Output for 7.2.0
array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } string(6) "asdsad" array(4) { [0]=> int(5) [1]=> int(6) [2]=> int(7) [3]=> int(8) } NULL
Output for 7.1.0 - 7.1.10
Fatal error: Declaration of Bar::doStuff($a, $b = NULL) must be compatible with Foo::doStuff(array $a, ?string $b = NULL) in /in/IIL14 on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Declaration of Bar::doStuff($a, $b = NULL) must be compatible with Foo::doStuff(array $a, string $b = NULL) in /in/IIL14 on line 7
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Fatal error: Declaration of Bar::doStuff() must be compatible with Foo::doStuff(array $a, string $b = NULL) in /in/IIL14 on line 7
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/IIL14 on line 14
Process exited with code 255.