Skip to content
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

Dynamic analysis for Auth calls #326

Merged
merged 21 commits into from
Mar 4, 2023
Merged

Conversation

alies-dev
Copy link
Collaborator

@alies-dev alies-dev commented Feb 6, 2023

Fixes #184

In this PR I added 3 handlers handlers that provide types for the following cases:

// Request
$request->user();
$request->user('guard-name');

// Auth
Auth::user();

// Guard
Auth::guard('guard-name')->user();

and some other less often used.

TODO:

  • Add tests (can be tricky as I need to load custom auth.php config, any help is very welcome)
  • Consider use template syntax for Guard to infer type like:
$guard = Auth::guard('guard-name');

return $guard->user();

Previous implementation attempts:

@alies-dev alies-dev self-assigned this Feb 6, 2023
@alies-dev alies-dev changed the title Auth handlers Dynamic handlers for Auth Feb 6, 2023
@alies-dev alies-dev changed the title Dynamic handlers for Auth Dynamic analysis for Auth Feb 6, 2023
@tm1000
Copy link
Contributor

tm1000 commented Feb 6, 2023

@alies-dev alies-dev added release:feature for PRs only (used by release-drafter) release:minor for PRs only (used by release-drafter) labels Feb 14, 2023
@alies-dev alies-dev marked this pull request as ready for review February 25, 2023 00:02
@alies-dev alies-dev merged commit 11d7a5c into psalm:master Mar 4, 2023
@alies-dev alies-dev deleted the auth-handler branch March 4, 2023 19:25
@alies-dev alies-dev changed the title Dynamic analysis for Auth Dynamic analysis for Auth calls Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature for PRs only (used by release-drafter) release:minor for PRs only (used by release-drafter)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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