From 51ed8e7b0cab381c15ca0606c498cbdd6f5f402c Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Fri, 9 Jan 2026 11:04:22 +0300 Subject: [PATCH 1/4] Bump minimal PHP version to 8.1 --- .github/workflows/bc.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/composer-require-checker.yml | 2 +- .github/workflows/static.yml | 2 +- CHANGELOG.md | 2 +- README.md | 2 +- composer.json | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/bc.yml b/.github/workflows/bc.yml index f8cc564..00041a9 100644 --- a/.github/workflows/bc.yml +++ b/.github/workflows/bc.yml @@ -30,4 +30,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0'] + ['8.1'] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c26d62..1b1e2d8 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.4', '8.5'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index a035b54..d2ef508 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.4', '8.5'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 0a323eb..d03874d 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -29,4 +29,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2', '8.3', '8.4'] + ['8.1', '8.2', '8.3', '8.4'] diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2f6fd..aa29a71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 3.2.2 under development -- no changes in this release. +- Chg #104: Bump minimal PHP version to 8.1 (@vjik) ## 3.2.1 December 17, 2025 diff --git a/README.md b/README.md index 571fc01..91c4fb6 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ a [PSR-15](https://www.php-fig.org/psr/psr-15/) middleware to authenticate an id ## Requirements -- PHP 8.0 - 8.5. +- PHP 8.1 - 8.5. ## Installation diff --git a/composer.json b/composer.json index b7b5745..d7d30f8 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ } ], "require": { - "php": "8.0 - 8.5", + "php": "8.1 - 8.5", "psr/http-factory": "^1.0", "psr/http-message": "^1.0 || ^2.0", "psr/http-server-handler": "^1.0", @@ -44,7 +44,7 @@ "roave/infection-static-analysis-plugin": "^1.25", "spatie/phpunit-watcher": "^1.23.6", "vimeo/psalm": "^4.30 || ^5.26.1 || ^6.10", - "yiisoft/yii-debug": "dev-master || dev-php80" + "yiisoft/yii-debug": "dev-master" }, "autoload": { "psr-4": { From d431e3fb4223d060b404389b19377a560db86f0f Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Fri, 9 Jan 2026 11:06:53 +0300 Subject: [PATCH 2/4] Apply rector --- CHANGELOG.md | 1 + rector.php | 2 +- src/Debug/AuthenticationMethodInterfaceProxy.php | 2 +- src/Handler/AuthenticationFailureHandler.php | 5 +++-- src/Method/Composite.php | 5 +++-- tests/AuthenticationMiddlewareTest.php | 6 ++++-- tests/Stub/FakeIdentity.php | 5 +++-- tests/Stub/FakeIdentityRepository.php | 5 +++-- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa29a71..3ff30dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 3.2.2 under development - Chg #104: Bump minimal PHP version to 8.1 (@vjik) +- Enh #104: Explicitly mark readonly properties (@vjik) ## 3.2.1 December 17, 2025 diff --git a/rector.php b/rector.php index 32c8e91..b65bf05 100644 --- a/rector.php +++ b/rector.php @@ -10,7 +10,7 @@ __DIR__ . '/src', __DIR__ . '/tests', ]) - ->withPhpSets(php80: true) + ->withPhpSets(php81: true) ->withRules([ InlineConstructorDefaultToPropertyRector::class, ]); diff --git a/src/Debug/AuthenticationMethodInterfaceProxy.php b/src/Debug/AuthenticationMethodInterfaceProxy.php index bf818a5..3e4c027 100644 --- a/src/Debug/AuthenticationMethodInterfaceProxy.php +++ b/src/Debug/AuthenticationMethodInterfaceProxy.php @@ -11,7 +11,7 @@ final class AuthenticationMethodInterfaceProxy implements AuthenticationMethodInterface { - public function __construct(private AuthenticationMethodInterface $decorated, private IdentityCollector $collector) + public function __construct(private readonly AuthenticationMethodInterface $decorated, private readonly IdentityCollector $collector) { } diff --git a/src/Handler/AuthenticationFailureHandler.php b/src/Handler/AuthenticationFailureHandler.php index d9396ea..d98da41 100644 --- a/src/Handler/AuthenticationFailureHandler.php +++ b/src/Handler/AuthenticationFailureHandler.php @@ -15,8 +15,9 @@ */ final class AuthenticationFailureHandler implements RequestHandlerInterface { - public function __construct(private ResponseFactoryInterface $responseFactory) - { + public function __construct( + private readonly ResponseFactoryInterface $responseFactory, + ) { } public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Method/Composite.php b/src/Method/Composite.php index 87a248e..ed48e1c 100644 --- a/src/Method/Composite.php +++ b/src/Method/Composite.php @@ -17,8 +17,9 @@ final class Composite implements AuthenticationMethodInterface /** * @param AuthenticationMethodInterface[] $methods */ - public function __construct(private array $methods) - { + public function __construct( + private readonly array $methods, + ) { } public function authenticate(ServerRequestInterface $request): ?IdentityInterface diff --git a/tests/AuthenticationMiddlewareTest.php b/tests/AuthenticationMiddlewareTest.php index 186ced2..bcea2f1 100644 --- a/tests/AuthenticationMiddlewareTest.php +++ b/tests/AuthenticationMiddlewareTest.php @@ -164,8 +164,10 @@ public function testImmutability(): void private function createAuthenticationFailureHandler(string $failureResponse): RequestHandlerInterface { return new class ($failureResponse, new Psr17Factory()) implements RequestHandlerInterface { - public function __construct(private string $failureResponse, private ResponseFactoryInterface $responseFactory) - { + public function __construct( + private readonly string $failureResponse, + private readonly ResponseFactoryInterface $responseFactory, + ) { } public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/tests/Stub/FakeIdentity.php b/tests/Stub/FakeIdentity.php index 8af6f02..fa01d84 100644 --- a/tests/Stub/FakeIdentity.php +++ b/tests/Stub/FakeIdentity.php @@ -8,8 +8,9 @@ final class FakeIdentity implements IdentityInterface { - public function __construct(private ?string $id) - { + public function __construct( + private readonly ?string $id, + ) { } public function getId(): ?string diff --git a/tests/Stub/FakeIdentityRepository.php b/tests/Stub/FakeIdentityRepository.php index 028b9f2..c2e0afd 100644 --- a/tests/Stub/FakeIdentityRepository.php +++ b/tests/Stub/FakeIdentityRepository.php @@ -11,8 +11,9 @@ final class FakeIdentityRepository implements IdentityWithTokenRepositoryInterfa { private array $callParams = []; - public function __construct(private ?IdentityInterface $returnIdentity) - { + public function __construct( + private readonly ?IdentityInterface $returnIdentity, + ) { } public function findIdentity(string $id): ?IdentityInterface From 89aea4ba220625f48d062e0b4cd89be585a51567 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Fri, 9 Jan 2026 11:08:00 +0300 Subject: [PATCH 3/4] Update deps --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index d7d30f8..2772203 100644 --- a/composer.json +++ b/composer.json @@ -37,13 +37,13 @@ }, "require-dev": { "jetbrains/phpstorm-attributes": "^1.2", - "maglnet/composer-require-checker": "^4.4", + "maglnet/composer-require-checker": "^4.7.1", "nyholm/psr7": "^1.8.2", - "phpunit/phpunit": "^9.6.22", - "rector/rector": "^2.0.9", - "roave/infection-static-analysis-plugin": "^1.25", - "spatie/phpunit-watcher": "^1.23.6", - "vimeo/psalm": "^4.30 || ^5.26.1 || ^6.10", + "phpunit/phpunit": "^9.6.31", + "rector/rector": "^2.3.0", + "roave/infection-static-analysis-plugin": "^1.35", + "spatie/phpunit-watcher": "^1.24.4", + "vimeo/psalm": "^5.26.1 || ^6.10", "yiisoft/yii-debug": "dev-master" }, "autoload": { From 2045d8a09c7a4be4d8b1691e614350ddeb43762d Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Fri, 9 Jan 2026 11:10:38 +0300 Subject: [PATCH 4/4] Update PhpUnit --- .gitignore | 12 +++--------- composer.json | 2 +- phpunit.xml.dist | 25 +++++++++++++------------ tests/AuthenticationMiddlewareTest.php | 7 +++---- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 18a33d4..e882061 100644 --- a/.gitignore +++ b/.gitignore @@ -23,13 +23,7 @@ composer.phar # Mac DS_Store Files .DS_Store -# phpunit itself is not needed -phpunit.phar -# local phpunit config +# PhpUnit +/phpunit.phar /phpunit.xml -# phpunit cache -.phpunit.result.cache - -# Phan -analysis.txt - +/.phpunit.cache diff --git a/composer.json b/composer.json index 2772203..2f8e73b 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "jetbrains/phpstorm-attributes": "^1.2", "maglnet/composer-require-checker": "^4.7.1", "nyholm/psr7": "^1.8.2", - "phpunit/phpunit": "^9.6.31", + "phpunit/phpunit": "^10.5.60", "rector/rector": "^2.3.0", "roave/infection-static-analysis-plugin": "^1.35", "spatie/phpunit-watcher": "^1.24.4", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c53f809..2eb7776 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,19 @@ - + colors="true" + displayDetailsOnPhpunitDeprecations="true" +> @@ -23,9 +24,9 @@ - + - ./src + ./src - + diff --git a/tests/AuthenticationMiddlewareTest.php b/tests/AuthenticationMiddlewareTest.php index bcea2f1..e193dc3 100644 --- a/tests/AuthenticationMiddlewareTest.php +++ b/tests/AuthenticationMiddlewareTest.php @@ -6,6 +6,7 @@ use Nyholm\Psr7\Factory\Psr17Factory; use Nyholm\Psr7\ServerRequest; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseFactoryInterface; @@ -56,7 +57,7 @@ function (ServerRequestInterface $request) use ($identity) { $auth->process($request, $handler); } - public function skipDataProvider(): array + public static function dataShouldSkipCheckForOptionalPath(): array { return [ 'ascii' => ['/optional'], @@ -64,9 +65,7 @@ public function skipDataProvider(): array ]; } - /** - * @dataProvider skipDataProvider - */ + #[DataProvider('dataShouldSkipCheckForOptionalPath')] public function testShouldSkipCheckForOptionalPath(string $path): void { $request = new ServerRequest('GET', $path);