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

Can’t Be Compatible With Less Arguments

<?php

interface i {
    function foo($a) ;
}

interface j extends i {
    function foo($a, $b = 3);
}

interface k extends j {
    function foo($a = 4, $b = 3);
}

interface l extends k {
    function foo();
}

A method is compatible with its parent’s version when it has at least the same number of arguments. This is valid with classes, but also with interfaces.

A child method is compatible with its parent when adding a new argument, as long as the argument as a default value.

Another child may also be compatible by adding a default value to the existing argument. At that point, calling the method without any argument is now a valid call.

Yet, it is not possible to rewrite the method without arguments because it would be incompatible with the method definition of the parent, even though it is always possible to call both versions the same way.

See Also

PHP Error Messages

PHP Features

Last updated: 10 September 2026