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

Named Parameter Inheritance

<?php
  
interface I { function foo(int $i); }

class X implements I { function foo(int $x) { echo $x; } }

(new X)->foo(x: 1);
(new X)->foo(i: 1);
  
?>

PHP enforces the methods compatibility with their types, names, and various options, but not with the parameter names. This means the parameter name existence is enforced, but the name might change. It might change between the parent and the child, but also, between the class and the interface.

It is recommended to keep all these parameter’s name identical, so as to keep consistence in the code, and simplify the usage of the method, with named parameters.

See Also

PHP Error Messages

PHP Features

Last updated: 10 September 2026