Hi Rowan,

Rowan Collins wrote:
Clearly, from the language's point of view, class Baz is missing the
parameters in its function signature that Foo specifies, so the warning
seems perfectly correct to me. In your example, you've replaced a single
optional parameter ($bar = null) with a specification of variadic
parameters (...$args); these are clearly not interchangeable, so again,
the signature is different.

An extending method merely needs to be "compatible", not have an identical signature. The parent class required one optional parameter, the subclass requires zero or more parameters. Those sounds compatible to me. If you can call the parent class's method here, it would also work on the subclass's method.

Thanks.

--
Andrea Faulds
http://ajf.me/

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to