Skip to content

Commit

Permalink
simplify phpstan (allow custom Authenticatable)
Browse files Browse the repository at this point in the history
  • Loading branch information
bert-w committed Jul 15, 2024
1 parent 757e7c2 commit 7b58bc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/Models/SocialiteUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* @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
{
Expand All @@ -28,7 +27,10 @@ class SocialiteUser extends Model implements FilamentSocialiteUserContract
*/
public function user(): BelongsTo
{
return $this->belongsTo(FilamentSocialitePlugin::current()->getUserModelClass());
/** @var class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable> */
$user = FilamentSocialitePlugin::current()->getUserModelClass();

return $this->belongsTo($user);
}

public function getUser(): Authenticatable
Expand Down
6 changes: 3 additions & 3 deletions src/Traits/Models.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
trait Models
{
/**
* @var ?class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable>
* @var ?class-string<\Illuminate\Contracts\Auth\Authenticatable>
*/
protected ?string $userModelClass = null;

Expand All @@ -21,7 +21,7 @@ trait Models
protected string $socialiteUserModelClass = SocialiteUser::class;

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

/**
* @return class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable>
* @return class-string<\Illuminate\Contracts\Auth\Authenticatable>
*/
public function getUserModelClass(): string
{
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\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable>
* @var class-string<\Illuminate\Contracts\Auth\Authenticatable>
*/
protected string $userModelClass = TestUser::class;

Expand Down

0 comments on commit 7b58bc6

Please sign in to comment.