driftingly / rector-laravel

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

Refactor If statements to use helpers with conditionals and provides a set #194

Closed peterfox closed 6 months ago

peterfox commented 7 months ago

Changes

Why

Makes sense to cover all the possible helpers and have a set that covers the three scenarios. The only one missing would be the Dispatchable trait static calls (dispatchIf) but it would require a new rule and feels a bit more niche compared to the helpers.

johnbacon commented 5 months ago

I may be missing something, but this doesn't seem to be available via https://github.com/driftingly/rector-laravel/blob/eefaf3ef1186a4f07b50988de402b30b87143ed7/src/Set/LaravelSetList.php. Is there another way to use it? (Thank you!!)

GeniJaho commented 5 months ago

@johnbacon You're right, we're missing a constant for it. We'll probably add one soon. Another way to use it is to include the three rules manually:

$rectorConfig->rule(AbortIfRector::class);
$rectorConfig->rule(ReportIfRector::class);
$rectorConfig->rule(ThrowIfRector::class);