Skip to content

Commit bd5744e

Browse files
Add types to public and protected properties
1 parent 2707992 commit bd5744e

File tree

9 files changed

+28
-72
lines changed

9 files changed

+28
-72
lines changed

Exception/MethodNotAllowedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
2222
{
23-
protected $allowedMethods = [];
23+
protected array $allowedMethods = [];
2424

2525
/**
2626
* @param string[] $allowedMethods

Generator/UrlGenerator.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,10 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
4242
'%2A' => '*',
4343
];
4444

45-
protected $routes;
46-
protected $context;
47-
48-
/**
49-
* @var bool|null
50-
*/
51-
protected $strictRequirements = true;
52-
53-
protected $logger;
45+
protected RouteCollection $routes;
46+
protected RequestContext $context;
47+
protected ?bool $strictRequirements = true;
48+
protected ?LoggerInterface $logger;
5449

5550
private ?string $defaultLocale;
5651

@@ -62,7 +57,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
6257
* "?" and "#" (would be interpreted wrongly as query and fragment identifier),
6358
* "'" and """ (are used as delimiters in HTML).
6459
*/
65-
protected $decodedChars = [
60+
protected array $decodedChars = [
6661
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
6762
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
6863
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss

Loader/AnnotationFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class AnnotationFileLoader extends FileLoader
2626
{
27-
protected $loader;
27+
protected AnnotationClassLoader $loader;
2828

2929
public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader)
3030
{

Loader/Configurator/RouteConfigurator.php

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

25-
protected $parentConfigurator;
25+
protected ?CollectionConfigurator $parentConfigurator;
2626

2727
public function __construct(RouteCollection $collection, RouteCollection $route, string $name = '', CollectionConfigurator $parentConfigurator = null, array $prefixes = null)
2828
{

Loader/Configurator/Traits/AddTrait.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ trait AddTrait
2323
{
2424
use LocalizedRouteTrait;
2525

26-
/**
27-
* @var RouteCollection
28-
*/
29-
protected $collection;
30-
protected $name = '';
31-
protected $prefixes;
26+
protected RouteCollection $collection;
27+
protected string $name = '';
28+
protected ?array $prefixes = null;
3229

3330
/**
3431
* Adds a route.

Loader/Configurator/Traits/RouteTrait.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
trait RouteTrait
1818
{
19-
/**
20-
* @var RouteCollection|Route
21-
*/
22-
protected $route;
19+
protected RouteCollection|Route $route;
2320

2421
/**
2522
* Adds defaults.

Matcher/TraceableUrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TraceableUrlMatcher extends UrlMatcher
2727
public const ROUTE_ALMOST_MATCHES = 1;
2828
public const ROUTE_MATCHES = 2;
2929

30-
protected $traces;
30+
protected array $traces;
3131

3232
public function getTraces(string $pathinfo): array
3333
{

Matcher/UrlMatcher.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
3232
public const REQUIREMENT_MISMATCH = 1;
3333
public const ROUTE_MATCH = 2;
3434

35-
/** @var RequestContext */
36-
protected $context;
35+
protected RequestContext $context;
3736

3837
/**
3938
* Collects HTTP methods that would be allowed for the request.
4039
*/
41-
protected $allow = [];
40+
protected array $allow = [];
4241

4342
/**
4443
* Collects URI schemes that would be allowed for the request.
@@ -47,14 +46,14 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
4746
*/
4847
protected array $allowSchemes = [];
4948

50-
protected $routes;
51-
protected $request;
52-
protected $expressionLanguage;
49+
protected RouteCollection $routes;
50+
protected ?Request $request = null;
51+
protected ExpressionLanguage $expressionLanguage;
5352

5453
/**
5554
* @var ExpressionFunctionProviderInterface[]
5655
*/
57-
protected $expressionLanguageProviders = [];
56+
protected array $expressionLanguageProviders = [];
5857

5958
public function __construct(RouteCollection $routes, RequestContext $context)
6059
{

Router.php

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,47 +37,15 @@
3737
*/
3838
class Router implements RouterInterface, RequestMatcherInterface
3939
{
40-
/**
41-
* @var UrlMatcherInterface|null
42-
*/
43-
protected $matcher;
44-
45-
/**
46-
* @var UrlGeneratorInterface|null
47-
*/
48-
protected $generator;
49-
50-
/**
51-
* @var RequestContext
52-
*/
53-
protected $context;
54-
55-
/**
56-
* @var LoaderInterface
57-
*/
58-
protected $loader;
59-
60-
/**
61-
* @var RouteCollection|null
62-
*/
63-
protected $collection;
64-
65-
protected $resource;
66-
67-
/**
68-
* @var array
69-
*/
70-
protected $options = [];
71-
72-
/**
73-
* @var LoggerInterface|null
74-
*/
75-
protected $logger;
76-
77-
/**
78-
* @var string|null
79-
*/
80-
protected $defaultLocale;
40+
protected UrlMatcherInterface|RequestMatcherInterface $matcher;
41+
protected UrlGeneratorInterface $generator;
42+
protected RequestContext $context;
43+
protected LoaderInterface $loader;
44+
protected RouteCollection $collection;
45+
protected mixed $resource;
46+
protected array $options = [];
47+
protected ?LoggerInterface $logger;
48+
protected ?string $defaultLocale;
8149

8250
private ConfigCacheFactoryInterface $configCacheFactory;
8351

0 commit comments

Comments
 (0)