psalm / psalm-plugin-laravel

A Psalm plugin for Laravel
MIT License
307 stars 72 forks source link

Support multiple migrations-directories #342

Open marcusrettig opened 1 year ago

marcusrettig commented 1 year ago

Is your feature request related to a problem? Please describe. The plugin only considers migrations in the database/migrations directory. If migrations are spread out in several directories, e.g. when using Laravel Modules, some Model stubs are generated without @property definitions. This results in many false positive UndefinedMagicPropertyAssignment errors.

Describe the solution you'd like First, a warning message would be nice when a table can't be found (here).

Second, a way to specify multiple directories for migrations would be nice. I'm not sure what would be the best way to do this.

Describe alternatives you've considered Temporarily moving all migrations into database/migrations before running Psalm fixes the issue, but it is rather inconvenient.

Additional context Our directory structure looks like this:

database/
    migrations/
modules/
    MobuleA/
        database/
            migrations/
    MobuleB/
        database/
            migrations/
Ar-Monta commented 8 months ago

Hello @marcusrettig To support migrating from a specific migration directory you can customize your module's service provider by overriding boot() function and adding this line of code: $this->loadMigrationsFrom("YOUR_SPECIFIC_MODULE_MIGRATIONS_DIRECTORY");