From 0eff0dd44037295d9b9f8b13bdc9526daf376470 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 20 Mar 2025 10:22:38 +0300 Subject: [PATCH 1/5] PHP 8.4 support --- .github/workflows/build.yml | 2 +- .github/workflows/composer-require-checker.yml | 2 +- .github/workflows/rector.yml | 2 +- .github/workflows/static.yml | 16 ++++++++-------- CHANGELOG.md | 2 +- composer.json | 16 ++++++++-------- psalm.xml | 2 ++ psalm83.xml => psalm81-82.xml | 1 - src/TrustedHostsNetworkResolver.php | 6 ++++-- 9 files changed, 26 insertions(+), 23 deletions(-) rename psalm83.xml => psalm81-82.xml (91%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e96052e..68fac01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest', 'windows-latest'] php: >- - ['8.0', '8.1', '8.2', '8.3'] + ['8.0', '8.1', '8.2', '8.3', '8.4'] diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 5473ec9..632bfd4 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2', '8.3'] + ['8.0', '8.1', '8.2', '8.3', '8.4'] diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 457772a..5d6931d 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -21,4 +21,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.3'] + ['8.4'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index d873c39..28a40b8 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -24,26 +24,26 @@ on: name: static analysis jobs: - psalm: + psalm80: uses: yiisoft/actions/.github/workflows/psalm.yml@master with: + psalm-config: psalm80.xml os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2'] - psalm80: + ['8.0'] + psalm81-82: uses: yiisoft/actions/.github/workflows/psalm.yml@master with: - psalm-config: psalm80.xml + psalm-config: psalm81-82.xml os: >- ['ubuntu-latest'] php: >- - ['8.0'] - psalm83: + ['8.1', '8.2'] + psalm: uses: yiisoft/actions/.github/workflows/psalm.yml@master with: - psalm-config: psalm83.xml os: >- ['ubuntu-latest'] php: >- - ['8.3'] + ['8.3', '8.4'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 37b10e0..46e2aa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.0.3 under development -- no changes in this release. +- Chg #44: Change PHP constraint in `composer.json` to `8.0 - 8.4` (@vjik) ## 1.0.2 August 06, 2024 diff --git a/composer.json b/composer.json index 1414345..bab5bfd 100644 --- a/composer.json +++ b/composer.json @@ -29,23 +29,23 @@ ], "prefer-stable": true, "require": { - "php": "^8.0", + "php": "8.0 - 8.4", "ext-filter": "*", - "psr/http-message": "^1.0|^2.0", + "psr/http-message": "^1.0 || ^2.0", "psr/http-server-handler": "^1.0", "psr/http-server-middleware": "^1.0", "yiisoft/http": "^1.2", "yiisoft/network-utilities": "^1.1" }, "require-dev": { - "httpsoft/http-message": "^1.0", + "httpsoft/http-message": "^1.1.6", "maglnet/composer-require-checker": "^4.4", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^9.6.22", "rector/rector": "^0.16.0", - "roave/infection-static-analysis-plugin": "^1.16", - "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.30|^5.24", - "yiisoft/test-support": "^3.0" + "roave/infection-static-analysis-plugin": "^1.25", + "spatie/phpunit-watcher": "^1.23.6", + "vimeo/psalm": "^4.30 || ^5.26.1 || ^6.9.1", + "yiisoft/test-support": "^3.0.2" }, "autoload": { "psr-4": { diff --git a/psalm.xml b/psalm.xml index b48c894..11ada94 100644 --- a/psalm.xml +++ b/psalm.xml @@ -3,6 +3,7 @@ errorLevel="1" findUnusedBaselineEntry="true" findUnusedCode="false" + ensureOverrideAttribute="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" @@ -16,5 +17,6 @@ + diff --git a/psalm83.xml b/psalm81-82.xml similarity index 91% rename from psalm83.xml rename to psalm81-82.xml index ee80eb3..b48c894 100644 --- a/psalm83.xml +++ b/psalm81-82.xml @@ -16,6 +16,5 @@ - diff --git a/src/TrustedHostsNetworkResolver.php b/src/TrustedHostsNetworkResolver.php index 444b4dd..a3a3019 100644 --- a/src/TrustedHostsNetworkResolver.php +++ b/src/TrustedHostsNetworkResolver.php @@ -62,6 +62,8 @@ * port: ?int, * ipIdentifier: ?non-empty-string, * } + * + * @psalm-suppress ClassMustBeFinal We allow to extend this class. */ class TrustedHostsNetworkResolver implements MiddlewareInterface { @@ -522,7 +524,7 @@ private function normalizeHeaderName(string $headerName): string /** * @psalm-param non-empty-string $remoteAddr * - * @psalm-return array{0: ForwardedHeaderGroup, 1: list} + * @psalm-return array{0: ForwardedHeaderGroup, 1: non-empty-list} * * @throws InvalidConnectionChainItemException * @throws RfcProxyParseException @@ -761,7 +763,7 @@ private function getConnectionChainItem( } /** - * @psalm-param list $items + * @psalm-param non-empty-list $items * @psalm-param list $validatedItems * @psalm-param-out list $validatedItems * From c81ef00385160382afc0ef5431fc02c1d07bc875 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 20 Mar 2025 10:24:39 +0300 Subject: [PATCH 2/5] fix rector --- composer.json | 2 +- rector.php | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index bab5bfd..288311a 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "httpsoft/http-message": "^1.1.6", "maglnet/composer-require-checker": "^4.4", "phpunit/phpunit": "^9.6.22", - "rector/rector": "^0.16.0", + "rector/rector": "^2.0.10", "roave/infection-static-analysis-plugin": "^1.25", "spatie/phpunit-watcher": "^1.23.6", "vimeo/psalm": "^4.30 || ^5.26.1 || ^6.9.1", diff --git a/rector.php b/rector.php index 20acccd..ba1c8be 100644 --- a/rector.php +++ b/rector.php @@ -6,24 +6,17 @@ use Rector\Config\RectorConfig; use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; -use Rector\Set\ValueObject\LevelSetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/src', __DIR__ . '/tests', - ]); - - // register a single rule - $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); - - // define sets of rules - $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_80, - ]); - - $rectorConfig->skip([ + ]) + ->withPhpSets(php80: true) + ->withRules([ + InlineConstructorDefaultToPropertyRector::class, + ]) + ->withSkip([ ClosureToArrowFunctionRector::class, AddDefaultValueForUndefinedVariableRector::class, ]); -}; From 8651f9a531266ee6dd1f77059a5a913a44c665f3 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 20 Mar 2025 10:25:33 +0300 Subject: [PATCH 3/5] fix rector --- rector.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/rector.php b/rector.php index ba1c8be..c2226bf 100644 --- a/rector.php +++ b/rector.php @@ -4,7 +4,6 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; -use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; return RectorConfig::configure() @@ -18,5 +17,4 @@ ]) ->withSkip([ ClosureToArrowFunctionRector::class, - AddDefaultValueForUndefinedVariableRector::class, ]); From 940a01455e6177758e367d95491857f55f4445a4 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 20 Mar 2025 10:28:25 +0300 Subject: [PATCH 4/5] fix psalm --- src/TrustedHostsNetworkResolver.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/TrustedHostsNetworkResolver.php b/src/TrustedHostsNetworkResolver.php index a3a3019..19877ca 100644 --- a/src/TrustedHostsNetworkResolver.php +++ b/src/TrustedHostsNetworkResolver.php @@ -553,6 +553,9 @@ private function getConnectionChainItems(string $remoteAddr, ServerRequestInterf } $items = []; + /** + * @psalm-var non-empty-list $requestIps It needs for PHP 8.0 only + */ $requestIps = array_merge([$remoteAddr], array_reverse($forwardedHeaderValue)); foreach ($requestIps as $requestIp) { $items[] = $this->getConnectionChainItem( From 3208bc13dbfabcad573a34897335f17700f50086 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 20 Mar 2025 10:29:18 +0300 Subject: [PATCH 5/5] fix psalm --- psalm81-82.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/psalm81-82.xml b/psalm81-82.xml index b48c894..2b2e0b2 100644 --- a/psalm81-82.xml +++ b/psalm81-82.xml @@ -3,6 +3,7 @@ errorLevel="1" findUnusedBaselineEntry="true" findUnusedCode="false" + ensureOverrideAttribute="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"