Skip to content

auth() helper return type #56783

@rcerljenko

Description

@rcerljenko

Laravel Version

12.26.2

PHP Version

8.4.11

Database Driver & Version

No response

Description

I have a custom auth guard which wraps up this library into the laravel auth flow.
It implements the Guard interface (not Stateful, just basic Guard).
Custom guard is registered via extend method in the AuthServiceProvider.

With latest update, auth() is fully return-typed now but for some reason it always expects to return the StatefulGuard which my custom guard is not.

Error message returned when pest-ing the code:

auth(): Return value must be of type Illuminate\Contracts\Auth\Factory|Illuminate\Contracts\Auth\StatefulGuard, App\Services\Auth\PasetoGuard returned

Steps To Reproduce

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions