3v4l.org

run code in 300+ PHP versions simultaneously
<?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.3.28, 5.4.0 - 5.4.23, 5.5.0 - 5.5.7
Fatal error: Cannot redeclare Thing::methodImplOtherThingInt() in /in/WYJEm on line 25
Process exited with code 255.

preferences:
182.24 ms | 1395 KiB | 68 Q