Let's get PHPStan working with Gitlab and code quality.
.gitlab-ci.yml add a new section:
phpstan: stage: testing needs: - composer script: - php -d memory_limit=-1 vendor/bin/phpstan analyse -c phpstan.neon --error-format gitlab > phpstan-report.json artifacts: paths: - "phpstan-report.json" expire_in: 14 days when: always reports: codequality: "./phpstan-report.json"
If your phpstan config isn't located in
phpstan.neon change the portion after the
-c to be the correct file. You might also need to change the
stage: testing to match with your stages setup.
One thing we've run into a few times with our main app was that PHPStan would fail on Gitlab but be passing on our local machines. While we still have no idea what causes this issue we added a manual job to run for these times:
phpstanmanual: stage: testing needs: - composer script: - php -d memory_limit=-1 vendor/bin/phpstan analyse -c phpstan.neon when: manual
After it is completed running, click on the specific job to view what the errors are.
Thanks, for reading, please let me know if you found this helpful or have questions over on Twitter: twitter.com/guywarner801