3v4l.org

run code in 500+ PHP versions simultaneously
<?php class x { function foo(int $a, int ...$args) {} } class y extends x { function foo( int ...$args) {} } // OK! //class z extends x { function foo(int $a, int $b, int ...$args) {} } // KO class x2 { function foo() {} } class y2 extends x2 { function foo(mixed ...$args) {} } // OK! //class y22 extends x2 { function foo(mixed $a, mixed ...$args) {} } // KO class x4 { function foo($a, $b) {} } class y4 extends x4 { function foo($b, $c, $d) {} } // OK! //class y22 extends x2 { function foo(mixed $a, mixed ...$args) {} } // KO class x3 { function foo(mixed ...$args) {} } //class y3 extends x3 { function foo() {} } // KO //class y32 extends x3 { function foo(mixed $a) {} } // KOx class x4 { function foo(int $a, int $b) {} } class y4 extends x4 { function foo(int $b, int $a) {} } // KO
Output for 8.3.5, 8.4.18
Fatal error: Declaration of y4::foo($b, $c, $d) must be compatible with x4::foo($a, $b) in /in/6kQRu on line 12
Process exited with code 255.

preferences:
44.04 ms | 493 KiB | 3 Q