From 000586da56ccde5f05746f5f492ba4ddf0e503e4 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 2 Dec 2024 18:29:49 +0100 Subject: [PATCH] Fix PHP 8.4 deprecations nullable objects --- .github/workflows/test-application.yaml | 2 ++ src/ChainRouter.php | 4 ++-- src/Event/RouterMatchEvent.php | 2 +- src/ProviderBasedGenerator.php | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 099cb40..e482851 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -30,6 +30,8 @@ jobs: - php-version: "8.2" - php-version: "8.3" symfony-version: "7" + - php-version: "8.4" + symfony-version: "7" steps: - name: "Checkout project" diff --git a/src/ChainRouter.php b/src/ChainRouter.php index 6c39c97..7c146d2 100644 --- a/src/ChainRouter.php +++ b/src/ChainRouter.php @@ -247,8 +247,8 @@ private function rebuildRequest(string $pathinfo): Request private function getErrorMessage( string $name, - RouterInterface|UrlGeneratorInterface|RequestMatcherInterface $router = null, - array $parameters = null + RouterInterface|UrlGeneratorInterface|RequestMatcherInterface|null $router = null, + ?array $parameters = null ): string { if ($router instanceof VersatileGeneratorInterface) { // the $parameters are not forced to be array, but versatile generator does typehint it diff --git a/src/Event/RouterMatchEvent.php b/src/Event/RouterMatchEvent.php index 757c6a6..87e6d66 100644 --- a/src/Event/RouterMatchEvent.php +++ b/src/Event/RouterMatchEvent.php @@ -18,7 +18,7 @@ final class RouterMatchEvent extends Event { private ?Request $request; - public function __construct(Request $request = null) + public function __construct(?Request $request = null) { $this->request = $request; } diff --git a/src/ProviderBasedGenerator.php b/src/ProviderBasedGenerator.php index 171a4d8..9880708 100644 --- a/src/ProviderBasedGenerator.php +++ b/src/ProviderBasedGenerator.php @@ -26,7 +26,7 @@ class ProviderBasedGenerator extends UrlGenerator implements VersatileGeneratorI { protected RouteProviderInterface $provider; - public function __construct(RouteProviderInterface $provider, LoggerInterface $logger = null) + public function __construct(RouteProviderInterface $provider, ?LoggerInterface $logger = null) { $this->provider = $provider; $this->logger = $logger ?: new NullLogger();