I found myself in this situation and I just hacked it dirtily. But I wonder, is there some clean way?
class base{
var $value;
public function getValue(){
return 'returned from base: '. $value;
}
}
class object extends base{
public function getValue(){
$this->value = 'wrong value';
return parent::getValue();
}
}
class overwrite extends object{
public function getValue(){
$this->value = 'right value';
?????
}
}
$o = new overwrite;
echo $o->getValue();
All I'm allowed to edit is overwrite
. If I call parent::getValue()
, the value gets overwritten by wrong value. If I name the class, like base::getValue()
, the base class would not have $value
property set.