- var_dump: documentation ( source)
<?php
function test(ReflectionFunctionAbstract $r) {
echo 'isClosure(): '; var_dump($r->isClosure());
if ($r instanceof ReflectionMethod) {
$rc = $r->getDeclaringClass();
$dc = $rc ? $rc->getName() : 'no declaring class';
} else {
$dc = 'not a ReflectionMethod';
}
echo 'getDeclaringClass(): ' . $dc;
echo "\n";
$csc = $r->getClosureScopeClass();
echo 'getClosureScopeClass(): ' . ($csc ? $csc->getName() : 'no closure scope class');
echo "\n";
echo "\n";
}
class C {
function f() {
return function($p) {};
}
}
class C2 {}
$c = new C; $cl = $c->f();
$rf = new ReflectionFunction($cl);
test($rf);
$rps = $rf->getParameters();
$rp = $rps[0];
test($rp->getDeclaringFunction());
$cl->bindTo(new C2);
$rf = new ReflectionFunction($cl);
test($rf);
$rps = $rf->getParameters();
$rp = $rps[0];
test($rp->getDeclaringFunction());