- var_dump: documentation ( source)
- is_callable: documentation ( source)
<?php
trait SomeTrait
{
public function __call($method, array $parameters)
{
// ...
return is_callable(['parent', '__call']) ? parent::__call($method, $parameters) : null;
}
}
class GreatParentClass
{
public function __call($method, array $parameters)
{
return 'bar';
}
}
class ParenClassWithoutCall
{
}
class ProxyClass extends GreatParentClass
{
}
class FooClass extends ProxyClass
{
use SomeTrait;
}
class BarClass extends GreatParentClass
{
use SomeTrait;
}
class BazClass extends ParenClassWithoutCall
{
use SomeTrait;
}
class SomeClassWithoutParent
{
use SomeTrait;
}
$class = new FooClass();
var_dump($class->foobar());
$class = new BarClass();
var_dump($class->foobar());
$class = new BazClass();
var_dump($class->foobar());
$class = new SomeClassWithoutParent();
var_dump($class->foobar());