Search code examples
symfonydoctrine-migrationssymfony-flexphpstan

phpstan complains about Doctrine Migrations in Symfony 3.4 with Flex project


I have a project built on Symfony 3.4 with Flex and I've added phpstan to it for static analysis.

It is complaining about not finding my migration classes:

Class DoctrineMigrations\Version20180831185050 was not found while trying to analyse it - autoloading is probably not configured properly.

Indeed, the files generated by Doctrine Migrations don't fit with the autoloader pattern, but works just fine otherwise.

Is there anything I can do to stop complaining about this?


Solution

  • You can exclude files from analysis

    Create phpstan.neon configuration file in the project directory and insert:

    parameters:
        excludes_analyse:
            - %currentWorkingDirectory%/src/DoctrineMigrations/*
    

    Every file inside src/DoctrineMigrations directory will be excluded from analysis.