Skip to content

Commit

Permalink
simplify type to Authenticatable
Browse files Browse the repository at this point in the history
  • Loading branch information
bert-w committed Feb 27, 2024
1 parent 2d4f95e commit 423810b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
ignoreErrors:
-
message: "#^Property 'email' does not exist in Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable&Illuminate\\\\Database\\\\Eloquent\\\\Model model\\.$#"
count: 1
count: 2
path: src/FilamentSocialite.php

-
Expand All @@ -16,6 +16,6 @@ parameters:
path: src/FilamentSocialitePlugin.php

-
message: "#^Property DutchCodingCompany\\\\FilamentSocialite\\\\FilamentSocialitePlugin\\:\\:\\$userModelClass \\(class\\-string\\<Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable&Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\) does not accept default value of type string\\.$#"
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
14 changes: 7 additions & 7 deletions src/FilamentSocialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public function getOptionalParameters(string $provider): array
}

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

public function getUserModel(): Model & Authenticatable
public function getUserModel(): Authenticatable
{
return new ($this->getUserModelClass());
}
Expand All @@ -95,13 +95,13 @@ public function getUserModel(): Model & Authenticatable
public function getUserResolver(): Closure
{
return $this->userResolver ?? function (string $provider, SocialiteUserContract $oauthUser, FilamentSocialite $socialite) {
/** @var \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable> $query */
$query = $this->getUserModel()->where(
/** @var \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable> $model */
$model = $this->getUserModel();

return $model->where(
'email',
$oauthUser->getEmail()
);

return $query->first();
)->first();
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/FilamentSocialitePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FilamentSocialitePlugin implements Plugin
protected array $domainAllowList = [];

/**
* @var class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable>
* @var class-string<\Illuminate\Contracts\Auth\Authenticatable>
*/
protected string $userModelClass = User::class;

Expand Down Expand Up @@ -159,7 +159,7 @@ public function getDomainAllowList(): array
}

/**
* @param class-string<\Illuminate\Database\Eloquent\Model&\Illuminate\Contracts\Auth\Authenticatable> $value
* @param class-string<\Illuminate\Contracts\Auth\Authenticatable> $value
*/
public function setUserModelClass(string $value): static
{
Expand All @@ -173,7 +173,7 @@ public function setUserModelClass(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

0 comments on commit 423810b

Please sign in to comment.