-
Notifications
You must be signed in to change notification settings - Fork 71
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
Use config('auth.providers.user') for return type of Auth::user() and Request::user() #184
Comments
Huh, I thought ide-helper already provided this functionality! |
@mr-feek it does but the issue is that Psalm gets confused and also reads |
I think I'm going to add in some dynamic analysis to stricten the return type of the We already do dynamic analysis for resolving container types -- it could also prove beneficial for resolving this issue |
@mr-feek sounds good to me I haven't gotten back to this because the tests are extremely complicated for this project. I only learned how they worked from the work on the 9.x release so I think I can actually get back to written a test here |
Feel free to take a look at #229 and https://github.com/nunomaduro/larastan/blob/master/src/Concerns/LoadsAuthModel.php for inspiration! |
Is your feature request related to a problem? Please describe.
According to PHPDoc:
Illuminate\Support\Facades\Auth::user()
returns\Illuminate\Contracts\Auth\Authenticatable|null
Illuminate\Http\Request::user()
returnsmixed
However, if
providers.users.driver
is set toeloquent
inconfig/auth.php
, they return the model configured inproviders.users.model
, which defaults to:Describe the solution you'd like
The Psalm plugin should use that config to determine (and narrow) the return type of
Auth::user()
and$request->user()
.Describe alternatives you've considered
(None.)
Additional context
(None.)
The text was updated successfully, but these errors were encountered: