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

@@ -20,10 +20,10 @@ use Symfony\Component\Routing\RequestContext;
*/
class CompiledUrlGenerator extends UrlGenerator
{
private $compiledRoutes = [];
private $defaultLocale;
private array $compiledRoutes = [];
private ?string $defaultLocale;
public function __construct(array $compiledRoutes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
public function __construct(array $compiledRoutes, RequestContext $context, ?LoggerInterface $logger = null, ?string $defaultLocale = null)
{
$this->compiledRoutes = $compiledRoutes;
$this->context = $context;
@@ -31,7 +31,7 @@ class CompiledUrlGenerator extends UrlGenerator
$this->defaultLocale = $defaultLocale;
}
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH)
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
{
$locale = $parameters['_locale']
?? $this->context->getParameter('_locale')

View File

@@ -40,14 +40,14 @@ interface ConfigurableRequirementsInterface
/**
* Enables or disables the exception on incorrect parameters.
* Passing null will deactivate the requirements check completely.
*
* @return void
*/
public function setStrictRequirements(?bool $enabled);
/**
* Returns whether to throw an exception on incorrect parameters.
* Null means the requirements check is deactivated completely.
*
* @return bool|null
*/
public function isStrictRequirements();
public function isStrictRequirements(): ?bool;
}

View File

@@ -88,10 +88,7 @@ class CompiledUrlGeneratorDumper extends GeneratorDumper
return $compiledAliases;
}
/**
* {@inheritdoc}
*/
public function dump(array $options = [])
public function dump(array $options = []): string
{
return <<<EOF
<?php

View File

@@ -20,17 +20,14 @@ use Symfony\Component\Routing\RouteCollection;
*/
abstract class GeneratorDumper implements GeneratorDumperInterface
{
private $routes;
private RouteCollection $routes;
public function __construct(RouteCollection $routes)
{
$this->routes = $routes;
}
/**
* {@inheritdoc}
*/
public function getRoutes()
public function getRoutes(): RouteCollection
{
return $this->routes;
}

View File

@@ -23,15 +23,11 @@ interface GeneratorDumperInterface
/**
* Dumps a set of routes to a string representation of executable code
* that can then be used to generate a URL of such a route.
*
* @return string
*/
public function dump(array $options = []);
public function dump(array $options = []): string;
/**
* Gets the routes to dump.
*
* @return RouteCollection
*/
public function getRoutes();
public function getRoutes(): RouteCollection;
}

View File

@@ -30,6 +30,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
private const QUERY_FRAGMENT_DECODED = [
// RFC 3986 explicitly allows those in the query/fragment to reference other URIs unencoded
'%2F' => '/',
'%252F' => '%2F',
'%3F' => '?',
// reserved chars that have no special meaning for HTTP URIs in a query or fragment
// this excludes esp. "&", "=" and also "+" because PHP would treat it as a space (form-encoded)
@@ -51,7 +52,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
protected $logger;
private $defaultLocale;
private ?string $defaultLocale;
/**
* This array defines the characters (besides alphanumeric ones) that will not be percent-encoded in the path segment of the generated URL.
@@ -82,7 +83,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
'%7C' => '|',
];
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
public function __construct(RouteCollection $routes, RequestContext $context, ?LoggerInterface $logger = null, ?string $defaultLocale = null)
{
$this->routes = $routes;
$this->context = $context;
@@ -91,46 +92,35 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
}
/**
* {@inheritdoc}
* @return void
*/
public function setContext(RequestContext $context)
{
$this->context = $context;
}
/**
* {@inheritdoc}
*/
public function getContext()
public function getContext(): RequestContext
{
return $this->context;
}
/**
* {@inheritdoc}
* @return void
*/
public function setStrictRequirements(?bool $enabled)
{
$this->strictRequirements = $enabled;
}
/**
* {@inheritdoc}
*/
public function isStrictRequirements()
public function isStrictRequirements(): ?bool
{
return $this->strictRequirements;
}
/**
* {@inheritdoc}
*/
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH)
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
{
$route = null;
$locale = $parameters['_locale']
?? $this->context->getParameter('_locale')
?: $this->defaultLocale;
$locale = $parameters['_locale'] ?? $this->context->getParameter('_locale') ?: $this->defaultLocale;
if (null !== $locale) {
do {
@@ -140,7 +130,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
} while (false !== $locale = strstr($locale, '_', true));
}
if (null === $route = $route ?? $this->routes->get($name)) {
if (null === $route ??= $this->routes->get($name)) {
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
}
@@ -165,17 +155,15 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
* it does not match the requirement
*
* @return string
*/
protected function doGenerate(array $variables, array $defaults, array $requirements, array $tokens, array $parameters, string $name, int $referenceType, array $hostTokens, array $requiredSchemes = [])
protected function doGenerate(array $variables, array $defaults, array $requirements, array $tokens, array $parameters, string $name, int $referenceType, array $hostTokens, array $requiredSchemes = []): string
{
$variables = array_flip($variables);
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
// all params must be given
if ($diff = array_diff_key($variables, $mergedParams)) {
throw new MissingMandatoryParametersException(sprintf('Some mandatory parameters are missing ("%s") to generate a URL for route "%s".', implode('", "', array_keys($diff)), $name));
throw new MissingMandatoryParametersException($name, array_keys($diff));
}
$url = '';
@@ -194,9 +182,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
throw new InvalidParameterException(strtr($message, ['{parameter}' => $varName, '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$varName]]));
}
if ($this->logger) {
$this->logger->error($message, ['parameter' => $varName, 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$varName]]);
}
$this->logger?->error($message, ['parameter' => $varName, 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$varName]]);
return '';
}
@@ -249,9 +235,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
}
if ($this->logger) {
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
}
$this->logger?->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
return '';
}
@@ -291,9 +275,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
}
// add a query string if needed
$extra = array_udiff_assoc(array_diff_key($parameters, $variables), $defaults, function ($a, $b) {
return $a == $b ? 0 : 1;
});
$extra = array_udiff_assoc(array_diff_key($parameters, $variables), $defaults, fn ($a, $b) => $a == $b ? 0 : 1);
array_walk_recursive($extra, $caster = static function (&$v) use (&$caster) {
if (\is_object($v)) {
@@ -342,10 +324,8 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
*
* @param string $basePath The base path
* @param string $targetPath The target path
*
* @return string
*/
public static function getRelativePath(string $basePath, string $targetPath)
public static function getRelativePath(string $basePath, string $targetPath): string
{
if ($basePath === $targetPath) {
return '';

View File

@@ -71,12 +71,10 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
*
* The special parameter _fragment will be used as the document fragment suffixed to the final URL.
*
* @return string
*
* @throws RouteNotFoundException If the named route doesn't exist
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
* it does not match the requirement
*/
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH);
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string;
}