driftingly / rector-laravel

Rector upgrades rules for Laravel
http://getrector.org
MIT License
469 stars 48 forks source link

laravel54 every => nth breaks modern use of Collection::every #186

Closed hackel closed 4 months ago

hackel commented 5 months ago

On my Laravel 10 project, I've enabled the LaravelLevelSetList::UP_TO_LARAVEL_100 set. (Please tell me if that's not the right way to use this package.)

In the laravel54 rules, it renames uses of Collection::every to Collection::nth. I'm sure this was appropriate for Laravel 5.4, but Collection has since added a new every method which is completely different from the nth method. I have had to disable the set in the meantime.

driftingly commented 4 months ago

Thanks for reporting.

The Laravel 5.4 rules follow the Laravel 5.4 upgrade guide:

The every Method The behavior of the every method has been moved to the nth method to match the method name defined by Lodash.

This is not what you want on a Laravel 10 app.

I'm sure there are/will be more instances of conflicting rules designed for older versions of Laravel.

We'll have to figure out ways of checking current versions, or maybe deprecating some of the older rules for the newer sets.

Since this particular rule is only valid when upgrading from 5.3 to 5.4 it can be dropped from the rule set.