Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[12.x] fix: intersect Authenticatable with Model in UserProvider phpdocs #54061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

calebdw
Copy link
Contributor

@calebdw calebdw commented Jan 2, 2025

Hello!

This adds the Model intersection to Authenticatable types (and visa versa) in the UserProvider phpdocs. This prevents redundant checks in user / package land to satisfy phpstan when calling methods that don't exist on the other type.

Thanks!

@taylorotwell
Copy link
Member

I'm not sure why the contract would require an Eloquent model. 🤔

@taylorotwell taylorotwell marked this pull request as draft January 2, 2025 22:57
@calebdw
Copy link
Contributor Author

calebdw commented Jan 3, 2025

@taylorotwell, these are just docblock changes so not breaking (at the moment, eventually the method signature should be updated).

Not all of the contract methods require a Model, but some do call Model methods and would failing if the intersection type is not guaranteed:

/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
* @return void
*/
public function updateRememberToken(UserContract $user, #[\SensitiveParameter] $token)
{
$user->setRememberToken($token);
$timestamps = $user->timestamps;
$user->timestamps = false;
$user->save();
$user->timestamps = $timestamps;
}

Due to this, I just updated all of them for consistency, but I can remove the intersection from the methods that don't have to have it as a parameter.

The method that particularly caused problems for me was createModel because it's not Authenticatable

@calebdw calebdw changed the base branch from 11.x to 12.x June 3, 2025 13:18
@calebdw calebdw changed the title [11.x] fix: intersect Authenticatable with Model in UserProvider phpdocs [12.x] fix: intersect Authenticatable with Model in UserProvider phpdocs Jun 3, 2025
@calebdw calebdw marked this pull request as ready for review June 3, 2025 13:18
@taylorotwell taylorotwell merged commit 70575df into laravel:12.x Jun 4, 2025
1 check passed
@calebdw calebdw deleted the auth_model branch June 4, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.