Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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: 10 September 2026