mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-29 13:38:44 +02:00
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:
@@ -32,22 +32,22 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* @var array<string, Route>
|
||||
*/
|
||||
private $routes = [];
|
||||
private array $routes = [];
|
||||
|
||||
/**
|
||||
* @var array<string, Alias>
|
||||
*/
|
||||
private $aliases = [];
|
||||
private array $aliases = [];
|
||||
|
||||
/**
|
||||
* @var array<string, ResourceInterface>
|
||||
*/
|
||||
private $resources = [];
|
||||
private array $resources = [];
|
||||
|
||||
/**
|
||||
* @var array<string, int>
|
||||
*/
|
||||
private $priorities = [];
|
||||
private array $priorities = [];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -69,37 +69,29 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return \ArrayIterator<string, Route>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
public function getIterator(): \ArrayIterator
|
||||
{
|
||||
return new \ArrayIterator($this->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of Routes in this collection.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return \count($this->routes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $priority
|
||||
* @return void
|
||||
*/
|
||||
public function add(string $name, Route $route/* , int $priority = 0 */)
|
||||
public function add(string $name, Route $route, int $priority = 0)
|
||||
{
|
||||
if (\func_num_args() < 3 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) {
|
||||
trigger_deprecation('symfony/routing', '5.1', 'The "%s()" method will have a new "int $priority = 0" argument in version 6.0, not defining it is deprecated.', __METHOD__);
|
||||
}
|
||||
|
||||
unset($this->routes[$name], $this->priorities[$name], $this->aliases[$name]);
|
||||
|
||||
$this->routes[$name] = $route;
|
||||
|
||||
if ($priority = 3 <= \func_num_args() ? func_get_arg(2) : 0) {
|
||||
if ($priority) {
|
||||
$this->priorities[$name] = $priority;
|
||||
}
|
||||
}
|
||||
@@ -109,14 +101,12 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return array<string, Route>
|
||||
*/
|
||||
public function all()
|
||||
public function all(): array
|
||||
{
|
||||
if ($this->priorities) {
|
||||
$priorities = $this->priorities;
|
||||
$keysOrder = array_flip(array_keys($this->routes));
|
||||
uksort($this->routes, static function ($n1, $n2) use ($priorities, $keysOrder) {
|
||||
return (($priorities[$n2] ?? 0) <=> ($priorities[$n1] ?? 0)) ?: ($keysOrder[$n1] <=> $keysOrder[$n2]);
|
||||
});
|
||||
uksort($this->routes, static fn ($n1, $n2) => (($priorities[$n2] ?? 0) <=> ($priorities[$n1] ?? 0)) ?: ($keysOrder[$n1] <=> $keysOrder[$n2]));
|
||||
}
|
||||
|
||||
return $this->routes;
|
||||
@@ -124,10 +114,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Gets a route by name.
|
||||
*
|
||||
* @return Route|null
|
||||
*/
|
||||
public function get(string $name)
|
||||
public function get(string $name): ?Route
|
||||
{
|
||||
$visited = [];
|
||||
while (null !== $alias = $this->aliases[$name] ?? null) {
|
||||
@@ -154,8 +142,10 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* Removes a route or an array of routes by name from the collection.
|
||||
*
|
||||
* @param string|string[] $name The route name or an array of route names
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function remove($name)
|
||||
public function remove(string|array $name)
|
||||
{
|
||||
foreach ((array) $name as $n) {
|
||||
unset($this->routes[$n], $this->priorities[$n], $this->aliases[$n]);
|
||||
@@ -165,6 +155,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Adds a route collection at the end of the current set by appending all
|
||||
* routes of the added collection.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addCollection(self $collection)
|
||||
{
|
||||
@@ -192,6 +184,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Adds a prefix to the path of all child routes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPrefix(string $prefix, array $defaults = [], array $requirements = [])
|
||||
{
|
||||
@@ -210,6 +204,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Adds a prefix to the name of all the routes within in the collection.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addNamePrefix(string $prefix)
|
||||
{
|
||||
@@ -238,6 +234,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Sets the host pattern on all routes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setHost(?string $pattern, array $defaults = [], array $requirements = [])
|
||||
{
|
||||
@@ -252,6 +250,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* Sets a condition on all routes.
|
||||
*
|
||||
* Existing conditions will be overridden.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCondition(?string $condition)
|
||||
{
|
||||
@@ -264,6 +264,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* Adds defaults to all routes.
|
||||
*
|
||||
* An existing default value under the same name in a route will be overridden.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addDefaults(array $defaults)
|
||||
{
|
||||
@@ -278,6 +280,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* Adds requirements to all routes.
|
||||
*
|
||||
* An existing requirement under the same name in a route will be overridden.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addRequirements(array $requirements)
|
||||
{
|
||||
@@ -292,6 +296,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* Adds options to all routes.
|
||||
*
|
||||
* An existing option value under the same name in a route will be overridden.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addOptions(array $options)
|
||||
{
|
||||
@@ -306,8 +312,10 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* Sets the schemes (e.g. 'https') all child routes are restricted to.
|
||||
*
|
||||
* @param string|string[] $schemes The scheme or an array of schemes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSchemes($schemes)
|
||||
public function setSchemes(string|array $schemes)
|
||||
{
|
||||
foreach ($this->routes as $route) {
|
||||
$route->setSchemes($schemes);
|
||||
@@ -318,8 +326,10 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* Sets the HTTP methods (e.g. 'POST') all child routes are restricted to.
|
||||
*
|
||||
* @param string|string[] $methods The method or an array of methods
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMethods($methods)
|
||||
public function setMethods(string|array $methods)
|
||||
{
|
||||
foreach ($this->routes as $route) {
|
||||
$route->setMethods($methods);
|
||||
@@ -331,7 +341,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return ResourceInterface[]
|
||||
*/
|
||||
public function getResources()
|
||||
public function getResources(): array
|
||||
{
|
||||
return array_values($this->resources);
|
||||
}
|
||||
@@ -339,6 +349,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Adds a resource for this collection. If the resource already exists
|
||||
* it is not added.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addResource(ResourceInterface $resource)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user