Re: inheritance check too strict?
| From: | Ionut G. Stan | Date: | Thu, 19 Aug 2010 14:04:26 +0000 |
| Subject: | Re: inheritance check too strict? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49455@lists.php.net to get a copy of this message | ||
On 19/Aug/10 4:16 PM, Ryan Panning wrote:
Nathan Rixham wrote:It still breaks the interface: class Parent {what if Bar implements Foo, or Bar extends Foo - surely that should be compatible given the inheritance chain.I ran into this exact issue and thought it was strange. Is there a reason this shouldn't be allowed?
public function foo(Foo $foo)
{}
}
class Child
{
public function foo(Bar $bar)
{}
}
class Foo
{}
class Bar extends Foo
{}
All fine until here, but what if...
class Taz extends Foo.
{}
I can't call Child::foo() with an instance of Taz, but I can call Parent::foo() with such an instance. So, I can't use instances of Child wherever instances of Parent would be accepted.
--
Ionuț G. Stan | http://igstan.ro