From a6d12f33888c5a8ccfa67b71d9294ef6fb0fcbbc Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 2 Dec 2024 18:31:35 +0100 Subject: [PATCH] Fix PHP 8.4 deprecations nullable objects (#27) --- .php-cs-fixer.dist.php | 3 +++ Routing/Loader/Reader/RestActionReader.php | 2 +- Routing/Loader/RestRouteProcessor.php | 8 ++++---- Routing/Loader/RestXmlCollectionLoader.php | 2 +- Routing/Loader/RestYamlCollectionLoader.php | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ab7457d..6740422 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -42,6 +42,9 @@ 'get_class_to_class_keyword' => false, 'phpdoc_separation' => false, 'fully_qualified_strict_types' => false, + 'nullable_type_declaration_for_default_null_value' => true, + 'native_function_invocation' => false, + 'trailing_comma_in_multiline' => false, ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/Routing/Loader/Reader/RestActionReader.php b/Routing/Loader/Reader/RestActionReader.php index 0d7bfcf..3a6167f 100644 --- a/Routing/Loader/Reader/RestActionReader.php +++ b/Routing/Loader/Reader/RestActionReader.php @@ -640,7 +640,7 @@ private function readMethodAnnotations(\ReflectionMethod $reflectionMethod, stri return $annotations; } - private function addRoute(RestRouteCollection $collection, string $routeName, Route $route, bool $isCollection, bool $isInflectable, RouteAnnotation $annotation = null): void + private function addRoute(RestRouteCollection $collection, string $routeName, Route $route, bool $isCollection, bool $isInflectable, ?RouteAnnotation $annotation = null): void { if ($annotation && null !== $annotation->getName()) { $options = $annotation->getOptions(); diff --git a/Routing/Loader/RestRouteProcessor.php b/Routing/Loader/RestRouteProcessor.php index 224e414..0def49a 100644 --- a/Routing/Loader/RestRouteProcessor.php +++ b/Routing/Loader/RestRouteProcessor.php @@ -30,10 +30,10 @@ public function importResource( LoaderInterface $loader, $resource, array $parents = [], - string $routePrefix = null, - string $namePrefix = null, - string $type = null, - string $currentDir = null + ?string $routePrefix = null, + ?string $namePrefix = null, + ?string $type = null, + ?string $currentDir = null ): RouteCollection { $loader = $loader->resolve($resource, $type); diff --git a/Routing/Loader/RestXmlCollectionLoader.php b/Routing/Loader/RestXmlCollectionLoader.php index bd4c076..ab11510 100644 --- a/Routing/Loader/RestXmlCollectionLoader.php +++ b/Routing/Loader/RestXmlCollectionLoader.php @@ -41,7 +41,7 @@ public function __construct( RestRouteProcessor $processor, bool $includeFormat = true, array $formats = [], - string $defaultFormat = null + ?string $defaultFormat = null ) { parent::__construct($locator); diff --git a/Routing/Loader/RestYamlCollectionLoader.php b/Routing/Loader/RestYamlCollectionLoader.php index da8141c..ff57cd3 100644 --- a/Routing/Loader/RestYamlCollectionLoader.php +++ b/Routing/Loader/RestYamlCollectionLoader.php @@ -41,7 +41,7 @@ public function __construct( RestRouteProcessor $processor, bool $includeFormat = true, array $formats = [], - string $defaultFormat = null + ?string $defaultFormat = null ) { parent::__construct($locator);