An example of a method __call in PHP?

I heard that using the magic method __call in php, you can simulate multiple inheritance (not supported by php). Could cause or give a link to a simple example of such implementation?
June 7th 19 at 14:40
2 answers
June 7th 19 at 14:44
class Class1 {
 public function test1() {}
}

class Class2 {
 public function test2() {}
}

class Class3 extends Class1 {
 protected $parent;
 public function __construct() {
 $this->parent = new Class2();
}

 public function __call(string $method_name, array $arguments) {
 return call_user_func([$this->parent, $method_name], $arguments);
}
}

$example = new Class3();
$example->test2();

IMHO this solution is better never to use.
I agree with You that it is better not to use, and multiple inheritance in General should be avoided. But such implementation is not exactly the emulation of multiple inheritance because:
1. Class3 Class2 is not
2. If there is a name conflict between Class2 and Class1 then have to invent even more crutches
3. What would be inherited from more than two classes will have to invent even more crutches .... - bryana.Renn commented on June 7th 19 at 14:47
June 7th 19 at 14:42
Emulating multiple inheritance using the method of __call if ever there was something in the past. Most of the problems of multiple inheritance can be achieved using traits and interfaces

Find more questions by tags PHP