Laravel Rules for RectorPHP

Share
Laravel Rules for RectorPHP
Photo by Kelly Sikkema / Unsplash

I'm a huge fan of RectorPHP. It makes upgrading your codebase so much easier. I'd recommend everyone goes and checks it out! I can guarantee once it's installed, you wont want to remove it!

I recently heard about this package, which adds a whole host of Laravel specific rules to Rector. For example, if you want to bring your application up to Laravel 12 standards, you can apply the UP_TO_LARAVEL_120 set list:

return RectorConfig::configure()
  ->withSets([
    LaravelLevelSetList::UP_TO_LARAVEL_120,
  ]);

I'll hazard a guess and say next year, there will be a UP_TO_LARAVEL_130 set list available! Aside from the version of Laravel, there's also 50+ rules you can use, such as:

  • AbortIfRector
  • AddHasFactoryToModelsRector
  • ConfigToTypedConfigMethodCallRector
  • EloquentMagicMethodToQueryBuilderRector
  • RemoveDumpDataDeadCodeRector

You can find a full list here. I can already see some rules that I'm definitely interested in bringing in to my applications!