Re: extending interfaces - fringe behavior
| From: | Marcus Boerger | Date: | Mon, 16 Feb 2004 21:35:28 +0000 |
| Subject: | Re: extending interfaces - fringe behavior | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7892@lists.php.net to get a copy of this message | ||
Hello Hans,
Monday, February 16, 2004, 10:07:53 PM, you wrote:
> Hi -
> Zeev Suraski wrote:
>> At 07:55 16/02/2004, Hans Lellelid wrote:
>>
>>> I have a need in a current application to extend interfaces and
>>> possibly re-define (change signature) some of the inherited methods in
>>> the child interface.
>> ...
>>
>>
>> You're not supposed to change the signature when you're
>> extending/implementing interfaces. I'll try to see if it's feasible to
>> improve the checks so that they compare signatures in a smarter way
>> (i.e., func($arg1, $arg2=null) is compatible with func($arg1), and
>> currently it's not detected that way).
>>
> Yeah, I realize that wanting to change signatures of parent interfaces
> is a little weird; I'd submit that it does allow for some nice design
> possibilities -- but perhaps modifying an interface is at odds with the
> idea of an interface. I think I probably want to just copy & paste the
> methods that are the same rather than extend.
> Making it possible to re-define methods w/ additional null params would
> be nice if that makes sense.
In C++ overwritten default value of derived classes are ignored because the
binding happens at compile time and the default values would have been
evaluated at run time to work as expected.
Now PHP is different. We would have the default values at runtim and compile
time and the problem is only inheriting the methods. Currently NULL matches
any time so it could work. Zeev maybe this is something worth to verify?
Best regards,
Marcus mailto:helly@php.net