phpstan complains about Doctrine Migrations in Symfony 3.4 with Flex project

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.


You can add the directory with the migrations to Composer autoloader, or preferably add it to autoload_directories in phpstan.neon:

parameters:
    autoload_directories:
        - src/Migrations

Check out the Autoloading section in the PHPStan’s documentation for more details.