🔧
This commit is contained in:
@@ -52,7 +52,7 @@ final class ControllerArgumentsEvent extends KernelEvent
|
||||
/**
|
||||
* @param array<class-string, list<object>>|null $attributes
|
||||
*/
|
||||
public function setController(callable $controller, array $attributes = null): void
|
||||
public function setController(callable $controller, ?array $attributes = null): void
|
||||
{
|
||||
$this->controllerEvent->setController($controller, $attributes);
|
||||
unset($this->namedArguments);
|
||||
@@ -102,7 +102,7 @@ final class ControllerArgumentsEvent extends KernelEvent
|
||||
*
|
||||
* @psalm-return (T is null ? array<class-string, list<object>> : list<object>)
|
||||
*/
|
||||
public function getAttributes(string $className = null): array
|
||||
public function getAttributes(?string $className = null): array
|
||||
{
|
||||
return $this->controllerEvent->getAttributes($className);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ final class ControllerEvent extends KernelEvent
|
||||
/**
|
||||
* @param array<class-string, list<object>>|null $attributes
|
||||
*/
|
||||
public function setController(callable $controller, array $attributes = null): void
|
||||
public function setController(callable $controller, ?array $attributes = null): void
|
||||
{
|
||||
if (null !== $attributes) {
|
||||
$this->attributes = $attributes;
|
||||
@@ -70,7 +70,7 @@ final class ControllerEvent extends KernelEvent
|
||||
if (\is_array($controller) && method_exists(...$controller)) {
|
||||
$this->controllerReflector = new \ReflectionMethod(...$controller);
|
||||
} elseif (\is_string($controller) && str_contains($controller, '::')) {
|
||||
$this->controllerReflector = new \ReflectionMethod($controller);
|
||||
$this->controllerReflector = new \ReflectionMethod(...explode('::', $controller, 2));
|
||||
} else {
|
||||
$this->controllerReflector = new \ReflectionFunction($controller(...));
|
||||
}
|
||||
@@ -87,7 +87,7 @@ final class ControllerEvent extends KernelEvent
|
||||
*
|
||||
* @psalm-return (T is null ? array<class-string, list<object>> : list<object>)
|
||||
*/
|
||||
public function getAttributes(string $className = null): array
|
||||
public function getAttributes(?string $className = null): array
|
||||
{
|
||||
if (isset($this->attributes)) {
|
||||
return null === $className ? $this->attributes : $this->attributes[$className] ?? [];
|
||||
@@ -98,7 +98,7 @@ final class ControllerEvent extends KernelEvent
|
||||
} elseif (\is_string($this->controller) && false !== $i = strpos($this->controller, '::')) {
|
||||
$class = new \ReflectionClass(substr($this->controller, 0, $i));
|
||||
} else {
|
||||
$class = str_contains($this->controllerReflector->name, '{closure}') ? null : (\PHP_VERSION_ID >= 80111 ? $this->controllerReflector->getClosureCalledClass() : $this->controllerReflector->getClosureScopeClass());
|
||||
$class = str_contains($this->controllerReflector->name, '{closure') ? null : (\PHP_VERSION_ID >= 80111 ? $this->controllerReflector->getClosureCalledClass() : $this->controllerReflector->getClosureScopeClass());
|
||||
}
|
||||
$this->attributes = [];
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Base class for events thrown in the HttpKernel component.
|
||||
* Base class for events dispatched in the HttpKernel component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,7 @@ final class ViewEvent extends RequestEvent
|
||||
public readonly ?ControllerArgumentsEvent $controllerArgumentsEvent;
|
||||
private mixed $controllerResult;
|
||||
|
||||
public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, mixed $controllerResult, ControllerArgumentsEvent $controllerArgumentsEvent = null)
|
||||
public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, mixed $controllerResult, ?ControllerArgumentsEvent $controllerArgumentsEvent = null)
|
||||
{
|
||||
parent::__construct($kernel, $request, $requestType);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user