Skip to content

Make unmatched ignoreErrors entries and too high counts fixable - #6906

Merged
ondrejmirtes merged 2 commits into
2.3.xfrom
fixable-ignore-errors-config
Nov 2, 2026
Merged

ondrejmirtes merged 2 commits into
2.3.xfrom
fixable-ignore-errors-config

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Continues #6902. --fix now fixes two errors about ignoreErrors entries in config files:

  • ignore.unmatched removes the entry. When it matched through a list like messages or identifiers that has other items, only that item is removed.
  • ignore.count lowers the count when the error occurred fewer times than the entry says. A count lower than the occurrences is not fixed, it would ignore more errors - that is what --generate-baseline is for.

Where the entry is looked for

  • The whole config cascade (allConfigFiles), except files of installed Composer packages. The check moved from ResultCacheManager to PackageDependencyResolver::isFileOfInstalledPackage(); packages from path repositories are still treated as the project's own code.
  • Only PHP config files, like PHP baselines, are fixed so far. NEON is left for later.
  • An entry is not fixed when it is unclear which one to change, like a count merged from duplicate entries or from an entry in a NEON file.

Performance
The first version used the format-preserving printer for every fix. On a WordPress level 10 baseline (31k entries, 186k lines) that took 4.4 s per error: cloning the AST and printing the whole file. Now the file is parsed once, a fix edits the source range of the node, and its diff covers only the changed lines, which is all Patcher reads. With 1,863 broken entries in that baseline, every fix takes under 1 ms and --fix finished in 28 s; the fixed baseline equals the original minus the broken entries.

The parse is lazy, but it happens on every run that reports one of these errors: about 1.5 s for the 7 MB WordPress baseline.

Removing the last items of a list
Removing an item rewrites the whole list, so removals of two items of one list conflict and go in separate rounds. Otherwise all items could be removed in one round, leaving an invalid 'messages' => [].

Tests: IgnoreErrorsConfigFixerTest applies the diffs through Patcher, and a new e2e/fix-baseline test checks the fixed baseline file, that entries in NEON and in vendor/ stay, and that --fix --generate-baseline is rejected.

…solver

So that other code than ResultCacheManager can tell whether a file belongs
to a package Composer installed.

Amp-Thread-ID: https://ampcode.com/threads/T-01a19bac-7181-7568-be9c-c7ec28db8ebc
ignore.unmatched removes the entry from the config file, or only the
message or identifier from a list like `messages` when it has other items.
ignore.count lowers the count when the error occurred fewer times. A higher
count is not fixed, it would ignore more errors - that is what
--generate-baseline is for.

The entry is looked for in the whole config cascade except for files of
installed Composer packages. Only PHP config files, like PHP baselines, are
fixed so far.

A fix edits the source range of the parsed node and its diff covers only the
changed lines. Printing the whole file for every fix took 4.4 s per error on
the 31k entries of a WordPress baseline, now it takes under a millisecond.

Amp-Thread-ID: https://ampcode.com/threads/T-01a19bac-7181-7568-be9c-c7ec28db8ebc
@ondrejmirtes
ondrejmirtes merged commit 7d0521a into 2.3.x Nov 2, 2026
721 of 722 checks passed
@ondrejmirtes
ondrejmirtes deleted the fixable-ignore-errors-config branch November 2, 2026 10:37
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