- var_dump: documentation ( source)
<?php
function test(ReflectionFunctionAbstract $r) {
var_dump($r->isClosure());
$dc = $r->getDeclaringClass();
var_dump($dc ? $dc->getName() : 'no declaring class');
$csc = $r->getClosureScopeClass();
var_dump($csc ? $csc->getName() : 'no closure scope class');
echo "\n\n";
}
class C {
function f() {
return function($p) {};
}
}
$c = new C; $cl = $c->f();
// instantiate ReflectionFunction directly on closure
$rf = new ReflectionFunction($cl);
test($rf);
// get ReflectionFunction via one of the initial ReflectionFunction's ReflectionParameter objects
$rps = $rf->getParameters();
$rp = $rps[0];
test($rp->getDeclaringFunction());