Re: inheritance check too strict?

From: Date: Thu, 19 Aug 2010 16:42:24 +0000
Subject: Re: inheritance check too strict?
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-49461@lists.php.net to get a copy of this message
Hi!
class A {
     public function foo(Foo $a = null) {}
} class B extends A {
     public function foo() {}
} class C extends B {
     public function foo(Bar $a = null) {}
} Here B::foo() is compatible with A:foo() and as the parameter is optional C::foo() is compatible with B::foo(). But C::foo() is no more compatible with A::foo().
Between B and C there's of course incompatibility - while B accepts anything (and ignores it), C accepts only Bar or nothing. But I was talking between A and B! -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#49461) next »