Skip to content

Commit 8a03fd7

Browse files
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
1 parent f1d08ed commit 8a03fd7

38 files changed

+65
-65
lines changed

Annotation/Route.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,20 @@ class Route
4949
public function __construct(
5050
$data = [],
5151
$path = null,
52-
string $name = null,
52+
?string $name = null,
5353
array $requirements = [],
5454
array $options = [],
5555
array $defaults = [],
56-
string $host = null,
56+
?string $host = null,
5757
$methods = [],
5858
$schemes = [],
59-
string $condition = null,
60-
int $priority = null,
61-
string $locale = null,
62-
string $format = null,
63-
bool $utf8 = null,
64-
bool $stateless = null,
65-
string $env = null
59+
?string $condition = null,
60+
?int $priority = null,
61+
?string $locale = null,
62+
?string $format = null,
63+
?bool $utf8 = null,
64+
?bool $stateless = null,
65+
?string $env = null
6666
) {
6767
if (\is_string($data)) {
6868
$data = ['path' => $data];

CompiledRoute.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CompiledRoute implements \Serializable
3737
* @param array $hostVariables An array of host variables
3838
* @param array $variables An array of variables (variables defined in the path and in the host patterns)
3939
*/
40-
public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = [], array $hostVariables = [], array $variables = [])
40+
public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, ?string $hostRegex = null, array $hostTokens = [], array $hostVariables = [], array $variables = [])
4141
{
4242
$this->staticPrefix = $staticPrefix;
4343
$this->regex = $regex;

Exception/MethodNotAllowedException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MethodNotAllowedException extends \RuntimeException implements ExceptionIn
2525
/**
2626
* @param string[] $allowedMethods
2727
*/
28-
public function __construct(array $allowedMethods, ?string $message = '', int $code = 0, \Throwable $previous = null)
28+
public function __construct(array $allowedMethods, ?string $message = '', int $code = 0, ?\Throwable $previous = null)
2929
{
3030
if (null === $message) {
3131
trigger_deprecation('symfony/routing', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__);

Generator/CompiledUrlGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CompiledUrlGenerator extends UrlGenerator
2323
private $compiledRoutes = [];
2424
private $defaultLocale;
2525

26-
public function __construct(array $compiledRoutes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
26+
public function __construct(array $compiledRoutes, RequestContext $context, ?LoggerInterface $logger = null, ?string $defaultLocale = null)
2727
{
2828
$this->compiledRoutes = $compiledRoutes;
2929
$this->context = $context;

Generator/UrlGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
8282
'%7C' => '|',
8383
];
8484

85-
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
85+
public function __construct(RouteCollection $routes, RequestContext $context, ?LoggerInterface $logger = null, ?string $defaultLocale = null)
8686
{
8787
$this->routes = $routes;
8888
$this->context = $context;

Loader/AnnotationClassLoader.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
8585
*/
8686
protected $defaultRouteIndex = 0;
8787

88-
public function __construct(Reader $reader = null, string $env = null)
88+
public function __construct(?Reader $reader = null, ?string $env = null)
8989
{
9090
$this->reader = $reader;
9191
$this->env = $env;
@@ -108,7 +108,7 @@ public function setRouteAnnotationClass(string $class)
108108
*
109109
* @throws \InvalidArgumentException When route can't be parsed
110110
*/
111-
public function load($class, string $type = null)
111+
public function load($class, ?string $type = null)
112112
{
113113
if (!class_exists($class)) {
114114
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
@@ -239,7 +239,7 @@ protected function addRoute(RouteCollection $collection, object $annot, array $g
239239
/**
240240
* {@inheritdoc}
241241
*/
242-
public function supports($resource, string $type = null)
242+
public function supports($resource, ?string $type = null)
243243
{
244244
return \is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type);
245245
}

Loader/AnnotationDirectoryLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
3232
*
3333
* @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed
3434
*/
35-
public function load($path, string $type = null)
35+
public function load($path, ?string $type = null)
3636
{
3737
if (!is_dir($dir = $this->locator->locate($path))) {
3838
return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection();
@@ -74,7 +74,7 @@ function (\SplFileInfo $current) {
7474
/**
7575
* {@inheritdoc}
7676
*/
77-
public function supports($resource, string $type = null)
77+
public function supports($resource, ?string $type = null)
7878
{
7979
if ('annotation' === $type) {
8080
return true;

Loader/AnnotationFileLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(FileLocatorInterface $locator, AnnotationClassLoader
4747
*
4848
* @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed
4949
*/
50-
public function load($file, string $type = null)
50+
public function load($file, ?string $type = null)
5151
{
5252
$path = $this->locator->locate($file);
5353

@@ -70,7 +70,7 @@ public function load($file, string $type = null)
7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function supports($resource, string $type = null)
73+
public function supports($resource, ?string $type = null)
7474
{
7575
return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'annotation' === $type);
7676
}

Loader/ClosureLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ class ClosureLoader extends Loader
3131
*
3232
* @return RouteCollection
3333
*/
34-
public function load($closure, string $type = null)
34+
public function load($closure, ?string $type = null)
3535
{
3636
return $closure($this->env);
3737
}
3838

3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function supports($resource, string $type = null)
42+
public function supports($resource, ?string $type = null)
4343
{
4444
return $resource instanceof \Closure && (!$type || 'closure' === $type);
4545
}

Loader/Configurator/CollectionConfigurator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CollectionConfigurator
2828
private $parentPrefixes;
2929
private $host;
3030

31-
public function __construct(RouteCollection $parent, string $name, self $parentConfigurator = null, array $parentPrefixes = null)
31+
public function __construct(RouteCollection $parent, string $name, ?self $parentConfigurator = null, ?array $parentPrefixes = null)
3232
{
3333
$this->parent = $parent;
3434
$this->name = $name;

Loader/Configurator/RouteConfigurator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class RouteConfigurator
2424

2525
protected $parentConfigurator;
2626

27-
public function __construct(RouteCollection $collection, RouteCollection $route, string $name = '', CollectionConfigurator $parentConfigurator = null, array $prefixes = null)
27+
public function __construct(RouteCollection $collection, RouteCollection $route, string $name = '', ?CollectionConfigurator $parentConfigurator = null, ?array $prefixes = null)
2828
{
2929
$this->collection = $collection;
3030
$this->route = $route;

Loader/Configurator/RoutingConfigurator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RoutingConfigurator
2626
private $file;
2727
private $env;
2828

29-
public function __construct(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file, string $env = null)
29+
public function __construct(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file, ?string $env = null)
3030
{
3131
$this->collection = $collection;
3232
$this->loader = $loader;
@@ -38,7 +38,7 @@ public function __construct(RouteCollection $collection, PhpFileLoader $loader,
3838
/**
3939
* @param string|string[]|null $exclude Glob patterns to exclude from the import
4040
*/
41-
final public function import($resource, string $type = null, bool $ignoreErrors = false, $exclude = null): ImportConfigurator
41+
final public function import($resource, ?string $type = null, bool $ignoreErrors = false, $exclude = null): ImportConfigurator
4242
{
4343
$this->loader->setCurrentDir(\dirname($this->path));
4444

Loader/Configurator/Traits/LocalizedRouteTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait LocalizedRouteTrait
2727
*
2828
* @param string|array $path the path, or the localized paths of the route
2929
*/
30-
final protected function createLocalizedRoute(RouteCollection $collection, string $name, $path, string $namePrefix = '', array $prefixes = null): RouteCollection
30+
final protected function createLocalizedRoute(RouteCollection $collection, string $name, $path, string $namePrefix = '', ?array $prefixes = null): RouteCollection
3131
{
3232
$paths = [];
3333

Loader/ContainerLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ContainerLoader extends ObjectLoader
2222
{
2323
private $container;
2424

25-
public function __construct(ContainerInterface $container, string $env = null)
25+
public function __construct(ContainerInterface $container, ?string $env = null)
2626
{
2727
$this->container = $container;
2828
parent::__construct($env);
@@ -31,7 +31,7 @@ public function __construct(ContainerInterface $container, string $env = null)
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function supports($resource, string $type = null)
34+
public function supports($resource, ?string $type = null)
3535
{
3636
return 'service' === $type && \is_string($resource);
3737
}

Loader/DirectoryLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DirectoryLoader extends FileLoader
2020
/**
2121
* {@inheritdoc}
2222
*/
23-
public function load($file, string $type = null)
23+
public function load($file, ?string $type = null)
2424
{
2525
$path = $this->locator->locate($file);
2626

@@ -49,7 +49,7 @@ public function load($file, string $type = null)
4949
/**
5050
* {@inheritdoc}
5151
*/
52-
public function supports($resource, string $type = null)
52+
public function supports($resource, ?string $type = null)
5353
{
5454
// only when type is forced to directory, not to conflict with AnnotationLoader
5555

Loader/GlobFileLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GlobFileLoader extends FileLoader
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
public function load($resource, string $type = null)
27+
public function load($resource, ?string $type = null)
2828
{
2929
$collection = new RouteCollection();
3030

@@ -40,7 +40,7 @@ public function load($resource, string $type = null)
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
public function supports($resource, string $type = null)
43+
public function supports($resource, ?string $type = null)
4444
{
4545
return 'glob' === $type;
4646
}

Loader/ObjectLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract protected function getObject(string $id);
4040
*
4141
* @return RouteCollection
4242
*/
43-
public function load($resource, string $type = null)
43+
public function load($resource, ?string $type = null)
4444
{
4545
if (!preg_match('/^[^\:]+(?:::(?:[^\:]+))?$/', $resource)) {
4646
throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the %s route loader: use the format "object_id::method" or "object_id" if your object class has an "__invoke" method.', $resource, \is_string($type) ? '"'.$type.'"' : 'object'));

Loader/PhpFileLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PhpFileLoader extends FileLoader
3535
*
3636
* @return RouteCollection
3737
*/
38-
public function load($file, string $type = null)
38+
public function load($file, ?string $type = null)
3939
{
4040
$path = $this->locator->locate($file);
4141
$this->setCurrentDir(\dirname($path));
@@ -62,7 +62,7 @@ public function load($file, string $type = null)
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function supports($resource, string $type = null)
65+
public function supports($resource, ?string $type = null)
6666
{
6767
return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'php' === $type);
6868
}

Loader/XmlFileLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class XmlFileLoader extends FileLoader
4545
* @throws \InvalidArgumentException when the file cannot be loaded or when the XML cannot be
4646
* parsed because it does not validate against the scheme
4747
*/
48-
public function load($file, string $type = null)
48+
public function load($file, ?string $type = null)
4949
{
5050
$path = $this->locator->locate($file);
5151

@@ -102,7 +102,7 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, str
102102
/**
103103
* {@inheritdoc}
104104
*/
105-
public function supports($resource, string $type = null)
105+
public function supports($resource, ?string $type = null)
106106
{
107107
return \is_string($resource) && 'xml' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'xml' === $type);
108108
}

Loader/YamlFileLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class YamlFileLoader extends FileLoader
4848
*
4949
* @throws \InvalidArgumentException When a route can't be parsed because YAML is invalid
5050
*/
51-
public function load($file, string $type = null)
51+
public function load($file, ?string $type = null)
5252
{
5353
$path = $this->locator->locate($file);
5454

@@ -117,7 +117,7 @@ public function load($file, string $type = null)
117117
/**
118118
* {@inheritdoc}
119119
*/
120-
public function supports($resource, string $type = null)
120+
public function supports($resource, ?string $type = null)
121121
{
122122
return \is_string($resource) && \in_array(pathinfo($resource, \PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type);
123123
}

Matcher/RedirectableUrlMatcherInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ interface RedirectableUrlMatcherInterface
2727
*
2828
* @return array
2929
*/
30-
public function redirect(string $path, string $route, string $scheme = null);
30+
public function redirect(string $path, string $route, ?string $scheme = null);
3131
}

Matcher/TraceableUrlMatcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function matchCollection(string $pathinfo, RouteCollection $routes)
152152
return [];
153153
}
154154

155-
private function addTrace(string $log, int $level = self::ROUTE_DOES_NOT_MATCH, string $name = null, Route $route = null)
155+
private function addTrace(string $log, int $level = self::ROUTE_DOES_NOT_MATCH, ?string $name = null, ?Route $route = null)
156156
{
157157
$this->traces[] = [
158158
'log' => $log,

RouteCollectionBuilder.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class RouteCollectionBuilder
4343
private $methods;
4444
private $resources = [];
4545

46-
public function __construct(LoaderInterface $loader = null)
46+
public function __construct(?LoaderInterface $loader = null)
4747
{
4848
$this->loader = $loader;
4949
}
@@ -59,7 +59,7 @@ public function __construct(LoaderInterface $loader = null)
5959
*
6060
* @throws LoaderLoadException
6161
*/
62-
public function import($resource, string $prefix = '/', string $type = null)
62+
public function import($resource, string $prefix = '/', ?string $type = null)
6363
{
6464
/** @var RouteCollection[] $collections */
6565
$collections = $this->load($resource, $type);
@@ -92,7 +92,7 @@ public function import($resource, string $prefix = '/', string $type = null)
9292
*
9393
* @return Route
9494
*/
95-
public function add(string $path, string $controller, string $name = null)
95+
public function add(string $path, string $controller, ?string $name = null)
9696
{
9797
$route = new Route($path);
9898
$route->setDefault('_controller', $controller);
@@ -125,7 +125,7 @@ public function mount(string $prefix, self $builder)
125125
*
126126
* @return $this
127127
*/
128-
public function addRoute(Route $route, string $name = null)
128+
public function addRoute(Route $route, ?string $name = null)
129129
{
130130
if (null === $name) {
131131
// used as a flag to know which routes will need a name later
@@ -337,7 +337,7 @@ private function generateRouteName(Route $route): string
337337
*
338338
* @throws LoaderLoadException If no loader is found
339339
*/
340-
private function load($resource, string $type = null): array
340+
private function load($resource, ?string $type = null): array
341341
{
342342
if (null === $this->loader) {
343343
throw new \BadMethodCallException('Cannot import other routing resources: you must pass a LoaderInterface when constructing RouteCollectionBuilder.');

Router.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Router implements RouterInterface, RequestMatcherInterface
9797
/**
9898
* @param mixed $resource The main resource to load
9999
*/
100-
public function __construct(LoaderInterface $loader, $resource, array $options = [], RequestContext $context = null, LoggerInterface $logger = null, string $defaultLocale = null)
100+
public function __construct(LoaderInterface $loader, $resource, array $options = [], ?RequestContext $context = null, ?LoggerInterface $logger = null, ?string $defaultLocale = null)
101101
{
102102
$this->loader = $loader;
103103
$this->resource = $resource;

Tests/Generator/UrlGeneratorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ public static function provideLookAroundRequirementsInPath()
10121012
yield ['/app.php/bar/a/b/bam/c/d/e', '/bar/{foo}/bam/{baz}', '(?<!^).+'];
10131013
}
10141014

1015-
protected function getGenerator(RouteCollection $routes, array $parameters = [], $logger = null, string $defaultLocale = null)
1015+
protected function getGenerator(RouteCollection $routes, array $parameters = [], $logger = null, ?string $defaultLocale = null)
10161016
{
10171017
$context = new RequestContext('/app.php');
10181018
foreach ($parameters as $key => $value) {

Tests/Loader/AnnotationClassLoaderWithAnnotationsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class AnnotationClassLoaderWithAnnotationsTest extends AnnotationClassLoaderTestCase
2020
{
21-
protected function setUp(string $env = null): void
21+
protected function setUp(?string $env = null): void
2222
{
2323
$reader = new AnnotationReader();
2424
$this->loader = new class($reader, $env) extends AnnotationClassLoader {

0 commit comments

Comments
 (0)