Hello Emil,
learn inheritance rules!
And besides PHP follows strict is_a rules.
Even if PHP weren't following strict is_a rules:
Every Work2 is a Work1 so and so any place that uses with Work1 objects
can take Work2 objects. Now "$o->f1($c);" might be using a $o being a
work1 or a work2. That means either f1(C1) or f1(C2). The more general
one is C1. So Work2::f1(C2) must be wrong becasue it no longer accepts
C1. But following is_a rules (even non strict) it needs to. So the code
must be wrong.
If you need a book to understand the rules I could direct you but I don't
recomment reading it really....
best regards
marcus
Wednesday, May 30, 2007, 12:17:20 AM, you wrote:
> Hi,
> I'll try get straight to the point:
> class C1 {}
> class C2 extends C1 {}
> abstract class Work1 {
> public function f1(C1 $c);
> }
> class Work2 extends Work1 {
> public function f1(C2 $c);
> }
> Here I get an an error regarding the prototype missmatch.
> Wouldn't it be nice to be able to tighted the requirement - C2 is still C1?
> Regards,
> Emil Ivanov
Best regards,
Marcus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php