Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0']
['8.1']
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
2 changes: 1 addition & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
12 changes: 3 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## 3.2.2 under development

- no changes in this release.
- Chg #104: Bump minimal PHP version to 8.1 (@vjik)
- Enh #104: Explicitly mark readonly properties (@vjik)

## 3.2.1 December 17, 2025

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -37,14 +37,14 @@
},
"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",
"yiisoft/yii-debug": "dev-master || dev-php80"
"phpunit/phpunit": "^10.5.60",
"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": {
"psr-4": {
Expand Down
25 changes: 13 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnDeprecation="true"
stopOnFailure="false"
executionOrder="random"
resolveDependencies="true">
colors="true"
displayDetailsOnPhpunitDeprecations="true"
>
<php>
<ini name="error_reporting" value="-1"/>
</php>
Expand All @@ -23,9 +24,9 @@
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory>./src</directory>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withPhpSets(php80: true)
->withPhpSets(php81: true)
->withRules([
InlineConstructorDefaultToPropertyRector::class,
]);
2 changes: 1 addition & 1 deletion src/Debug/AuthenticationMethodInterfaceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
5 changes: 3 additions & 2 deletions src/Handler/AuthenticationFailureHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/Method/Composite.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* @param AuthenticationMethodInterface[] $methods
*/
public function __construct(private array $methods)
{
public function __construct(
private readonly array $methods,
) {
}

public function authenticate(ServerRequestInterface $request): ?IdentityInterface
{
foreach ($this->methods as $method) {
if (!$method instanceof AuthenticationMethodInterface) {
throw new \RuntimeException('Authentication method must be an instance of ' . AuthenticationMethodInterface::class . '.');

Check warning on line 29 in src/Method/Composite.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ { foreach ($this->methods as $method) { if (!$method instanceof AuthenticationMethodInterface) { - throw new \RuntimeException('Authentication method must be an instance of ' . AuthenticationMethodInterface::class . '.'); + throw new \RuntimeException('Authentication method must be an instance of ' . AuthenticationMethodInterface::class); } $identity = $method->authenticate($request);

Check warning on line 29 in src/Method/Composite.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "Concat": @@ @@ { foreach ($this->methods as $method) { if (!$method instanceof AuthenticationMethodInterface) { - throw new \RuntimeException('Authentication method must be an instance of ' . AuthenticationMethodInterface::class . '.'); + throw new \RuntimeException('Authentication method must be an instance of ' . '.' . AuthenticationMethodInterface::class); } $identity = $method->authenticate($request);

Check warning on line 29 in src/Method/Composite.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ { foreach ($this->methods as $method) { if (!$method instanceof AuthenticationMethodInterface) { - throw new \RuntimeException('Authentication method must be an instance of ' . AuthenticationMethodInterface::class . '.'); + throw new \RuntimeException('Authentication method must be an instance of ' . '.'); } $identity = $method->authenticate($request);

Check warning on line 29 in src/Method/Composite.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ { foreach ($this->methods as $method) { if (!$method instanceof AuthenticationMethodInterface) { - throw new \RuntimeException('Authentication method must be an instance of ' . AuthenticationMethodInterface::class . '.'); + throw new \RuntimeException(AuthenticationMethodInterface::class . '.'); } $identity = $method->authenticate($request);

Check warning on line 29 in src/Method/Composite.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "Concat": @@ @@ { foreach ($this->methods as $method) { if (!$method instanceof AuthenticationMethodInterface) { - throw new \RuntimeException('Authentication method must be an instance of ' . AuthenticationMethodInterface::class . '.'); + throw new \RuntimeException(AuthenticationMethodInterface::class . 'Authentication method must be an instance of ' . '.'); } $identity = $method->authenticate($request);
}

$identity = $method->authenticate($request);
Expand Down
13 changes: 7 additions & 6 deletions tests/AuthenticationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,17 +57,15 @@ function (ServerRequestInterface $request) use ($identity) {
$auth->process($request, $handler);
}

public function skipDataProvider(): array
public static function dataShouldSkipCheckForOptionalPath(): array
{
return [
'ascii' => ['/optional'],
'utf' => ['/опциональный'],
];
}

/**
* @dataProvider skipDataProvider
*/
#[DataProvider('dataShouldSkipCheckForOptionalPath')]
public function testShouldSkipCheckForOptionalPath(string $path): void
{
$request = new ServerRequest('GET', $path);
Expand Down Expand Up @@ -164,8 +163,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
Expand Down
5 changes: 3 additions & 2 deletions tests/Stub/FakeIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/Stub/FakeIdentityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading