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

[8.x] Restore auto-complete functionality on when and unless #38018

Merged
merged 3 commits into from
Jul 15, 2021

Conversation

deleugpn
Copy link
Contributor

Looks like when the Conditionable trait was merged, we lost the ability to get autocompletion from PHPStorm when doing $eloquent->newQuery()->when(...)->chain()->anotherChain()->get() because of the mixed return type.

I have not verified, but as far as I remember the goal with a Conditionable trait was consistency across the framework, in which case they're likely returning $this for chain capabilities.

@inxilpro
Copy link
Contributor

I think a return type of $this|mixed might be more appropriate, because when() isn't guaranteed to return $this — it depends on what you return from your callback.

@driesvints
Copy link
Member

mixed is the correct return type here. The callbacks can return anything imaginable. You need to type-check in userland. $this|mixed is invalid as mixed already includes $this.

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