Re: Calling methods of parent/ancestor classes in PHP5
| From: | Ferdinand Beyer | Date: | Wed, 18 Feb 2004 14:01:59 +0000 |
| Subject: | Re: Calling methods of parent/ancestor classes in PHP5 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7950@lists.php.net to get a copy of this message | ||
On 17 Feb 2004 at 14:01, Brad Fisher wrote:
> class D {
> function bar() {
> $c = new C;
> // I'd like to call the A::foo method of C here...
> // In PHP4, I could do something like:
Why should one want to do that? Why should PHP allow this?
$c is not an A, it is a C. Of course C is a special version of A, so it is
compatible to A. But it still is a C.
There will be a reason why C has overridden the A implementation of
foo(). It is possible that the original implementation is not compatible
to C, so it could be a risk to call the old method.
The feature you are asking for is not available in any OO language
and it even conflicts with the OOP ideology!
--
Ferdinand Beyer
<fb@fbeyer.com>