Update dependencies

This commit is contained in:
Chris Hunt
2024-02-16 21:36:54 +00:00
parent 22d7a59e59
commit d52ae0d3c3
9569 changed files with 460443 additions and 282416 deletions

View File

@@ -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,17 +142,36 @@ 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)
{
$routes = [];
foreach ((array) $name as $n) {
if (isset($this->routes[$n])) {
$routes[] = $n;
}
unset($this->routes[$n], $this->priorities[$n], $this->aliases[$n]);
}
if (!$routes) {
return;
}
foreach ($this->aliases as $k => $alias) {
if (\in_array($alias->getId(), $routes, true)) {
unset($this->aliases[$k]);
}
}
}
/**
* 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 +199,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 +219,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 +249,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 +265,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 +279,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 +295,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 +311,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 +327,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 +341,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 +356,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
*
* @return ResourceInterface[]
*/
public function getResources()
public function getResources(): array
{
return array_values($this->resources);
}
@@ -339,6 +364,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)
{
@@ -380,4 +407,9 @@ class RouteCollection implements \IteratorAggregate, \Countable
{
return $this->aliases[$name] ?? null;
}
public function getPriority(string $name): ?int
{
return $this->priorities[$name] ?? null;
}
}