Search code examples
symfonygitlabgitlab-cigitlab-ci-runnerphpstan

Phpstan with gitlab-ci cant find srcApp_KernelDevDebugContainer.xml because its in the gitignore?


this is my phpstan.neon

  parameters:
  checkMissingIterableValueType: false
  checkGenericClassInNonGenericObjectType: false
  symfony:
        container_xml_path: '%rootDir%/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml'
  bootstrap: '%rootDir%/../../../vendor/autoload.php'

This is my gitlab-ci snippet

commit:
  stage: analysis
  variables:
    APP_ENV: dev
  cache:
    untracked: true
    paths:
     - Source/var/cache/dev/
  before_script:
    - cd Source
    - cp .env.example .env
    - composer install --no-interaction --optimize-autoloader --classmap-authoritative
  script:
    - composer commit
  only:
    - merge_requests

And I get the following error:

In XmlServiceMapFactory.php line 29:

   [PHPStan\Symfony\XmlContainerNotExistsException]                             
   Container /builds/Mehlichmeyer/heracles-mvp-symfony/Source/vendor/phpstan/p  
   hpstan/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml does not e  
   xist                  

The issue is that my gitlab-ci container doesn't have the srcApp_KernelDevDebugContainer.xml, since it's in my .gitignore (/var/ is). Any Ideas for a workaround?


Solution

  • Alright, so I finally found the Issue. I updated my Symfony from 4.x to 5.x, and I had to adjust my phpstan.neon

    container_xml_path: '%rootDir%/../../../var/cache/dev/App_KernelDevDebugContainer.xml'
    

    Locally this never threw an error because I hadn't run bin/console cache:clear, so the old container_xml_path was working fine.