admin wrote:
> Inside the body of method foo() you can of course use syntax like
> parent::foo(). But is there a way to call the parent version of
> obj->foo() outside the class? That kind of syntax is allowed in C++, for
> example: Aclass a; if (a.Aparent::foo()) ...;

there is nothing in the language that provides this functionality
and I would argue that the caller should be able to do such things ...
the object should be in control of the functionality it provides not the user.

hmm, I don't think I explained that very well - I'm having a bit of a
brain freeze ...

if you need to expose parent::foo() via a subclass then you shouldn't
override it in the subclass but rather create a foo2() (for instance)

> 
> Some contrived example to illustrate the point:
> 
> class AParent {
>   public function foo() { .. }
> }
> 
> class A extends AParent {
>   public function foo() {
>     doit($this, __CLASS__, __FUNCTION__);
>   }
> }
> 
> function doit($obj, $classname, $funcname) {
>   if (...)
> //    $obj->classname_parent::$funcname();
> }
> 
> 
> Thanks.
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to