laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.66k stars 11.04k forks source link

[11.x] prefer `new Collection()` over `collect()` #53563

Closed browner12 closed 6 days ago

browner12 commented 1 week ago

the collect() helper is a basic wrapper for new Collection(). because there is no logic in the helper, I believe the framework should internally only use new Collection().

I'm guessing the general sentiment will be "it's fine", and I understand the performance hit is miniscule. However, I believe the framework should avoid aliases and no-logic helpers to try and have the shortest and most performant call graph it can.

this also makes DX slightly better when navigating the framework as you don't have a middleman to click through.


There is A LOT of usage of collect() in this repo. I've included a good chunk of them in this PR, but didn't want to commit the time until a decision is made on it, but will do so if it's accepted.

browner12 commented 6 days ago

great. I'll get to work tonight on replacing the remaining occurrences.

joshmanders commented 5 days ago

@browner12 doing gods work