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

@@ -36,19 +36,12 @@ class YamlFileLoader extends FileLoader
private const AVAILABLE_KEYS = [
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', 'name_prefix', 'trailing_slash_on_root', 'locale', 'format', 'utf8', 'exclude', 'stateless',
];
private $yamlParser;
private YamlParser $yamlParser;
/**
* Loads a Yaml file.
*
* @param string $file A Yaml file path
* @param string|null $type The resource type
*
* @return RouteCollection
*
* @throws \InvalidArgumentException When a route can't be parsed because YAML is invalid
*/
public function load($file, string $type = null)
public function load(mixed $file, ?string $type = null): RouteCollection
{
$path = $this->locator->locate($file);
@@ -60,9 +53,7 @@ class YamlFileLoader extends FileLoader
throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path));
}
if (null === $this->yamlParser) {
$this->yamlParser = new YamlParser();
}
$this->yamlParser ??= new YamlParser();
try {
$parsedConfig = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
@@ -84,7 +75,7 @@ class YamlFileLoader extends FileLoader
}
foreach ($parsedConfig as $name => $config) {
if (0 === strpos($name, 'when@')) {
if (str_starts_with($name, 'when@')) {
if (!$this->env || 'when@'.$this->env !== $name) {
continue;
}
@@ -114,16 +105,15 @@ class YamlFileLoader extends FileLoader
return $collection;
}
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports(mixed $resource, ?string $type = null): bool
{
return \is_string($resource) && \in_array(pathinfo($resource, \PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type);
}
/**
* Parses a route and adds it to the RouteCollection.
*
* @return void
*/
protected function parseRoute(RouteCollection $collection, string $name, array $config, string $path)
{
@@ -182,6 +172,8 @@ class YamlFileLoader extends FileLoader
/**
* Parses an import and adds the routes in the resource to the RouteCollection.
*
* @return void
*/
protected function parseImport(RouteCollection $collection, array $config, string $path, string $file)
{
@@ -250,16 +242,12 @@ class YamlFileLoader extends FileLoader
}
/**
* Validates the route configuration.
*
* @param array $config A resource config
* @param string $name The config key
* @param string $path The loaded file path
* @return void
*
* @throws \InvalidArgumentException If one of the provided config keys is not supported,
* something is missing or the combination is nonsense
*/
protected function validate($config, string $name, string $path)
protected function validate(mixed $config, string $name, string $path)
{
if (!\is_array($config)) {
throw new \InvalidArgumentException(sprintf('The definition of "%s" in "%s" must be a YAML array.', $name, $path));