Batch phpcs into two invocations: one for new files, one for old#114
Open
sirbrillig wants to merge 1 commit intotrunkfrom
Open
Batch phpcs into two invocations: one for new files, one for old#114sirbrillig wants to merge 1 commit intotrunkfrom
sirbrillig wants to merge 1 commit intotrunkfrom
Conversation
… old Instead of running phpcs per-file (2N invocations for N files), batch all new (modified) file versions into one phpcs call, then batch all old (unmodified) file versions into a second phpcs call. This preserves the existing optimization of skipping the old-version scan entirely for files that have no new phpcs messages, since the old-version batch is only assembled after the new-version results are known.
This was referenced Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #115
Summary
Alternative to #110, which batches all phpcs calls into a single invocation.
This approach uses two separate phpcs batch calls instead of one combined call:
Key difference from #110
The single-batch approach (#110) pre-determines which old files need scanning before the new-file results are known, which means it sometimes scans old versions of files that turn out to have no new messages (wasted work).
This two-batch approach waits until the new-file results are in before deciding which old versions to scan, preserving the existing per-file optimization of skipping old-version scans for clean files.
Trade-offs vs #110
array<string,string>instead ofarray{new:..., old:...}Performance
Measured with
benchmark.shon 10 staged PHP files (PSR2 standard, 10 runs):