function ReflectionCaster::castClosure
1 call to ReflectionCaster::castClosure()
- CutStub::__construct in vendor/
symfony/ var-dumper/ Caster/ CutStub.php
File
-
vendor/
symfony/ var-dumper/ Caster/ ReflectionCaster.php, line 38
Class
- ReflectionCaster
- Casts Reflector related classes to array representation.
Namespace
Symfony\Component\VarDumper\CasterCode
public static function castClosure(\Closure $c, array $a, Stub $stub, bool $isNested, int $filter = 0) : array {
$prefix = Caster::PREFIX_VIRTUAL;
$c = new \ReflectionFunction($c);
$a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter);
if (!$c->isAnonymous()) {
$stub->class = isset($a[$prefix . 'class']) ? $a[$prefix . 'class']->value . '::' . $c->name : $c->name;
unset($a[$prefix . 'class']);
}
unset($a[$prefix . 'extra']);
$stub->class .= self::getSignature($a);
if ($f = $c->getFileName()) {
$stub->attr['file'] = $f;
$stub->attr['line'] = $c->getStartLine();
}
unset($a[$prefix . 'parameters']);
if ($filter & Caster::EXCLUDE_VERBOSE) {
$stub->cut += ($c->getFileName() ? 2 : 0) + \count($a);
return [];
}
if ($f) {
$a[$prefix . 'file'] = new LinkStub($f, $c->getStartLine());
$a[$prefix . 'line'] = $c->getStartLine() . ' to ' . $c->getEndLine();
}
return $a;
}