3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Foo { public function doStuff(array $a, $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 IIL14
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.0.0 - 7.1.10
Fatal error: Declaration of Bar::doStuff($a, $b = NULL) must be compatible with Foo::doStuff(array $a, $b = NULL) in /in/P4U05 on line 7
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Fatal error: Declaration of Bar::doStuff() must be compatible with Foo::doStuff(array $a, $b = NULL) in /in/P4U05 on line 7
Process exited with code 255.