Skip to content

Commit bc5cd38

Browse files
committed
[Routing] Add types to private properties
1 parent 2317889 commit bc5cd38

18 files changed

+64
-83
lines changed

CompiledRoute.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
*/
1919
class CompiledRoute implements \Serializable
2020
{
21-
private $variables;
22-
private $tokens;
23-
private $staticPrefix;
24-
private $regex;
25-
private $pathVariables;
26-
private $hostVariables;
27-
private $hostRegex;
28-
private $hostTokens;
21+
private array $variables;
22+
private array $tokens;
23+
private string $staticPrefix;
24+
private string $regex;
25+
private array $pathVariables;
26+
private array $hostVariables;
27+
private ?string $hostRegex;
28+
private array $hostTokens;
2929

3030
/**
3131
* @param string $staticPrefix The static prefix of the compiled route

Generator/CompiledUrlGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
class CompiledUrlGenerator extends UrlGenerator
2222
{
23-
private $compiledRoutes = [];
24-
private $defaultLocale;
23+
private array $compiledRoutes = [];
24+
private ?string $defaultLocale;
2525

2626
public function __construct(array $compiledRoutes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
2727
{

Generator/Dumper/GeneratorDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
abstract class GeneratorDumper implements GeneratorDumperInterface
2222
{
23-
private $routes;
23+
private RouteCollection $routes;
2424

2525
public function __construct(RouteCollection $routes)
2626
{

Generator/UrlGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
5151

5252
protected $logger;
5353

54-
private $defaultLocale;
54+
private ?string $defaultLocale;
5555

5656
/**
5757
* This array defines the characters (besides alphanumeric ones) that will not be percent-encoded in the path segment of the generated URL.

Loader/Configurator/CollectionConfigurator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class CollectionConfigurator
2323
use Traits\HostTrait;
2424
use Traits\RouteTrait;
2525

26-
private $parent;
27-
private $parentConfigurator;
28-
private $parentPrefixes;
29-
private $host;
26+
private RouteCollection $parent;
27+
private ?CollectionConfigurator $parentConfigurator;
28+
private ?array $parentPrefixes;
29+
private string|array|null $host = null;
3030

3131
public function __construct(RouteCollection $parent, string $name, self $parentConfigurator = null, array $parentPrefixes = null)
3232
{

Loader/Configurator/ImportConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ImportConfigurator
2222
use Traits\PrefixTrait;
2323
use Traits\RouteTrait;
2424

25-
private $parent;
25+
private RouteCollection $parent;
2626

2727
public function __construct(RouteCollection $parent, RouteCollection $route)
2828
{

Loader/Configurator/RoutingConfigurator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class RoutingConfigurator
2121
{
2222
use Traits\AddTrait;
2323

24-
private $loader;
25-
private $path;
26-
private $file;
27-
private $env;
24+
private PhpFileLoader $loader;
25+
private string $path;
26+
private string $file;
27+
private ?string $env;
2828

2929
public function __construct(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file, string $env = null)
3030
{

Loader/ContainerLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class ContainerLoader extends ObjectLoader
2222
{
23-
private $container;
23+
private ContainerInterface $container;
2424

2525
public function __construct(ContainerInterface $container, string $env = null)
2626
{

Loader/YamlFileLoader.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class YamlFileLoader extends FileLoader
3636
private const AVAILABLE_KEYS = [
3737
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', 'name_prefix', 'trailing_slash_on_root', 'locale', 'format', 'utf8', 'exclude', 'stateless',
3838
];
39-
private $yamlParser;
39+
private YamlParser $yamlParser;
4040

4141
/**
4242
* @throws \InvalidArgumentException When a route can't be parsed because YAML is invalid
@@ -53,9 +53,7 @@ public function load(mixed $file, string $type = null): RouteCollection
5353
throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path));
5454
}
5555

56-
if (null === $this->yamlParser) {
57-
$this->yamlParser = new YamlParser();
58-
}
56+
$this->yamlParser ??= new YamlParser();
5957

6058
try {
6159
$parsedConfig = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);

Matcher/Dumper/CompiledUrlMatcherDumper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
*/
2727
class CompiledUrlMatcherDumper extends MatcherDumper
2828
{
29-
private $expressionLanguage;
30-
private $signalingException;
29+
private ExpressionLanguage $expressionLanguage;
30+
private ?\Exception $signalingException = null;
3131

3232
/**
3333
* @var ExpressionFunctionProviderInterface[]
3434
*/
35-
private $expressionLanguageProviders = [];
35+
private array $expressionLanguageProviders = [];
3636

3737
/**
3838
* {@inheritdoc}
@@ -445,7 +445,7 @@ private function compileRoute(Route $route, string $name, string|array|null $var
445445

446446
private function getExpressionLanguage(): ExpressionLanguage
447447
{
448-
if (null === $this->expressionLanguage) {
448+
if (!isset($this->expressionLanguage)) {
449449
if (!class_exists(ExpressionLanguage::class)) {
450450
throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
451451
}

0 commit comments

Comments
 (0)