Argument Renaming

<?php

class x           { function foo(int $a, int $b) {} }
class y extends x { function foo(int $b, int $a) {} }

class x2            { function foo(int $a, string $b) {} }
class y2 extends x2 { function foo(string $b, int $a) {} }

Method compatibility does not allow adding or removing arguments between a parent and a child, and types must be compatible.

Yet, it is possible to rename arguments. When the argument types are distinct, method compatibility emits an error, but when both types are identical, this typo may go undetected.

See Also

PHP Error Messages

PHP Features

Last updated: 14 July 2026