[9.x] Uses generic collections on Eloquent\Model::class
#38575
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: this pull request is waiting for a PHPStan release
This pull request makes
Eloquent\Model::class
to use generic collections (#38538). In other words, the goal is simply search forCollection
, and add the information - regarding generics - to those annotations. Of course, the benefit is, at some point, have auto-completion/static analysis support on code like:Also, in the process, and thanks the
@mixin
annotation on theEloquent\Model::class
, without the IDE Helper, PHPStorm is able to understand a little bit more of the Model Builder class:Finally, at this point, is worth waiting for having PHPStorm understand generics before moving forward. If we go deeper on eloquent - as we did with collections (fully type arguments, etc ) - we actually take the risk of losing some auto-completion.