Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 892
Radu C Avatar asked Sep 10 '18 10:09

Radu C


People also ask

Does Symfony work with databases?

Although the Symfony Framework doesn't integrate any component to work with databases, it provides tight integration with a third-party library called Doctrine . Doctrine's sole goal is to give you powerful tools to make database interactions easy and flexible.

What is doctrine in Symfony?

Doctrine's sole goal is to give you powerful tools to make database interactions easy and flexible. In this chapter, you'll learn how to start leveraging Doctrine in your Symfony projects to give you rich database interactions.

How do I use the phpstan extension in composer?

Analysis of discrepancies between entity column types and property field types. To use this extension, require it in Composer: If you also install phpstan/extension-installer then you're all set! If your repositories have a common base class, you can configure it in your phpstan.neon and PHPStan will see additional methods you define in it:

Which version of Symfony is no longer maintained?

Warning: You are browsing the documentation for Symfony 3.4 , which is no longer maintained. Read the updated version of this page for Symfony 6.1 (the current stable version).


1 Answers

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.

like image 130
Vadim Ashikhman Avatar answered Sep 17 '22 14:09

Vadim Ashikhman