Re: RfC: rethink OO inheritance strictness
| From: | Jochem Maas | Date: | Thu, 03 Aug 2006 15:26:13 +0000 |
| Subject: | Re: RfC: rethink OO inheritance strictness | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-25191@lists.php.net to get a copy of this message | ||
Rasmus Lerdorf wrote:
> Pierre wrote:
>> Hello,
>>
>> On 8/3/06, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
>>
>>> I'm not all that keen on a new keyword for this. How about using an
>>> interface to indicate strictness? Isn't this really what interfaces are
>>> all about?
>>
>> I don't like new keywords either, but I don't see any alternative. I
>> also think that interfaces are what should be used. But it seems that
>> we are wrong, interfaces do not solve this issue, I'm still unsure
>> about the reasons though...
>
> Well, currently they don't because they don't care about method
> signatures, but they could be made to care. Are there reasons beyond that?
erm, interfaces do care about method signatures either that or my php5 install
is magic:
# php5 -r '
interface Foo { function bar($v, $k); } class Qux implements Foo { function bar() {} }'
Fatal error: Declaration of Qux::bar() must be compatible with that of Foo::bar() in Command line
code on line 2
# php5 -r '
interface Foo { function bar($v, $k); } class Qux implements Foo { function bar($a, $b, $c) {}
}'
Fatal error: Declaration of Qux::bar() must be compatible with that of Foo::bar() in Command line
code on line 2
>
> -Rasmus
>