Skip to content

Commit

Permalink
use larastan
Browse files Browse the repository at this point in the history
  • Loading branch information
bert-w committed Feb 27, 2024
1 parent 423810b commit 51a5d7f
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 33 deletions.
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
18 changes: 9 additions & 9 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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\\<Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable\\>\\) 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\\<Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable\\>\\) does not accept default value of type string\\.$#"
message: "#^Parameter \\#1 \\$callback of static method Illuminate\\\\Database\\\\Eloquent\\\\Factories\\\\Factory\\<Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\:\\:guessFactoryNamesUsing\\(\\) expects callable\\(class\\-string\\<Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\)\\: class\\-string\\<Illuminate\\\\Database\\\\Eloquent\\\\Factories\\\\Factory\\>, Closure\\(string\\)\\: non\\-falsy\\-string given\\.$#"
count: 1
path: src/FilamentSocialitePlugin.php
path: tests/TestCase.php
13 changes: 0 additions & 13 deletions phpstan.neon.dist

This file was deleted.

9 changes: 9 additions & 0 deletions src/FilamentSocialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public function isProviderConfigured(string $provider): bool
return $this->config->has('services.'.$provider);
}

/**
* @return array<string, mixed>
*/
public function getProviderConfig(string $provider): array
{
if (! $this->isProviderConfigured($provider)) {
Expand All @@ -66,11 +69,17 @@ public function getProviderConfig(string $provider): array
return $this->config->get('services.'.$provider);
}

/**
* @return string|array<string>
*/
public function getProviderScopes(string $provider): string | array
{
return $this->getProviderConfig($provider)['scopes'] ?? [];
}

/**
* @return array<string, mixed>
*/
public function getOptionalParameters(string $provider): array
{
return $this->getProviderConfig($provider)['with'] ?? [];
Expand Down
18 changes: 18 additions & 0 deletions src/FilamentSocialitePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

class FilamentSocialitePlugin implements Plugin
{
/**
* @var array<string, mixed>
*/
protected array $providers = [];

protected ?string $loginRouteName = null;
Expand All @@ -23,6 +26,9 @@ class FilamentSocialitePlugin implements Plugin

protected bool $registrationEnabled = false;

/**
* @var array<string>
*/
protected array $domainAllowList = [];

/**
Expand Down Expand Up @@ -69,13 +75,19 @@ public function boot(Panel $panel): void
//
}

/**
* @param array<string, mixed> $providers
*/
public function setProviders(array $providers): static
{
$this->providers = $providers;

return $this;
}

/**
* @return array<string, mixed>
*/
public function getProviders(): array
{
return $this->providers;
Expand Down Expand Up @@ -146,13 +158,19 @@ public function getRegistrationEnabled(): bool
return $this->registrationEnabled;
}

/**
* @param array<string> $values
*/
public function setDomainAllowList(array $values): static
{
$this->domainAllowList = $values;

return $this;
}

/**
* @return array<string>
*/
public function getDomainAllowList(): array
{
return $this->domainAllowList;
Expand Down
10 changes: 5 additions & 5 deletions tests/Fixtures/TestUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -38,6 +38,6 @@ public function setRememberToken($value)

public function getRememberTokenName()
{
//
return 'test-user-remember-token-name';
}
}
4 changes: 2 additions & 2 deletions tests/Fixtures/create_socialite_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -23,7 +23,7 @@ public function up()
});
}

public function down()
public function down(): void
{
Schema::dropIfExists('socialite_users');
}
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 51a5d7f

Please sign in to comment.