[11.x] always alias the Illuminate\Database\Eloquent\Collection
#53735
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.
while there is no behavior change in this commit, my intent behind this is to help prevent stupid mistakes from assuming what Collection is being referenced. by always aliasing this class explicitly, we gain a little confidence when in the code about what version we are referencing.
our use of
Illuminate\Support\Collection
far outweighs our use ofIlluminate\Database\Eloquent\Collection
. however, it's very common for both to be used in a file that usesIlluminate\Database\Eloquent\Collection
. therefore, I say we treat the base Collection as the default, and our Eloquent Collection as our alias ALL the time. this will provide consistency and help avoid stupid mistakes.it is also helpful when doing global searches because now we have a unique token to search for.
this idea came to me as I was working on #53726 because making sure I was referencing the correct Collection was the gotcha I had to pay the closest attention to.