🔧
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user