package and depencies
This commit is contained in:
86
vendor/symfony/routing/Router.php
vendored
86
vendor/symfony/routing/Router.php
vendored
@@ -82,22 +82,16 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
protected $defaultLocale;
|
||||
|
||||
/**
|
||||
* @var ConfigCacheFactoryInterface|null
|
||||
*/
|
||||
private $configCacheFactory;
|
||||
private ConfigCacheFactoryInterface $configCacheFactory;
|
||||
|
||||
/**
|
||||
* @var ExpressionFunctionProviderInterface[]
|
||||
*/
|
||||
private $expressionLanguageProviders = [];
|
||||
private array $expressionLanguageProviders = [];
|
||||
|
||||
private static $cache = [];
|
||||
private static ?array $cache = [];
|
||||
|
||||
/**
|
||||
* @param mixed $resource The main resource to load
|
||||
*/
|
||||
public function __construct(LoaderInterface $loader, $resource, array $options = [], RequestContext $context = null, LoggerInterface $logger = null, string $defaultLocale = null)
|
||||
public function __construct(LoaderInterface $loader, mixed $resource, array $options = [], RequestContext $context = null, LoggerInterface $logger = null, string $defaultLocale = null)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
$this->resource = $resource;
|
||||
@@ -155,11 +149,9 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
/**
|
||||
* Sets an option.
|
||||
*
|
||||
* @param mixed $value The value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setOption(string $key, $value)
|
||||
public function setOption(string $key, mixed $value)
|
||||
{
|
||||
if (!\array_key_exists($key, $this->options)) {
|
||||
throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key));
|
||||
@@ -171,11 +163,9 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
/**
|
||||
* Gets an option value.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function getOption(string $key)
|
||||
public function getOption(string $key): mixed
|
||||
{
|
||||
if (!\array_key_exists($key, $this->options)) {
|
||||
throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key));
|
||||
@@ -184,21 +174,11 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
return $this->options[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteCollection()
|
||||
{
|
||||
if (null === $this->collection) {
|
||||
$this->collection = $this->loader->load($this->resource, $this->options['resource_type']);
|
||||
}
|
||||
|
||||
return $this->collection;
|
||||
return $this->collection ??= $this->loader->load($this->resource, $this->options['resource_type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContext(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
@@ -211,10 +191,7 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContext()
|
||||
public function getContext(): RequestContext
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
@@ -227,26 +204,17 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
$this->configCacheFactory = $configCacheFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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
|
||||
{
|
||||
return $this->getGenerator()->generate($name, $parameters, $referenceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function match(string $pathinfo)
|
||||
public function match(string $pathinfo): array
|
||||
{
|
||||
return $this->getMatcher()->match($pathinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function matchRequest(Request $request)
|
||||
public function matchRequest(Request $request): array
|
||||
{
|
||||
$matcher = $this->getMatcher();
|
||||
if (!$matcher instanceof RequestMatcherInterface) {
|
||||
@@ -259,10 +227,8 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
|
||||
/**
|
||||
* Gets the UrlMatcher or RequestMatcher instance associated with this Router.
|
||||
*
|
||||
* @return UrlMatcherInterface|RequestMatcherInterface
|
||||
*/
|
||||
public function getMatcher()
|
||||
public function getMatcher(): UrlMatcherInterface|RequestMatcherInterface
|
||||
{
|
||||
if (null !== $this->matcher) {
|
||||
return $this->matcher;
|
||||
@@ -302,10 +268,8 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
|
||||
/**
|
||||
* Gets the UrlGenerator instance associated with this Router.
|
||||
*
|
||||
* @return UrlGeneratorInterface
|
||||
*/
|
||||
public function getGenerator()
|
||||
public function getGenerator(): UrlGeneratorInterface
|
||||
{
|
||||
if (null !== $this->generator) {
|
||||
return $this->generator;
|
||||
@@ -343,18 +307,12 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
$this->expressionLanguageProviders[] = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GeneratorDumperInterface
|
||||
*/
|
||||
protected function getGeneratorDumperInstance()
|
||||
protected function getGeneratorDumperInstance(): GeneratorDumperInterface
|
||||
{
|
||||
return new $this->options['generator_dumper_class']($this->getRouteCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MatcherDumperInterface
|
||||
*/
|
||||
protected function getMatcherDumperInstance()
|
||||
protected function getMatcherDumperInstance(): MatcherDumperInterface
|
||||
{
|
||||
return new $this->options['matcher_dumper_class']($this->getRouteCollection());
|
||||
}
|
||||
@@ -365,16 +323,12 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
private function getConfigCacheFactory(): ConfigCacheFactoryInterface
|
||||
{
|
||||
if (null === $this->configCacheFactory) {
|
||||
$this->configCacheFactory = new ConfigCacheFactory($this->options['debug']);
|
||||
}
|
||||
|
||||
return $this->configCacheFactory;
|
||||
return $this->configCacheFactory ??= new ConfigCacheFactory($this->options['debug']);
|
||||
}
|
||||
|
||||
private static function getCompiledRoutes(string $path): array
|
||||
{
|
||||
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
|
||||
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL))) {
|
||||
self::$cache = null;
|
||||
}
|
||||
|
||||
@@ -382,10 +336,6 @@ class Router implements RouterInterface, RequestMatcherInterface
|
||||
return require $path;
|
||||
}
|
||||
|
||||
if (isset(self::$cache[$path])) {
|
||||
return self::$cache[$path];
|
||||
}
|
||||
|
||||
return self::$cache[$path] = require $path;
|
||||
return self::$cache[$path] ??= require $path;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user