N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)

* Update Symfony lib to version ~6.4.0
* Update code missing return type
* Add an iTop general configuration entry to store application secret (Symfony mandatory parameter)
* Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
bdalsass
2023-12-05 13:56:56 +01:00
committed by GitHub
parent 863ab4560c
commit 27ce51ab07
1392 changed files with 44869 additions and 27799 deletions

View File

@@ -28,25 +28,34 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
*/
final class ControllerArgumentsEvent extends KernelEvent
{
private $controller;
private $arguments;
private ControllerEvent $controllerEvent;
private array $arguments;
private array $namedArguments;
public function __construct(HttpKernelInterface $kernel, callable $controller, array $arguments, Request $request, ?int $requestType)
public function __construct(HttpKernelInterface $kernel, callable|ControllerEvent $controller, array $arguments, Request $request, ?int $requestType)
{
parent::__construct($kernel, $request, $requestType);
$this->controller = $controller;
if (!$controller instanceof ControllerEvent) {
$controller = new ControllerEvent($kernel, $controller, $request, $requestType);
}
$this->controllerEvent = $controller;
$this->arguments = $arguments;
}
public function getController(): callable
{
return $this->controller;
return $this->controllerEvent->getController();
}
public function setController(callable $controller)
/**
* @param array<class-string, list<object>>|null $attributes
*/
public function setController(callable $controller, array $attributes = null): void
{
$this->controller = $controller;
$this->controllerEvent->setController($controller, $attributes);
unset($this->namedArguments);
}
public function getArguments(): array
@@ -54,8 +63,47 @@ final class ControllerArgumentsEvent extends KernelEvent
return $this->arguments;
}
public function setArguments(array $arguments)
public function setArguments(array $arguments): void
{
$this->arguments = $arguments;
unset($this->namedArguments);
}
public function getNamedArguments(): array
{
if (isset($this->namedArguments)) {
return $this->namedArguments;
}
$namedArguments = [];
$arguments = $this->arguments;
foreach ($this->controllerEvent->getControllerReflector()->getParameters() as $i => $param) {
if ($param->isVariadic()) {
$namedArguments[$param->name] = \array_slice($arguments, $i);
break;
}
if (\array_key_exists($i, $arguments)) {
$namedArguments[$param->name] = $arguments[$i];
} elseif ($param->isDefaultvalueAvailable()) {
$namedArguments[$param->name] = $param->getDefaultValue();
}
}
return $this->namedArguments = $namedArguments;
}
/**
* @template T of class-string|null
*
* @param T $className
*
* @return array<class-string, list<object>>|list<object>
*
* @psalm-return (T is null ? array<class-string, list<object>> : list<object>)
*/
public function getAttributes(string $className = null): array
{
return $this->controllerEvent->getAttributes($className);
}
}