Skip to content

Commit

Permalink
fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bert-w committed Jul 15, 2024
1 parent 28c6b82 commit 757e7c2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 34 deletions.
19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ parameters:
count: 1
path: src/FilamentSocialitePlugin.php

-
message: "#^Property DutchCodingCompany\\\\FilamentSocialite\\\\FilamentSocialitePlugin\\:\\:\\$userModelClass \\(class\\-string\\<Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable\\>\\) does not accept default value of type string\\.$#"
count: 1
path: src/FilamentSocialitePlugin.php

-
message: "#^Parameter \\#1 \\$value of method DutchCodingCompany\\\\FilamentSocialite\\\\Http\\\\Controllers\\\\SocialiteLoginController\\:\\:evaluate\\(\\) expects bool\\|\\(callable\\(\\)\\: bool\\), bool\\|\\(Closure\\(string, Laravel\\\\Socialite\\\\Contracts\\\\User, Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable\\|null\\)\\: bool\\) given\\.$#"
count: 1
Expand Down
6 changes: 2 additions & 4 deletions src/Models/SocialiteUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use DutchCodingCompany\FilamentSocialite\FilamentSocialitePlugin;
use DutchCodingCompany\FilamentSocialite\Models\Contracts\FilamentSocialiteUser as FilamentSocialiteUserContract;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Laravel\Socialite\Contracts\User as SocialiteUserContract;
Expand All @@ -14,19 +13,18 @@
* @property int $user_id
* @property string $provider
* @property int $provider_id
* @property \Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable $user
*/
class SocialiteUser extends Model implements FilamentSocialiteUserContract
{
use HasFactory;

protected $fillable = [
'user_id',
'provider',
'provider_id',
];

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable, self>
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Illuminate\Database\Eloquent\Model, $this>
*/
public function user(): BelongsTo
{
Expand Down
13 changes: 8 additions & 5 deletions src/Traits/Models.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
trait Models
{
/**
* @var class-string<\Illuminate\Contracts\Auth\Authenticatable>
* @var ?class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable>
*/
protected string $userModelClass = User::class;
protected ?string $userModelClass = null;

/**
* @var class-string<\DutchCodingCompany\FilamentSocialite\Models\Contracts\FilamentSocialiteUser>
*/
protected string $socialiteUserModelClass = SocialiteUser::class;

/**
* @param class-string<\Illuminate\Contracts\Auth\Authenticatable> $value
* @param class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable> $value
* @throws ImplementationException
*/
public function userModelClass(string $value): static
Expand All @@ -36,11 +36,14 @@ public function userModelClass(string $value): static
}

/**
* @return class-string<\Illuminate\Contracts\Auth\Authenticatable>
* @return class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable>
*/
public function getUserModelClass(): string
{
return $this->userModelClass;
/** @var class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable> */
$user = User::class;

return $this->userModelClass ?? $user;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class TestCase extends Orchestra
{
/**
* @var class-string<\Illuminate\Contracts\Auth\Authenticatable>
* @var class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable>
*/
protected string $userModelClass = TestUser::class;

Expand Down

0 comments on commit 757e7c2

Please sign in to comment.