Skip to content

Use config('auth.providers.user') for return type of Auth::user() and Request::user() #184

Closed
@caugner

Description

@caugner

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() returns mixed

However, if providers.users.driver is set to eloquent in config/auth.php, they return the model configured in providers.users.model, which defaults to:

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\User::class,
        ],

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.)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions