Re: inheritance check too strict?
| From: | mathieu.suen | Date: | Thu, 19 Aug 2010 15:21:50 +0000 |
| Subject: | Re: inheritance check too strict? | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49458@lists.php.net to get a copy of this message | ||
I consider having type in the declaration of a method a bad idea and this thread just prove it.
You can also read this:
http://gbracha.blogspot.com/2009/09/systemic-overload.html
On 08/19/2010 10:32 AM, Johannes Schlüter wrote:
On Thu, 2010-08-19 at 01:13 -0700, Stas Malyshev wrote:Let|s take a look at making it one step more complex: class A {Hi!Your impression is wrong. Overriden method should have _compatible_ signature - i.e. accept any argument set that parent object accepted. Nothing requires it to have the same signature.proper polymorphism, overridden methods should share the parent's method signature, although they can have additional optional arguments.I was under the impression that, in order for inheritance to provide
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().
So I consider the message good and correct.
johannes
--
• *Mathieu Suen* | It Team | www.easyflirt.com
• mathieu [dot] suen [at] easyflirt [dot] com
<mathieu%20[dot]%20suen%20[at]%20easyflirt%20[dot]%20com>
• EasyFlirt - Park Nord, Les Pléiades, 74370 - Metz-Tessy - FRANCE
• Pensez à l'environnement, n'imprimez cet e-mail qu'en cas de réelle
nécessité