Skip to content
Latchkey

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.

PHPStan
 ------ ---------------------------------------------------------------
  Line   src/Invoice.php
 ------ ---------------------------------------------------------------
  31     Parameter #1 $amount of method format() expects int, string given.
 ------ ---------------------------------------------------------------

 [ERROR] Found 7 errors

Common 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

  1. Read each file:line and the specific message PHPStan prints.
  2. Correct the type, add a missing nullsafe check, or annotate where the type is genuinely wider.
  3. Re-run phpstan analyse until it reports no errors.
Terminal
vendor/bin/phpstan analyse --no-progress

Adopt 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.

Terminal
vendor/bin/phpstan analyse --generate-baseline

How to prevent it

  • Raise PHPStan level gradually 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →