driftingly/rector-laravel

L8 rules: Seeders are now namespaced

Closed this issue · 2 comments

Hi there,

After joining a meet-up on Rector (PHP-WVL) I was very curious about the package. I'm now using it to upgrade a L7 to L8 and noticed that there's probably a rule missing, although I'm not sure as it could be that I'm not familiar enough with rector.

The high impact change is that Seeder classes need namespacing from L8 forward. Is it possible that this rules needs to be added still, if so how can I help?

that there's probably a rule missing

First of all, you are right. Sorry for left this out when I added the rule set.

IMO, there are three parts to this change:

  1. Rename the database/seeds directory to database/seeders
  2. Remove classmap block from the autoload section and add the new namespaced class directory mappings
  3. Add the Database\Seeders namespace to your seeder classes

The first two are not supported as far as I know. But if you do the first two manually, the third change you can handle with rule NormalizeNamespaceByPSR4ComposerAutoloadRector


If you want to add rules for this change, hope the following rules will help you.

Thanks @zingimmick I expected as much that 1. and 2. were not possible, renaming folders and such has a big impact on a code base. I'll give 3. a shot when I have time, thanks for the reply!