diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index db9e4a1..8f68dc8 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,5 +1,7 @@ setRules([ '@PHP7x1Migration' => true, @@ -10,6 +12,7 @@ 'native_constant_invocation' => ['strict' => false], 'nullable_type_declaration_for_default_null_value' => true, 'modernize_strpos' => true, + 'declare_strict_types' => ['strategy' => 'enforce'], ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/composer.json b/composer.json index 90ecd66..e36cfb7 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/console": "^7 || ^8" }, "require-dev": { - "friendsofphp/php-cs-fixer": "3.92.5", + "friendsofphp/php-cs-fixer": "3.95.1", "phpunit/phpunit": "^11 || ^12 || ^13", "guzzlehttp/guzzle": "^7.0", "humbug/box": "^4.6", diff --git a/src/Initiator.php b/src/Initiator.php index 7d94133..2e0e614 100644 --- a/src/Initiator.php +++ b/src/Initiator.php @@ -1,5 +1,7 @@ pages)) { - $this->pages = array_map(fn (Page $page) => clone $page, $this->pages); + $this->pages = array_map(static fn (Page $page) => clone $page, $this->pages); } if (isset($this->entries)) { - $this->entries = array_map(fn (Entry $entry) => clone $entry, $this->entries); + $this->entries = array_map(static fn (Entry $entry) => clone $entry, $this->entries); } } } diff --git a/src/Serializer.php b/src/Serializer.php index f3271de..452a3ad 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -25,7 +25,7 @@ public function getSerializerBuilder(): SerializerBuilder $builder = SerializerBuilder::create() ->setPropertyNamingStrategy(new IdenticalPropertyNamingStrategy()) ->configureHandlers( - function (HandlerRegistryInterface $registry) { + static function (HandlerRegistryInterface $registry) { $registry->registerSubscribingHandler( new DateFormatInterfaceHandler(Log::ISO_8601_MICROSECONDS) ); diff --git a/tests/src/Unit/Handler/TruncatingDateTimeHandlerTest.php b/tests/src/Unit/Handler/TruncatingDateTimeHandlerTest.php index 47cd31d..d2ebfe7 100644 --- a/tests/src/Unit/Handler/TruncatingDateTimeHandlerTest.php +++ b/tests/src/Unit/Handler/TruncatingDateTimeHandlerTest.php @@ -46,7 +46,7 @@ public function testGetSubscribingMethods(): void $this->assertContains('xml', $formats); // Verify method names are correctly formed for DateTimeInterface - $dateTimeInterfaceMethods = array_filter($methods, fn ($m) => 'DateTimeInterface' === $m['type']); + $dateTimeInterfaceMethods = array_filter($methods, static fn ($m) => 'DateTimeInterface' === $m['type']); $methodNames = array_column($dateTimeInterfaceMethods, 'method'); // Method names should be deserializeDateTimeFromJson and deserializeDateTimeFromXml diff --git a/tests/src/Unit/HarTest.php b/tests/src/Unit/HarTest.php index e10d050..88520be 100644 --- a/tests/src/Unit/HarTest.php +++ b/tests/src/Unit/HarTest.php @@ -109,7 +109,7 @@ private function removeCustomFields(array &$a): void } } - $a = array_filter($a, function ($key): bool { + $a = array_filter($a, static function ($key): bool { return !\is_string($key) || !str_starts_with($key, '_'); }, \ARRAY_FILTER_USE_KEY); } diff --git a/tests/src/Unit/PostDataTest.php b/tests/src/Unit/PostDataTest.php index 9544bfb..2893980 100644 --- a/tests/src/Unit/PostDataTest.php +++ b/tests/src/Unit/PostDataTest.php @@ -232,7 +232,7 @@ public function testGetBodySizeWithoutParamsDoesNotError(): void // Set up error handler to catch any warnings $warningTriggered = false; - $previousHandler = set_error_handler(function ($errno, $errstr) use (&$warningTriggered) { + $previousHandler = set_error_handler(static function ($errno, $errstr) use (&$warningTriggered) { if (str_contains($errstr, 'foreach') || str_contains($errstr, 'null')) { $warningTriggered = true; } diff --git a/tests/src/Unit/RequestTest.php b/tests/src/Unit/RequestTest.php index de2eb09..d74c5bc 100644 --- a/tests/src/Unit/RequestTest.php +++ b/tests/src/Unit/RequestTest.php @@ -107,7 +107,7 @@ public function testFromPsr7ServerRequest(): void // Verify headers $headers = $har_request->getHeaders(); - $headerNames = array_map(fn ($h) => $h->getName(), $headers); + $headerNames = array_map(static fn ($h) => $h->getName(), $headers); $this->assertContains('Host', $headerNames); $this->assertContains('Accept', $headerNames);