function ReflectionCaster::castFunctionAbstract
3 calls to ReflectionCaster::castFunctionAbstract()
- ClassStub::__construct in vendor/
symfony/ var-dumper/ Caster/ ClassStub.php - ExceptionCaster::extractSource in vendor/
symfony/ var-dumper/ Caster/ ExceptionCaster.php - ReflectionCaster::castClosure in vendor/
symfony/ var-dumper/ Caster/ ReflectionCaster.php
File
-
vendor/
symfony/ var-dumper/ Caster/ ReflectionCaster.php, line 199
Class
- ReflectionCaster
- Casts Reflector related classes to array representation.
Namespace
Symfony\Component\VarDumper\CasterCode
public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, bool $isNested, int $filter = 0) : array {
$prefix = Caster::PREFIX_VIRTUAL;
self::addMap($a, $c, [
'returnsReference' => 'returnsReference',
'returnType' => 'getReturnType',
'class' => 'getClosureCalledClass',
'this' => 'getClosureThis',
]);
if (isset($a[$prefix . 'returnType'])) {
$v = $a[$prefix . 'returnType'];
$v = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v;
$a[$prefix . 'returnType'] = new ClassStub($a[$prefix . 'returnType'] instanceof \ReflectionNamedType && $a[$prefix . 'returnType']->allowsNull() && !\in_array($v, [
'mixed',
'null',
], true) ? '?' . $v : $v, [
class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '',
'',
]);
}
if (isset($a[$prefix . 'class'])) {
$a[$prefix . 'class'] = new ClassStub($a[$prefix . 'class']);
}
if (isset($a[$prefix . 'this'])) {
$a[$prefix . 'this'] = new CutStub($a[$prefix . 'this']);
}
foreach ($c->getParameters() as $v) {
$k = '$' . $v->name;
if ($v->isVariadic()) {
$k = '...' . $k;
}
if ($v->isPassedByReference()) {
$k = '&' . $k;
}
$a[$prefix . 'parameters'][$k] = $v;
}
if (isset($a[$prefix . 'parameters'])) {
$a[$prefix . 'parameters'] = new EnumStub($a[$prefix . 'parameters']);
}
self::addAttributes($a, $c, $prefix);
if (!($filter & Caster::EXCLUDE_VERBOSE) && ($v = $c->getStaticVariables())) {
foreach ($v as $k => &$v) {
if (\is_object($v)) {
$a[$prefix . 'use']['$' . $k] = new CutStub($v);
}
else {
$a[$prefix . 'use']['$' . $k] =& $v;
}
}
unset($v);
$a[$prefix . 'use'] = new EnumStub($a[$prefix . 'use']);
}
if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) {
self::addExtra($a, $c);
}
return $a;
}