Skip to content

Remove ignores made stale by --fix-ignored for a list of files too - #1

Draft
Kanti wants to merge 4 commits into
2.3.xfrom
fix-ignored-list-of-files
Draft

Kanti wants to merge 4 commits into
2.3.xfrom
fix-ignored-list-of-files

Conversation

@Kanti

@Kanti Kanti commented Nov 11, 2026

Copy link
Copy Markdown
Owner

For a list of files, --fix-ignored fixes the ignored errors but leaves the baseline entries that matched them in place, so the next full analysis fails with ignore.unmatched. Without paths, the same command removes them (phpstan#6909).

A list of files is a partial analysis (onlyFiles), where unmatched ignoreErrors entries with a path are not reported, because errors from files outside the list can still match them. So the later rounds never saw the entries that the earlier rounds made stale. The rounds already get the files the earlier rounds changed (--fixed-ignored-in), but only AnalyseCommand used them, to pick the ignore.* errors to fix.

They are now passed through AnalyseApplication::analyse() to IgnoredErrorHelperResult::process(), which reports the unmatched entries for those files for a list of files too, so the next round removes them. Entries for other files are still not reported, and a run without --fix or --fix-ignored doesn't change. With --fix alone, the rounds now also remove unmatched entries in the files they changed, like a full run does for all files.

This matters for tools that pass the changed files to PHPStan, like git hooks (GrumPHP, CaptainHook).

Tests:

  • AnalyserTest: an unmatched entry for an analysed file is reported for a list of files only when an earlier fix round changed that file.
  • e2e/fix-ignored-entries: the existing scenario as a list of files, with the same expected result as the full run.

Closes https://github.com/phpstan/phpstan/issues/XXXXX


Generated by Claude Code

For a list of files, unmatched ignoreErrors entries with a path are not
reported, because errors from other files can still match them. So the
later rounds of --fix-ignored never saw the baseline entry that matched
a fixed ignored error, left it in place, and the next full analysis
failed with ignore.unmatched.

The rounds already get the files the earlier rounds changed. They are
now passed to IgnoredErrorHelperResult::process(), which reports the
unmatched entries for those files for a list of files too, so the next
round removes them. Entries for other files are still not reported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant