From 91cd0d4061ac19fef41d17a1c77dc1696ded97f5 Mon Sep 17 00:00:00 2001 From: Jeff Roedel Date: Tue, 4 Aug 2026 12:21:51 +0200 Subject: [PATCH] Support PHP 8.4 Adds ~8.4.0 to the php constraint and 8.4 to the CI matrix (both the --prefer-stable and --prefer-lowest legs, matching the existing rows). The library already ran correctly on 8.4; what it emitted was 5 implicit-nullable-parameter deprecations, the `Type $x = null` form 8.4 deprecates in favour of `?Type $x = null`. These parameters were always nullable, so the signatures do not change in meaning. Verified on PHP 8.4.24 (intl loaded): 98 tests, 122 assertions pass, and loading every class under E_ALL reports zero deprecations where it previously reported 5. Not addressed here, but noted while testing: UriPathStrategy line 202 passes a null $base to trim(), which PHP has deprecated since 8.1. It reproduces on unmodified master and is unrelated to 8.4, so it is left for a separate change. --- .github/workflows/ci.yaml | 6 ++++++ composer.json | 2 +- src/SlmLocale/Locale/Detector.php | 2 +- src/SlmLocale/Service/PrimaryLanguageHelperFactory.php | 2 +- src/SlmLocale/Strategy/UriPathStrategy.php | 4 ++-- src/SlmLocale/View/Helper/LocaleUrl.php | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 712314a..9cc560c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,6 +39,12 @@ jobs: - php-version: 8.3 dependencies: "--prefer-lowest --prefer-stable" test_coverage: "no" + - php-version: 8.4 + dependencies: "--prefer-stable" + test_coverage: "no" + - php-version: 8.4 + dependencies: "--prefer-lowest --prefer-stable" + test_coverage: "no" steps: - name: Setup PHP diff --git a/composer.json b/composer.json index b7e1eb3..b3c7331 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": "^7.2 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "php": "^7.2 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "ext-intl": "*", "laminas/laminas-eventmanager": "^3.1", "laminas/laminas-http": "^2.7", diff --git a/src/SlmLocale/Locale/Detector.php b/src/SlmLocale/Locale/Detector.php index 86f061c..1278f15 100644 --- a/src/SlmLocale/Locale/Detector.php +++ b/src/SlmLocale/Locale/Detector.php @@ -145,7 +145,7 @@ public function hasMappings() return is_array($this->mappings) && count($this->mappings); } - public function detect(RequestInterface $request, ResponseInterface $response = null) + public function detect(RequestInterface $request, ?ResponseInterface $response = null) { $event = new LocaleEvent(LocaleEvent::EVENT_DETECT, $this); $event->setRequest($request); diff --git a/src/SlmLocale/Service/PrimaryLanguageHelperFactory.php b/src/SlmLocale/Service/PrimaryLanguageHelperFactory.php index 89f0844..6abba24 100644 --- a/src/SlmLocale/Service/PrimaryLanguageHelperFactory.php +++ b/src/SlmLocale/Service/PrimaryLanguageHelperFactory.php @@ -52,7 +52,7 @@ final class PrimaryLanguageHelperFactory implements FactoryInterface * @param array|null $options * @return object|PrimaryLanguage */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { return new PrimaryLanguage(new Locale()); } diff --git a/src/SlmLocale/Strategy/UriPathStrategy.php b/src/SlmLocale/Strategy/UriPathStrategy.php index 5dbd33a..0e65a36 100644 --- a/src/SlmLocale/Strategy/UriPathStrategy.php +++ b/src/SlmLocale/Strategy/UriPathStrategy.php @@ -66,7 +66,7 @@ class UriPathStrategy extends AbstractStrategy */ protected $router; - public function __construct(SimpleRouteStack $router = null) + public function __construct(?SimpleRouteStack $router = null) { $this->router = $router; } @@ -267,7 +267,7 @@ protected function getAliasForLocale($locale) * @param RequestInterface|null $request * @return string|null */ - protected function getBasePath(RequestInterface $request = null) + protected function getBasePath(?RequestInterface $request = null) { $result = null; if ($this->router instanceof TreeRouteStack) { diff --git a/src/SlmLocale/View/Helper/LocaleUrl.php b/src/SlmLocale/View/Helper/LocaleUrl.php index 0e18571..6ad8e10 100644 --- a/src/SlmLocale/View/Helper/LocaleUrl.php +++ b/src/SlmLocale/View/Helper/LocaleUrl.php @@ -59,7 +59,7 @@ class LocaleUrl extends AbstractHelper */ protected $request; - public function __construct(Detector $detector, Request $request, RouteMatch $match = null) + public function __construct(Detector $detector, Request $request, ?RouteMatch $match = null) { $this->detector = $detector; $this->match = $match;