Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -85,7 +85,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
*/
protected $defaultRouteIndex = 0;
public function __construct(Reader $reader = null, string $env = null)
public function __construct(?Reader $reader = null, ?string $env = null)
{
$this->reader = $reader;
$this->env = $env;
@@ -108,7 +108,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
*
* @throws \InvalidArgumentException When route can't be parsed
*/
public function load($class, string $type = null)
public function load($class, ?string $type = null)
{
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
@@ -239,7 +239,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
return \is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type);
}

View File

@@ -32,7 +32,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
*
* @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed
*/
public function load($path, string $type = null)
public function load($path, ?string $type = null)
{
if (!is_dir($dir = $this->locator->locate($path))) {
return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection();
@@ -74,7 +74,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
if ('annotation' === $type) {
return true;

View File

@@ -47,7 +47,7 @@ class AnnotationFileLoader extends FileLoader
*
* @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed
*/
public function load($file, string $type = null)
public function load($file, ?string $type = null)
{
$path = $this->locator->locate($file);
@@ -70,7 +70,7 @@ class AnnotationFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'annotation' === $type);
}

View File

@@ -31,7 +31,7 @@ class ClosureLoader extends Loader
*
* @return RouteCollection
*/
public function load($closure, string $type = null)
public function load($closure, ?string $type = null)
{
return $closure($this->env);
}
@@ -39,7 +39,7 @@ class ClosureLoader extends Loader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
return $resource instanceof \Closure && (!$type || 'closure' === $type);
}

View File

@@ -28,7 +28,7 @@ class CollectionConfigurator
private $parentPrefixes;
private $host;
public function __construct(RouteCollection $parent, string $name, self $parentConfigurator = null, array $parentPrefixes = null)
public function __construct(RouteCollection $parent, string $name, ?self $parentConfigurator = null, ?array $parentPrefixes = null)
{
$this->parent = $parent;
$this->name = $name;

View File

@@ -24,7 +24,7 @@ class RouteConfigurator
protected $parentConfigurator;
public function __construct(RouteCollection $collection, RouteCollection $route, string $name = '', CollectionConfigurator $parentConfigurator = null, array $prefixes = null)
public function __construct(RouteCollection $collection, RouteCollection $route, string $name = '', ?CollectionConfigurator $parentConfigurator = null, ?array $prefixes = null)
{
$this->collection = $collection;
$this->route = $route;

View File

@@ -26,7 +26,7 @@ class RoutingConfigurator
private $file;
private $env;
public function __construct(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file, string $env = null)
public function __construct(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file, ?string $env = null)
{
$this->collection = $collection;
$this->loader = $loader;
@@ -38,7 +38,7 @@ class RoutingConfigurator
/**
* @param string|string[]|null $exclude Glob patterns to exclude from the import
*/
final public function import($resource, string $type = null, bool $ignoreErrors = false, $exclude = null): ImportConfigurator
final public function import($resource, ?string $type = null, bool $ignoreErrors = false, $exclude = null): ImportConfigurator
{
$this->loader->setCurrentDir(\dirname($this->path));

View File

@@ -27,7 +27,7 @@ trait LocalizedRouteTrait
*
* @param string|array $path the path, or the localized paths of the route
*/
final protected function createLocalizedRoute(RouteCollection $collection, string $name, $path, string $namePrefix = '', array $prefixes = null): RouteCollection
final protected function createLocalizedRoute(RouteCollection $collection, string $name, $path, string $namePrefix = '', ?array $prefixes = null): RouteCollection
{
$paths = [];

View File

@@ -29,6 +29,7 @@ trait PrefixTrait
}
foreach ($routes->all() as $name => $route) {
if (null === $locale = $route->getDefault('_locale')) {
$priority = $routes->getPriority($name) ?? 0;
$routes->remove($name);
foreach ($prefix as $locale => $localePrefix) {
$localizedRoute = clone $route;
@@ -36,13 +37,13 @@ trait PrefixTrait
$localizedRoute->setRequirement('_locale', preg_quote($locale));
$localizedRoute->setDefault('_canonical_route', $name);
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
$routes->add($name.'.'.$locale, $localizedRoute);
$routes->add($name.'.'.$locale, $localizedRoute, $priority);
}
} elseif (!isset($prefix[$locale])) {
throw new \InvalidArgumentException(sprintf('Route "%s" with locale "%s" is missing a corresponding prefix in its parent collection.', $name, $locale));
} else {
$route->setPath($prefix[$locale].(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
$routes->add($name, $route);
$routes->add($name, $route, $routes->getPriority($name) ?? 0);
}
}

View File

@@ -22,7 +22,7 @@ class ContainerLoader extends ObjectLoader
{
private $container;
public function __construct(ContainerInterface $container, string $env = null)
public function __construct(ContainerInterface $container, ?string $env = null)
{
$this->container = $container;
parent::__construct($env);
@@ -31,7 +31,7 @@ class ContainerLoader extends ObjectLoader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
return 'service' === $type && \is_string($resource);
}

View File

@@ -20,7 +20,7 @@ class DirectoryLoader extends FileLoader
/**
* {@inheritdoc}
*/
public function load($file, string $type = null)
public function load($file, ?string $type = null)
{
$path = $this->locator->locate($file);
@@ -49,7 +49,7 @@ class DirectoryLoader extends FileLoader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
// only when type is forced to directory, not to conflict with AnnotationLoader

View File

@@ -24,7 +24,7 @@ class GlobFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
public function load($resource, string $type = null)
public function load($resource, ?string $type = null)
{
$collection = new RouteCollection();
@@ -40,7 +40,7 @@ class GlobFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
return 'glob' === $type;
}

View File

@@ -40,7 +40,7 @@ abstract class ObjectLoader extends Loader
*
* @return RouteCollection
*/
public function load($resource, string $type = null)
public function load($resource, ?string $type = null)
{
if (!preg_match('/^[^\:]+(?:::(?:[^\:]+))?$/', $resource)) {
throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the %s route loader: use the format "object_id::method" or "object_id" if your object class has an "__invoke" method.', $resource, \is_string($type) ? '"'.$type.'"' : 'object'));

View File

@@ -35,7 +35,7 @@ class PhpFileLoader extends FileLoader
*
* @return RouteCollection
*/
public function load($file, string $type = null)
public function load($file, ?string $type = null)
{
$path = $this->locator->locate($file);
$this->setCurrentDir(\dirname($path));
@@ -62,7 +62,7 @@ class PhpFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'php' === $type);
}

View File

@@ -45,7 +45,7 @@ class XmlFileLoader extends FileLoader
* @throws \InvalidArgumentException when the file cannot be loaded or when the XML cannot be
* parsed because it does not validate against the scheme
*/
public function load($file, string $type = null)
public function load($file, ?string $type = null)
{
$path = $this->locator->locate($file);
@@ -102,7 +102,7 @@ class XmlFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
return \is_string($resource) && 'xml' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'xml' === $type);
}
@@ -195,7 +195,7 @@ class XmlFileLoader extends FileLoader
$this->setCurrentDir(\dirname($path));
/** @var RouteCollection[] $imported */
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file, $exclude) ?: [];
$imported = $this->import($resource, '' !== $type ? $type : null, false, $file, $exclude) ?: [];
if (!\is_array($imported)) {
$imported = [$imported];

View File

@@ -48,7 +48,7 @@ class YamlFileLoader extends FileLoader
*
* @throws \InvalidArgumentException When a route can't be parsed because YAML is invalid
*/
public function load($file, string $type = null)
public function load($file, ?string $type = null)
{
$path = $this->locator->locate($file);
@@ -117,7 +117,7 @@ class YamlFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null)
{
return \is_string($resource) && \in_array(pathinfo($resource, \PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type);
}