Can’t Be Compatible With Less Arguments

../_images/cantBeBackCompatible.png

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