I'm trying to redefine the behaviour of the magic method __set
in a trait. The problem shows up when I also want to access from the trait to the parent class custom __set
function.
trait TestingTrait {
public function __set($key, $value)
{
// Some stuff...
parent::__set($key, $value);
// self::__set($key, $value);
}
}
class TestingClass {
use TestingTrait;
}
$var = new TestingClass();
$var->value = 'some value';
Everything works perfect until I need to also use the main class __set
method as it's doing some other stuff with the variable sets.
I've tried with self
but it goes into an infinite loop. Is there any way to access the main class?