On 19/Aug/10 4:16 PM, Ryan Panning wrote:
Nathan Rixham wrote:
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?
It still breaks the interface:
class Parent
{
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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php