PHPStan "[ERROR] Found N errors" fails the build in CI
PHPStan analyzed the code at the configured rule level and found issues it cannot prove safe. It exits non-zero with "[ERROR] Found N errors", and each line names a file, a line, and the specific problem.
What this error means
The analyse step ends with a table of errors and "[ERROR] Found 7 errors", failing the job. New errors often appear after raising level or upgrading PHP.
------ ---------------------------------------------------------------
Line src/Invoice.php
------ ---------------------------------------------------------------
31 Parameter #1 $amount of method format() expects int, string given.
------ ---------------------------------------------------------------
[ERROR] Found 7 errorsCommon causes
Real type or logic issues at this level
Higher levels check more; code that passed at a lower level now reports type mismatches, undefined methods, or unreachable branches.
A level or PHP bump surfaced new findings
Raising level in phpstan.neon or upgrading PHP exposes patterns PHPStan now flags that were previously unchecked.
How to fix it
Fix the reported lines
- Read each file:line and the specific message PHPStan prints.
- Correct the type, add a missing nullsafe check, or annotate where the type is genuinely wider.
- Re-run
phpstan analyseuntil it reports no errors.
vendor/bin/phpstan analyse --no-progressAdopt a level incrementally with a baseline
Generate a baseline so existing findings do not block the build while new code is held to the higher level.
vendor/bin/phpstan analyse --generate-baselineHow to prevent it
- Raise PHPStan
levelgradually and fix findings as you go. - Use a baseline to ratchet quality without a giant cleanup commit.
- Run analysis locally before pushing so findings surface early.