update lock clucknut
All checks were successful
All checks were successful
This commit is contained in:
24
vendor/nette/utils/src/Utils/Reflection.php
vendored
24
vendor/nette/utils/src/Utils/Reflection.php
vendored
@@ -38,7 +38,7 @@ public static function isClassKeyword(string $name): bool
|
||||
public static function getParameterDefaultValue(\ReflectionParameter $param): mixed
|
||||
{
|
||||
if ($param->isDefaultValueConstant()) {
|
||||
$const = $orig = $param->getDefaultValueConstantName();
|
||||
$const = $orig = $param->getDefaultValueConstantName() ?? throw new Nette\ShouldNotHappenException;
|
||||
$pair = explode('::', $const);
|
||||
if (isset($pair[1])) {
|
||||
$pair[0] = Type::resolve($pair[0], $param);
|
||||
@@ -68,6 +68,7 @@ public static function getParameterDefaultValue(\ReflectionParameter $param): mi
|
||||
|
||||
/**
|
||||
* Returns a reflection of a class or trait that contains a declaration of given property. Property can also be declared in the trait.
|
||||
* @return \ReflectionClass<object>
|
||||
*/
|
||||
public static function getPropertyDeclaringClass(\ReflectionProperty $prop): \ReflectionClass
|
||||
{
|
||||
@@ -151,6 +152,7 @@ public static function toString(\Reflector $ref): string
|
||||
/**
|
||||
* Expands the name of the class to full name in the given context of given class.
|
||||
* Thus, it returns how the PHP parser would understand $name if it were written in the body of the class $context.
|
||||
* @param \ReflectionClass<object> $context
|
||||
* @throws Nette\InvalidArgumentException
|
||||
*/
|
||||
public static function expandClassName(string $name, \ReflectionClass $context): string
|
||||
@@ -189,7 +191,10 @@ public static function expandClassName(string $name, \ReflectionClass $context):
|
||||
}
|
||||
|
||||
|
||||
/** @return array<string, class-string> of [alias => class] */
|
||||
/**
|
||||
* @param \ReflectionClass<object> $class
|
||||
* @return array<string, class-string> of [alias => class]
|
||||
*/
|
||||
public static function getUseStatements(\ReflectionClass $class): array
|
||||
{
|
||||
if ($class->isAnonymous()) {
|
||||
@@ -201,7 +206,7 @@ public static function getUseStatements(\ReflectionClass $class): array
|
||||
if ($class->isInternal()) {
|
||||
$cache[$name] = [];
|
||||
} else {
|
||||
$code = file_get_contents($class->getFileName());
|
||||
$code = (string) file_get_contents((string) $class->getFileName());
|
||||
$cache = self::parseUseStatements($code, $name) + $cache;
|
||||
}
|
||||
}
|
||||
@@ -212,6 +217,7 @@ public static function getUseStatements(\ReflectionClass $class): array
|
||||
|
||||
/**
|
||||
* Parses PHP code to [class => [alias => class, ...]]
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
private static function parseUseStatements(string $code, ?string $forClass = null): array
|
||||
{
|
||||
@@ -256,8 +262,8 @@ private static function parseUseStatements(string $code, ?string $forClass = nul
|
||||
$name = ltrim($name, '\\');
|
||||
if (self::fetch($tokens, '{')) {
|
||||
while ($suffix = self::fetch($tokens, $nameTokens)) {
|
||||
if (self::fetch($tokens, T_AS)) {
|
||||
$uses[self::fetch($tokens, T_STRING)] = $name . $suffix;
|
||||
if (self::fetch($tokens, T_AS) && ($alias = self::fetch($tokens, T_STRING))) {
|
||||
$uses[$alias] = $name . $suffix;
|
||||
} else {
|
||||
$tmp = explode('\\', $suffix);
|
||||
$uses[end($tmp)] = $name . $suffix;
|
||||
@@ -267,8 +273,8 @@ private static function parseUseStatements(string $code, ?string $forClass = nul
|
||||
break;
|
||||
}
|
||||
}
|
||||
} elseif (self::fetch($tokens, T_AS)) {
|
||||
$uses[self::fetch($tokens, T_STRING)] = $name;
|
||||
} elseif (self::fetch($tokens, T_AS) && ($alias = self::fetch($tokens, T_STRING))) {
|
||||
$uses[$alias] = $name;
|
||||
|
||||
} else {
|
||||
$tmp = explode('\\', $name);
|
||||
@@ -301,6 +307,10 @@ private static function parseUseStatements(string $code, ?string $forClass = nul
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \PhpToken[] $tokens
|
||||
* @param string|int|int[] $take
|
||||
*/
|
||||
private static function fetch(array &$tokens, string|int|array $take): ?string
|
||||
{
|
||||
$res = null;
|
||||
|
||||
Reference in New Issue
Block a user