From 458fbafba44c2b1c7780adca996e204218f39839 Mon Sep 17 00:00:00 2001 From: mpyw Date: Mon, 13 Mar 2023 15:57:06 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20Drop=20support=20for=20?= =?UTF-8?q?stale=20versions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 18 ++++-------- .gitignore | 3 +- README.md | 4 +-- composer.json | 10 +++---- phpunit.xml | 21 ++++---------- src/Concerns/GuardsNothing.php | 10 ++----- src/Concerns/HasEloquentIdentifier.php | 8 ++--- src/Concerns/HasEloquentPassword.php | 4 +-- src/Concerns/ProvidesNothing.php | 29 ++++++------------- src/Concerns/RequiresIdentifier.php | 8 ++--- src/GenericNullAuthenticatable.php | 17 ++++------- src/GenericStrictNullAuthenticatable.php | 12 +++----- src/NullAuthServiceProvider.php | 13 ++------- src/UnsetsUser.php | 2 +- tests/TestCase.php | 5 ++-- .../NoRememberTokenAuthenticatableTest.php | 5 +--- tests/Unit/NullAuthenticatableTest.php | 5 +--- tests/Unit/NullGuardTest.php | 7 ++--- tests/Unit/NullUserProviderTest.php | 6 ++-- 19 files changed, 57 insertions(+), 130 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50cab43..ee1d571 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,23 +8,15 @@ jobs: strategy: matrix: - php: [7.3, 7.4, '8.0', 8.1] + php: ['8.0', 8.1, 8.2] lib: + - { laravel: ^11.0 } - { laravel: ^10.0 } - { laravel: ^9.0 } - - { laravel: ^8.0 } - - { laravel: ^7.0 } - - { laravel: ^6.0 } - - { laravel: ^6.0, flags: --prefer-lowest } exclude: - - { php: 8.1, lib: { laravel: ^7.0 } } - - { php: 8.1, lib: { laravel: ^6.0 } } - - { php: 8.1, lib: { laravel: ^6.0, flags: --prefer-lowest } } - { php: 8.0, lib: { laravel: ^10.0 } } - - { php: 7.4, lib: { laravel: ^10.0 } } - - { php: 7.4, lib: { laravel: ^9.0 } } - - { php: 7.3, lib: { laravel: ^10.0 } } - - { php: 7.3, lib: { laravel: ^9.0 } } + - { php: 8.0, lib: { laravel: ^11.0 } } + - { php: 8.1, lib: { laravel: ^11.0 } } steps: - uses: actions/checkout@v2 @@ -35,7 +27,7 @@ jobs: php-version: ${{ matrix.php }} coverage: xdebug - - run: composer require "laravel/framework:${{ matrix.lib.laravel }}" --dev ${{ matrix.lib.flags }} + - run: composer require "laravel/framework:${{ matrix.lib.laravel }}" --dev - run: mkdir -p build/logs - run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml diff --git a/.gitignore b/.gitignore index b2c15b6..cd68c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ +/.idea/ /vendor/ .php_cs.cache -.phpunit.result.cache +/.phpunit.cache/ composer.lock diff --git a/README.md b/README.md index 9b47fb9..b8a7930 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Null Guard for Laravel. Designed for Middleware-based authentication and testing ## Requirements -- PHP: `^7.3 || ^8.0` -- Laravel: `^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0` +- PHP: `^8.0` +- Laravel: `^9.0 || ^10.0` ## Installing diff --git a/composer.json b/composer.json index 743d9aa..b1728dd 100644 --- a/composer.json +++ b/composer.json @@ -21,14 +21,14 @@ } }, "require": { - "php": "^7.3 || ^8.0", - "illuminate/auth": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0", - "illuminate/contracts": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0", - "illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0" + "php": "^8.0", + "illuminate/auth": "^9.0 || ^10.0 || ^11.0", + "illuminate/contracts": "^9.0 || ^10.0 || ^11.0", + "illuminate/support": "^9.0 || ^10.0 || ^11.0" }, "require-dev": { "orchestra/testbench": "*", - "orchestra/testbench-core": "^4.9 || ^5.9 || >=6.6", + "orchestra/testbench-core": ">=7.0", "phpunit/phpunit": ">=9.5", "mockery/mockery": "^1.3.3 || ^1.4.2" }, diff --git a/phpunit.xml b/phpunit.xml index f3db8cf..e0e3371 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,13 @@ - + + + + src + + ./tests/ - - - src - - diff --git a/src/Concerns/GuardsNothing.php b/src/Concerns/GuardsNothing.php index 861adfa..2403d92 100644 --- a/src/Concerns/GuardsNothing.php +++ b/src/Concerns/GuardsNothing.php @@ -3,6 +3,7 @@ namespace Mpyw\NullAuth\Concerns; use Illuminate\Auth\GuardHelpers; +use Illuminate\Contracts\Auth\Authenticatable; trait GuardsNothing { @@ -10,21 +11,16 @@ trait GuardsNothing /** * Get the currently authenticated user. - * - * @return null|\Illuminate\Contracts\Auth\Authenticatable */ - public function user() + public function user(): ?Authenticatable { return $this->user; } /** * Validate a user's credentials. - * - * @param array $credentials - * @return bool */ - public function validate(array $credentials = []) + public function validate(array $credentials = []): bool { return false; } diff --git a/src/Concerns/HasEloquentIdentifier.php b/src/Concerns/HasEloquentIdentifier.php index 403e06b..726e291 100644 --- a/src/Concerns/HasEloquentIdentifier.php +++ b/src/Concerns/HasEloquentIdentifier.php @@ -11,20 +11,16 @@ trait HasEloquentIdentifier { /** * Get the name of the unique identifier for the user. - * - * @return string */ - public function getAuthIdentifierName() + public function getAuthIdentifierName(): string { return $this->getKeyName(); } /** * Get the unique identifier for the user. - * - * @return mixed */ - public function getAuthIdentifier() + public function getAuthIdentifier(): mixed { return $this->{$this->getKeyName()}; } diff --git a/src/Concerns/HasEloquentPassword.php b/src/Concerns/HasEloquentPassword.php index 757ec7e..068d0cf 100644 --- a/src/Concerns/HasEloquentPassword.php +++ b/src/Concerns/HasEloquentPassword.php @@ -11,10 +11,8 @@ trait HasEloquentPassword { /** * Get the unique identifier for the user. - * - * @return mixed */ - public function getAuthPassword() + public function getAuthPassword(): mixed { return $this->getAttribute('password'); } diff --git a/src/Concerns/ProvidesNothing.php b/src/Concerns/ProvidesNothing.php index a4ac023..1a7c248 100644 --- a/src/Concerns/ProvidesNothing.php +++ b/src/Concerns/ProvidesNothing.php @@ -9,10 +9,9 @@ trait ProvidesNothing /** * Retrieve a user by their unique identifier. * - * @param mixed $identifier - * @return null|\Illuminate\Contracts\Auth\Authenticatable + * @param mixed $identifier */ - public function retrieveById($identifier) + public function retrieveById($identifier): ?Authenticatable { return null; } @@ -20,11 +19,10 @@ public function retrieveById($identifier) /** * Retrieve a user by their unique identifier and "remember me" token. * - * @param mixed $identifier - * @param string $token - * @return null|\Illuminate\Contracts\Auth\Authenticatable + * @param mixed $identifier + * @param string $token */ - public function retrieveByToken($identifier, $token) + public function retrieveByToken($identifier, $token): ?Authenticatable { return null; } @@ -32,33 +30,24 @@ public function retrieveByToken($identifier, $token) /** * Update the "remember me" token for the given user in storage. * - * @param \Illuminate\Contracts\Auth\Authenticatable $user - * @param string $token - * @return void + * @param string $token */ - public function updateRememberToken(Authenticatable $user, $token) + public function updateRememberToken(Authenticatable $user, $token): void { } /** * Retrieve a user by the given credentials. - * - * @param array $credentials - * @return null|\Illuminate\Contracts\Auth\Authenticatable */ - public function retrieveByCredentials(array $credentials) + public function retrieveByCredentials(array $credentials): ?Authenticatable { return null; } /** * Validate a user against the given credentials. - * - * @param \Illuminate\Contracts\Auth\Authenticatable $user - * @param array $credentials - * @return bool */ - public function validateCredentials(Authenticatable $user, array $credentials) + public function validateCredentials(Authenticatable $user, array $credentials): bool { return false; } diff --git a/src/Concerns/RequiresIdentifier.php b/src/Concerns/RequiresIdentifier.php index 3e3c788..19c7d37 100644 --- a/src/Concerns/RequiresIdentifier.php +++ b/src/Concerns/RequiresIdentifier.php @@ -6,15 +6,11 @@ trait RequiresIdentifier { /** * Get the name of the unique identifier for the user. - * - * @return string */ - abstract public function getAuthIdentifierName(); + abstract public function getAuthIdentifierName(): string; /** * Get the unique identifier for the user. - * - * @return mixed */ - abstract public function getAuthIdentifier(); + abstract public function getAuthIdentifier(): mixed; } diff --git a/src/GenericNullAuthenticatable.php b/src/GenericNullAuthenticatable.php index 8fa69e2..5453f15 100644 --- a/src/GenericNullAuthenticatable.php +++ b/src/GenericNullAuthenticatable.php @@ -8,20 +8,16 @@ trait GenericNullAuthenticatable /** * Get the password for the user. - * - * @return string */ - public function getAuthPassword() + public function getAuthPassword(): string { return ''; } /** * Get the token value for the "remember me" session. - * - * @return string */ - public function getRememberToken() + public function getRememberToken(): string { return ''; } @@ -29,19 +25,16 @@ public function getRememberToken() /** * Set the token value for the "remember me" session. * - * @param string $value - * @return void + * @param string $value */ - public function setRememberToken($value) + public function setRememberToken($value): void { } /** * Get the column name for the "remember me" token. - * - * @return string */ - public function getRememberTokenName() + public function getRememberTokenName(): string { return ''; } diff --git a/src/GenericStrictNullAuthenticatable.php b/src/GenericStrictNullAuthenticatable.php index 581c104..48c73ac 100644 --- a/src/GenericStrictNullAuthenticatable.php +++ b/src/GenericStrictNullAuthenticatable.php @@ -10,20 +10,16 @@ trait GenericStrictNullAuthenticatable /** * Get the password for the user. - * - * @return string */ - public function getAuthPassword() + public function getAuthPassword(): string { throw new BadMethodCallException('Not implemented'); } /** * Get the token value for the "remember me" session. - * - * @return string */ - public function getRememberToken() + public function getRememberToken(): string { throw new BadMethodCallException('Not implemented'); } @@ -33,7 +29,7 @@ public function getRememberToken() * * @param string $value */ - public function setRememberToken($value) + public function setRememberToken($value): void { throw new BadMethodCallException('Not implemented'); } @@ -43,7 +39,7 @@ public function setRememberToken($value) * * @return string */ - public function getRememberTokenName() + public function getRememberTokenName(): string { throw new BadMethodCallException('Not implemented'); } diff --git a/src/NullAuthServiceProvider.php b/src/NullAuthServiceProvider.php index 921c004..466dc2f 100644 --- a/src/NullAuthServiceProvider.php +++ b/src/NullAuthServiceProvider.php @@ -9,12 +9,7 @@ class NullAuthServiceProvider extends ServiceProvider { - /** @noinspection PhpDocMissingThrowsInspection */ - - /** - * @return void - */ - public function register() + public function register(): void { /* @noinspection PhpUnhandledExceptionInspection */ $this->app->resolved(AuthManager::class) @@ -22,11 +17,7 @@ public function register() : $this->app->afterResolving(AuthManager::class, Closure::fromCallable([$this, 'extendComponents'])); } - /** - * @param \Illuminate\Auth\AuthManager $auth - * @return void - */ - protected function extendComponents(AuthManager $auth) + protected function extendComponents(AuthManager $auth): void { $auth->extend('null', function (Container $app, string $name, array $config) use ($auth) { $guard = new NullGuard(); diff --git a/src/UnsetsUser.php b/src/UnsetsUser.php index 3ee2fea..113d9bf 100644 --- a/src/UnsetsUser.php +++ b/src/UnsetsUser.php @@ -15,7 +15,7 @@ trait UnsetsUser * * @return $this */ - public function unsetUser() + public function unsetUser(): static { $this->user = null; diff --git a/tests/TestCase.php b/tests/TestCase.php index 6dd42af..24802f1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -8,10 +8,9 @@ class TestCase extends BaseTestCase { /** - * @param \Illuminate\Foundation\Application $app - * @return array + * @param \Illuminate\Foundation\Application $app */ - protected function getPackageProviders($app) + protected function getPackageProviders($app): array { return [ NullAuthServiceProvider::class, diff --git a/tests/Unit/NoRememberTokenAuthenticatableTest.php b/tests/Unit/NoRememberTokenAuthenticatableTest.php index 8051357..df26dbf 100644 --- a/tests/Unit/NoRememberTokenAuthenticatableTest.php +++ b/tests/Unit/NoRememberTokenAuthenticatableTest.php @@ -10,10 +10,7 @@ class NoRememberTokenAuthenticatableTest extends TestCase { - /** - * @var array - */ - protected $attributes; + protected array $attributes; /** * @var \Illuminate\Auth\GenericUser|\Mpyw\NullAuth\NoRememberTokenAuthenticatable diff --git a/tests/Unit/NullAuthenticatableTest.php b/tests/Unit/NullAuthenticatableTest.php index f7909f9..8f427c6 100644 --- a/tests/Unit/NullAuthenticatableTest.php +++ b/tests/Unit/NullAuthenticatableTest.php @@ -10,10 +10,7 @@ class NullAuthenticatableTest extends TestCase { - /** - * @var array - */ - protected $attributes; + protected array $attributes; /** * @var \Illuminate\Auth\GenericUser|\Mpyw\NullAuth\NullAuthenticatable diff --git a/tests/Unit/NullGuardTest.php b/tests/Unit/NullGuardTest.php index d773c20..8931c14 100644 --- a/tests/Unit/NullGuardTest.php +++ b/tests/Unit/NullGuardTest.php @@ -4,6 +4,7 @@ use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\GenericUser; +use Illuminate\Contracts\Auth\Authenticatable; use Mockery; use Mpyw\NullAuth\NullGuard; use Mpyw\NullAuth\Tests\TestCase; @@ -14,11 +15,7 @@ class NullGuardTest extends TestCase * @var \Illuminate\Auth\GuardHelpers|\Illuminate\Contracts\Auth\Guard|\Mpyw\NullAuth\NullGuard */ protected $guard; - - /** - * @var \Illuminate\Contracts\Auth\Authenticatable - */ - protected $user; + protected Authenticatable $user; public function setUp(): void { diff --git a/tests/Unit/NullUserProviderTest.php b/tests/Unit/NullUserProviderTest.php index c7f0086..d1a1389 100644 --- a/tests/Unit/NullUserProviderTest.php +++ b/tests/Unit/NullUserProviderTest.php @@ -3,15 +3,13 @@ namespace Mpyw\NullAuth\Tests\Unit; use Illuminate\Auth\GenericUser; +use Illuminate\Contracts\Auth\UserProvider; use Mpyw\NullAuth\NullUserProvider; use Mpyw\NullAuth\Tests\TestCase; class NullUserProviderTest extends TestCase { - /** - * @var \Illuminate\Contracts\Auth\UserProvider - */ - protected $provider; + protected UserProvider $provider; public function testGetAuthP(): void {