mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-17 04:13:46 +09:00
Updates to vendors etc
This commit is contained in:
@@ -25,13 +25,12 @@ use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
*/
|
||||
class ControllerResolver implements ControllerResolverInterface
|
||||
{
|
||||
private ?LoggerInterface $logger;
|
||||
private array $allowedControllerTypes = [];
|
||||
private array $allowedControllerAttributes = [AsController::class => AsController::class];
|
||||
|
||||
public function __construct(?LoggerInterface $logger = null)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
public function __construct(
|
||||
private ?LoggerInterface $logger = null,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +73,7 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
}
|
||||
|
||||
if (!\is_callable($controller)) {
|
||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller));
|
||||
throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller));
|
||||
}
|
||||
|
||||
return $this->checkController($request, $controller);
|
||||
@@ -82,7 +81,7 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
|
||||
if (\is_object($controller)) {
|
||||
if (!\is_callable($controller)) {
|
||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller));
|
||||
throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller));
|
||||
}
|
||||
|
||||
return $this->checkController($request, $controller);
|
||||
@@ -95,11 +94,11 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
try {
|
||||
$callable = $this->createController($controller);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);
|
||||
throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
if (!\is_callable($callable)) {
|
||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($callable));
|
||||
throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($callable));
|
||||
}
|
||||
|
||||
return $this->checkController($request, $callable);
|
||||
@@ -159,19 +158,19 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
if (str_contains($callable, '::')) {
|
||||
$callable = explode('::', $callable, 2);
|
||||
} else {
|
||||
return sprintf('Function "%s" does not exist.', $callable);
|
||||
return \sprintf('Function "%s" does not exist.', $callable);
|
||||
}
|
||||
}
|
||||
|
||||
if (\is_object($callable)) {
|
||||
$availableMethods = $this->getClassMethodsWithoutMagicMethods($callable);
|
||||
$alternativeMsg = $availableMethods ? sprintf(' or use one of the available methods: "%s"', implode('", "', $availableMethods)) : '';
|
||||
$alternativeMsg = $availableMethods ? \sprintf(' or use one of the available methods: "%s"', implode('", "', $availableMethods)) : '';
|
||||
|
||||
return sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', get_debug_type($callable), $alternativeMsg);
|
||||
return \sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', get_debug_type($callable), $alternativeMsg);
|
||||
}
|
||||
|
||||
if (!\is_array($callable)) {
|
||||
return sprintf('Invalid type for controller given, expected string, array or object, got "%s".', get_debug_type($callable));
|
||||
return \sprintf('Invalid type for controller given, expected string, array or object, got "%s".', get_debug_type($callable));
|
||||
}
|
||||
|
||||
if (!isset($callable[0]) || !isset($callable[1]) || 2 !== \count($callable)) {
|
||||
@@ -181,13 +180,13 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
[$controller, $method] = $callable;
|
||||
|
||||
if (\is_string($controller) && !class_exists($controller)) {
|
||||
return sprintf('Class "%s" does not exist.', $controller);
|
||||
return \sprintf('Class "%s" does not exist.', $controller);
|
||||
}
|
||||
|
||||
$className = \is_object($controller) ? get_debug_type($controller) : $controller;
|
||||
|
||||
if (method_exists($controller, $method)) {
|
||||
return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className);
|
||||
return \sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className);
|
||||
}
|
||||
|
||||
$collection = $this->getClassMethodsWithoutMagicMethods($controller);
|
||||
@@ -204,12 +203,12 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
|
||||
asort($alternatives);
|
||||
|
||||
$message = sprintf('Expected method "%s" on class "%s"', $method, $className);
|
||||
$message = \sprintf('Expected method "%s" on class "%s"', $method, $className);
|
||||
|
||||
if (\count($alternatives) > 0) {
|
||||
$message .= sprintf(', did you mean "%s"?', implode('", "', $alternatives));
|
||||
$message .= \sprintf(', did you mean "%s"?', implode('", "', $alternatives));
|
||||
} else {
|
||||
$message .= sprintf('. Available methods: "%s".', implode('", "', $collection));
|
||||
$message .= \sprintf('. Available methods: "%s".', implode('", "', $collection));
|
||||
}
|
||||
|
||||
return $message;
|
||||
@@ -240,9 +239,9 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
$r = new \ReflectionFunction($controller);
|
||||
$name = $r->name;
|
||||
|
||||
if (str_contains($name, '{closure}')) {
|
||||
if ($r->isAnonymous()) {
|
||||
$name = $class = \Closure::class;
|
||||
} elseif ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
|
||||
} elseif ($class = $r->getClosureCalledClass()) {
|
||||
$class = $class->name;
|
||||
$name = $class.'::'.$name;
|
||||
}
|
||||
@@ -265,15 +264,9 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
}
|
||||
|
||||
if (str_contains($name, '@anonymous')) {
|
||||
$name = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $name);
|
||||
$name = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $name);
|
||||
}
|
||||
|
||||
if (-1 === $request->attributes->get('_check_controller_is_allowed')) {
|
||||
trigger_deprecation('symfony/http-kernel', '6.4', 'Callable "%s()" is not allowed as a controller. Did you miss tagging it with "#[AsController]" or registering its type with "%s::allowControllers()"?', $name, self::class);
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
throw new BadRequestException(sprintf('Callable "%s()" is not allowed as a controller. Did you miss tagging it with "#[AsController]" or registering its type with "%s::allowControllers()"?', $name, self::class));
|
||||
throw new BadRequestException(\sprintf('Callable "%s()" is not allowed as a controller. Did you miss tagging it with "#[AsController]" or registering its type with "%s::allowControllers()"?', $name, self::class));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user