Home > Back-end >  Configure phpstan with symfony
Configure phpstan with symfony

Time:07-04

I am getting a lot of errors related to phpunit like

Class MyTest extends unknown class PHPUnit\Framework\TestCase

or

Call to an undefined method MyTest::assertFalse().

I am on Symfony 6 and use the docker image of phpstan

My Dockerfile:

FROM ghcr.io/phpstan/phpstan:1-php8.1
RUN composer global require phpstan/phpstan-phpunit phpstan/phpstan-doctrine phpstan/phpstan-symfony

My config:

parameters:
    symfony:
        containerXmlPath: /app/var/cache/dev/App_KernelDevDebugContainer.xml
    scanDirectories:
        - /app/vendor/bin/.phpunit/phpunit-9.5-0/vendor/
    scanFiles:
        - /app/vendor/bin/.phpunit/phpunit-9.5-0/vendor/autoload.php
includes:
    - /composer/vendor/phpstan/phpstan-symfony/extension.neon
    - /composer/vendor/phpstan/phpstan-symfony/rules.neon
    - /composer/vendor/phpstan/phpstan-phpunit/extension.neon
    - /composer/vendor/phpstan/phpstan-phpunit/rules.neon

What did I miss?

CodePudding user response:

Try this instead of scanFiles:

    bootstrapFiles:
        - /app/vendor/bin/.phpunit/phpunit-9.5-0/vendor/autoload.php
  • Related