3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Thing { public function method() { $args = func_get_args(); if (count($args) === 2) { if ($args[0] instanceof OtherThing && is_int($args[1])) { $this->methodImplOtherThingInt($args[0], $args[1]); } else if (is_int($args[0]) && is_int($args[1])) { $this->methodImplIntInt($args[0], $args[1]); } } else if (count($args) === 3) { // ... } } public function methodImplOtherThingInt(OtherThing $otherThing, $int) { // stuff } public function methodImplOtherThingInt($int1, $int2) { // stuff } } class BetterThing { public function method(OtherThing $otherThing, int $int) { // stuff } public function method(int $int1, int $int2) { // stuff } }
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Fatal error: Cannot redeclare Thing::methodImplOtherThingInt() in /in/WYJEm on line 25
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: Redeclared method Thing::methodImplOtherThingInt in /in/WYJEm on line 20
Process exited with code 255.