upgraded dependencies
This commit is contained in:
@@ -18,7 +18,7 @@ use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
* @final
|
||||
*/
|
||||
class ReflectionCaster
|
||||
{
|
||||
@@ -35,7 +35,7 @@ class ReflectionCaster
|
||||
'isVariadic' => 'isVariadic',
|
||||
];
|
||||
|
||||
public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
public static function castClosure(\Closure $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$c = new \ReflectionFunction($c);
|
||||
@@ -78,7 +78,7 @@ class ReflectionCaster
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castGenerator(\Generator $c, array $a, Stub $stub, $isNested)
|
||||
public static function castGenerator(\Generator $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
// Cannot create ReflectionGenerator based on a terminated Generator
|
||||
try {
|
||||
@@ -92,7 +92,7 @@ class ReflectionCaster
|
||||
return self::castReflectionGenerator($reflectionGenerator, $a, $stub, $isNested);
|
||||
}
|
||||
|
||||
public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNested)
|
||||
public static function castType(\ReflectionType $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
@@ -114,7 +114,17 @@ class ReflectionCaster
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, $isNested)
|
||||
public static function castAttribute(\ReflectionAttribute $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
self::addMap($a, $c, [
|
||||
'name' => 'getName',
|
||||
'arguments' => 'getArguments',
|
||||
]);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
@@ -149,7 +159,7 @@ class ReflectionCaster
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castClass(\ReflectionClass $c, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
public static function castClass(\ReflectionClass $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
@@ -160,7 +170,7 @@ class ReflectionCaster
|
||||
self::addMap($a, $c, [
|
||||
'extends' => 'getParentClass',
|
||||
'implements' => 'getInterfaceNames',
|
||||
'constants' => 'getConstants',
|
||||
'constants' => 'getReflectionConstants',
|
||||
]);
|
||||
|
||||
foreach ($c->getProperties() as $n) {
|
||||
@@ -171,6 +181,8 @@ class ReflectionCaster
|
||||
$a[$prefix.'methods'][$n->name] = $n;
|
||||
}
|
||||
|
||||
self::addAttributes($a, $c, $prefix);
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) {
|
||||
self::addExtra($a, $c);
|
||||
}
|
||||
@@ -178,14 +190,14 @@ class ReflectionCaster
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, $isNested, $filter = 0)
|
||||
public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
self::addMap($a, $c, [
|
||||
'returnsReference' => 'returnsReference',
|
||||
'returnType' => 'getReturnType',
|
||||
'class' => 'getClosureScopeClass',
|
||||
'class' => \PHP_VERSION_ID >= 80111 ? 'getClosureCalledClass' : 'getClosureScopeClass',
|
||||
'this' => 'getClosureThis',
|
||||
]);
|
||||
|
||||
@@ -215,6 +227,8 @@ class ReflectionCaster
|
||||
$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)) {
|
||||
@@ -234,14 +248,24 @@ class ReflectionCaster
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castMethod(\ReflectionMethod $c, array $a, Stub $stub, $isNested)
|
||||
public static function castClassConstant(\ReflectionClassConstant $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers()));
|
||||
$a[Caster::PREFIX_VIRTUAL.'value'] = $c->getValue();
|
||||
|
||||
self::addAttributes($a, $c);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castMethod(\ReflectionMethod $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers()));
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castParameter(\ReflectionParameter $c, array $a, Stub $stub, $isNested)
|
||||
public static function castParameter(\ReflectionParameter $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
@@ -252,6 +276,8 @@ class ReflectionCaster
|
||||
'allowsNull' => 'allowsNull',
|
||||
]);
|
||||
|
||||
self::addAttributes($a, $c, $prefix);
|
||||
|
||||
if ($v = $c->getType()) {
|
||||
$a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v;
|
||||
}
|
||||
@@ -279,22 +305,24 @@ class ReflectionCaster
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub, $isNested)
|
||||
public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers()));
|
||||
|
||||
self::addAttributes($a, $c);
|
||||
self::addExtra($a, $c);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castReference(\ReflectionReference $c, array $a, Stub $stub, $isNested)
|
||||
public static function castReference(\ReflectionReference $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'id'] = $c->getId();
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, $isNested)
|
||||
public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
self::addMap($a, $c, [
|
||||
'version' => 'getVersion',
|
||||
@@ -310,7 +338,7 @@ class ReflectionCaster
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, $isNested)
|
||||
public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
self::addMap($a, $c, [
|
||||
'version' => 'getVersion',
|
||||
@@ -390,7 +418,7 @@ class ReflectionCaster
|
||||
}
|
||||
}
|
||||
|
||||
private static function addMap(array &$a, $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL)
|
||||
private static function addMap(array &$a, object $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL)
|
||||
{
|
||||
foreach ($map as $k => $m) {
|
||||
if (\PHP_VERSION_ID >= 80000 && 'isDisabled' === $k) {
|
||||
@@ -402,4 +430,13 @@ class ReflectionCaster
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function addAttributes(array &$a, \Reflector $c, string $prefix = Caster::PREFIX_VIRTUAL): void
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 80000) {
|
||||
foreach ($c->getAttributes() as $n) {
|
||||
$a[$prefix.'attributes'][] = $n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user