package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -32,7 +32,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
/**
* @var array<string, Route>
*/
private $routes = [];
private array $routes = [];
/**
* @var array<string, Alias>
@@ -42,12 +42,12 @@ class RouteCollection implements \IteratorAggregate, \Countable
/**
* @var array<string, ResourceInterface>
*/
private $resources = [];
private array $resources = [];
/**
* @var array<string, int>
*/
private $priorities = [];
private array $priorities = [];
public function __clone()
{
@@ -69,37 +69,26 @@ 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
*/
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,7 +98,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
*
* @return array<string, Route>
*/
public function all()
public function all(): array
{
if ($this->priorities) {
$priorities = $this->priorities;
@@ -124,10 +113,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) {
@@ -155,7 +142,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
*
* @param string|string[] $name The route name or an array of route names
*/
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]);
@@ -307,7 +294,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
*
* @param string|string[] $schemes The scheme or an array of schemes
*/
public function setSchemes($schemes)
public function setSchemes(string|array $schemes)
{
foreach ($this->routes as $route) {
$route->setSchemes($schemes);
@@ -319,7 +306,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
*
* @param string|string[] $methods The method or an array of methods
*/
public function setMethods($methods)
public function setMethods(string|array $methods)
{
foreach ($this->routes as $route) {
$route->setMethods($methods);
@@ -331,7 +318,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
*
* @return ResourceInterface[]
*/
public function getResources()
public function getResources(): array
{
return array_values($this->resources);
}