- var_dump: documentation ( source)
<?php
trait Qux
{
public static function bar()
{
return __CLASS__;
}
}
class Foo
{
use Qux;
}
class Baz extends Foo
{
}
$reflectionTrait = new ReflectionMethod('Qux', 'bar');
$reflectionClass = new ReflectionMethod('Foo', 'bar');
$reflectionExtended = new ReflectionMethod('Baz', 'bar');
var_dump(Qux::bar(), $reflectionTrait->getDeclaringClass()->getName(), $reflectionTrait->invoke(null));
var_dump(Foo::bar(), $reflectionClass->getPrototype()->getDeclaringClass()->getName(), $reflectionClass->invoke(null));
var_dump(Baz::bar(), $reflectionExtended->getDeclaringClass()->getName(), $reflectionExtended->invoke(null));