diff --git a/composer.json b/composer.json index 7ecdaf5..9cfc800 100644 --- a/composer.json +++ b/composer.json @@ -34,12 +34,10 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.8", + "larastan/larastan": "^2.9", "nunomaduro/collision": "^7.0", "nunomaduro/larastan": "^2.0.1", "orchestra/testbench": "^8.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^10.0" }, "suggest": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f9eb82f..8767e19 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,21 +1,21 @@ parameters: ignoreErrors: - - message: "#^Property 'email' does not exist in Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable&Illuminate\\\\Database\\\\Eloquent\\\\Model model\\.$#" - count: 2 - path: src/FilamentSocialite.php + message: "#^Class App\\\\Models\\\\User not found\\.$#" + count: 1 + path: src/FilamentSocialitePlugin.php - - message: "#^Property 'name' does not exist in Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable&Illuminate\\\\Database\\\\Eloquent\\\\Model model\\.$#" + message: "#^Property DutchCodingCompany\\\\FilamentSocialite\\\\FilamentSocialitePlugin\\:\\:\\$userModelClass \\(class\\-string\\\\) does not accept default value of type string\\.$#" count: 1 - path: src/FilamentSocialite.php + path: src/FilamentSocialitePlugin.php - - message: "#^Class App\\\\Models\\\\User not found\\.$#" + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:andReturn\\(\\)\\.$#" count: 1 - path: src/FilamentSocialitePlugin.php + path: tests/SocialiteLoginTest.php - - message: "#^Property DutchCodingCompany\\\\FilamentSocialite\\\\FilamentSocialitePlugin\\:\\:\\$userModelClass \\(class\\-string\\\\) does not accept default value of type string\\.$#" + message: "#^Parameter \\#1 \\$callback of static method Illuminate\\\\Database\\\\Eloquent\\\\Factories\\\\Factory\\\\:\\:guessFactoryNamesUsing\\(\\) expects callable\\(class\\-string\\\\)\\: class\\-string\\, Closure\\(string\\)\\: non\\-falsy\\-string given\\.$#" count: 1 - path: src/FilamentSocialitePlugin.php + path: tests/TestCase.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist deleted file mode 100644 index 81595c9..0000000 --- a/phpstan.neon.dist +++ /dev/null @@ -1,13 +0,0 @@ -includes: - - phpstan-baseline.neon - -parameters: - level: 7 - paths: - - src - - config - - database - tmpDir: build/phpstan - checkOctaneCompatibility: true - checkModelProperties: true - checkMissingIterableValueType: false diff --git a/src/FilamentSocialite.php b/src/FilamentSocialite.php index fb51be8..ca038d9 100755 --- a/src/FilamentSocialite.php +++ b/src/FilamentSocialite.php @@ -57,6 +57,9 @@ public function isProviderConfigured(string $provider): bool return $this->config->has('services.'.$provider); } + /** + * @return array + */ public function getProviderConfig(string $provider): array { if (! $this->isProviderConfigured($provider)) { @@ -66,11 +69,17 @@ public function getProviderConfig(string $provider): array return $this->config->get('services.'.$provider); } + /** + * @return string|array + */ public function getProviderScopes(string $provider): string | array { return $this->getProviderConfig($provider)['scopes'] ?? []; } + /** + * @return array + */ public function getOptionalParameters(string $provider): array { return $this->getProviderConfig($provider)['with'] ?? []; diff --git a/src/FilamentSocialitePlugin.php b/src/FilamentSocialitePlugin.php index faa72d9..4d6ec0e 100644 --- a/src/FilamentSocialitePlugin.php +++ b/src/FilamentSocialitePlugin.php @@ -13,6 +13,9 @@ class FilamentSocialitePlugin implements Plugin { + /** + * @var array + */ protected array $providers = []; protected ?string $loginRouteName = null; @@ -23,6 +26,9 @@ class FilamentSocialitePlugin implements Plugin protected bool $registrationEnabled = false; + /** + * @var array + */ protected array $domainAllowList = []; /** @@ -69,6 +75,9 @@ public function boot(Panel $panel): void // } + /** + * @param array $providers + */ public function setProviders(array $providers): static { $this->providers = $providers; @@ -76,6 +85,9 @@ public function setProviders(array $providers): static return $this; } + /** + * @return array + */ public function getProviders(): array { return $this->providers; @@ -146,6 +158,9 @@ public function getRegistrationEnabled(): bool return $this->registrationEnabled; } + /** + * @param array $values + */ public function setDomainAllowList(array $values): static { $this->domainAllowList = $values; @@ -153,6 +168,9 @@ public function setDomainAllowList(array $values): static return $this; } + /** + * @return array + */ public function getDomainAllowList(): array { return $this->domainAllowList; diff --git a/tests/Fixtures/TestUser.php b/tests/Fixtures/TestUser.php index b9de07a..ea245d1 100644 --- a/tests/Fixtures/TestUser.php +++ b/tests/Fixtures/TestUser.php @@ -13,22 +13,22 @@ class TestUser extends Model implements Authenticatable public function getAuthIdentifierName() { - // + return 'test-user-auth-identifier-name'; } public function getAuthIdentifier() { - // + return 'test-user-auth-identifier'; } public function getAuthPassword() { - // + return 'test-user-auth-password'; } public function getRememberToken() { - // + return 'test-user-remember-token'; } public function setRememberToken($value) @@ -38,6 +38,6 @@ public function setRememberToken($value) public function getRememberTokenName() { - // + return 'test-user-remember-token-name'; } } diff --git a/tests/Fixtures/create_socialite_users_table.php b/tests/Fixtures/create_socialite_users_table.php index d71e21f..cafb212 100644 --- a/tests/Fixtures/create_socialite_users_table.php +++ b/tests/Fixtures/create_socialite_users_table.php @@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Schema; return new class() extends Migration { - public function up() + public function up(): void { Schema::create('socialite_users', function (Blueprint $table) { $table->id(); @@ -23,7 +23,7 @@ public function up() }); } - public function down() + public function down(): void { Schema::dropIfExists('socialite_users'); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 12b7343..bf70706 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -15,6 +15,7 @@ use Illuminate\Encryption\Encrypter; use Illuminate\Foundation\Testing\LazilyRefreshDatabase; use Illuminate\Session\Middleware\StartSession; +use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Schema; use Laravel\Socialite\SocialiteServiceProvider; use Livewire\LivewireServiceProvider; @@ -105,7 +106,7 @@ protected function defineDatabaseMigrations() $this->loadLaravelMigrations(); $this->loadMigrationsFrom(__DIR__.'/Fixtures'); - $this->artisan('migrate', ['--database' => 'testing'])->run(); + Artisan::call('migrate', ['--database' => 'testing']); Schema::table('users', static function (Blueprint $table): void { $table->string('password')->nullable()->change();