Skip to content

Conversation

@mpyw
Copy link
Contributor

@mpyw mpyw commented Oct 12, 2021

The following PR by @TBlindaruk has been previously rejected at v5.8.

However, we are now at a new stage with many changes, such as introducing Contract on Query Builder implementation. I decided that it would be ready to resubmit this PR now. It is useful in some situations that knowing whether user() causes side effects in advance.

Note that we don't have to add setProvider() and getProvider() because they are mainly for internal use.

Breaking Changes

  • All custom Guard without GuardHelpers should explicitly implement hasUser() from now on.
    • Most Guard implementation which uses property caching should return ! is_null($this->user)
    • Guard without any caches should always return false

- #24518 in this PR was added method `hasUser` to the GuardHelper trait. As for me it will be useful to have this method in the contract.
@driesvints
Copy link
Member

driesvints commented Oct 12, 2021

I think we can rename this to a more applicable method like checkSilently and then add that as an alias on the GuardHelpers trait.

I do have to say that ideally, I wish check didn't produce any side effects. But it's too much of a breaking change probably to change that now.

@mpyw
Copy link
Contributor Author

mpyw commented Oct 12, 2021

@taylorotwell Hi! Do you have any ideas about renaming hasUser()?

@taylorotwell taylorotwell merged commit 438eba7 into laravel:master Oct 12, 2021
@mpyw mpyw deleted the feat/9.x/gurad-contract-has-user branch October 12, 2021 15:47
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.

4 participants