Batch phpcs calls into a single invocation#110
Open
sirbrillig wants to merge 1 commit intotrunkfrom
Open
Conversation
a75e2c2 to
129b081
Compare
Replace the 2N per-file phpcs launches in runGitWorkflow and runSvnWorkflow with a single batch invocation. All modified and unmodified file contents are written to a temp directory and phpcs is run once on all of them, eliminating the startup overhead cost that scaled linearly with the number of changed files. - Add getPhpcsOutputForGitBatch / getPhpcsOutputForSvnBatch to ShellOperator - Implement batch methods in UnixShell using a temp dir layout (new/ and old/) - Override batch methods in TestShell to delegate to existing per-file mocks - Rewrite runGitWorkflow and runSvnWorkflow with pre-batch/batch/filter phases - Add and update tests for the new batch behavior
129b081 to
74ce1eb
Compare
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
runGitWorkflowandrunSvnWorkflowwith a single phpcs invocation that scans all file versions at once/tmp/phpcs-changed-XXXX/new/…and/tmp/phpcs-changed-XXXX/old/…) and phpcs runs once across all of them, eliminating startup overhead that previously scaled linearly with the number of changed filesrunGitWorkflowForFileandrunSvnWorkflowForFileare unchangedThis is a different approach to #114
Approach
Each workflow now has three phases:
getPhpcsOutputForGitBatch/getPhpcsOutputForSvnBatchcall writes all content to a temp dir and runs phpcs once; results are cached individually per fileTrade-off
The batch approach always scans the unmodified version of uncached files even when the modified version has no messages. Previously the per-file path skipped the unmodified scan in that case. The trade-off is intentional: one saved phpcs startup cost (≥250 ms) outweighs the cost of a few extra file sniffs.
Performance
Measured with
benchmark.shon 10 staged PHP files (PSR2 standard, 10 runs):Changes
PhpcsChanged/ShellOperator.php— addgetPhpcsOutputForGitBatchandgetPhpcsOutputForSvnBatchto the interfacePhpcsChanged/UnixShell.php— implement both batch methods using a temp directory and a single phpcs invocation; private helperswriteTempFile,runBatchPhpcs,cleanupTempDirtests/helpers/TestShell.php— override both batch methods to delegate to existing per-file mocks (shell redirections can't be simulated in tests)PhpcsChanged/Cli.php— rewriterunGitWorkflowandrunSvnWorkflowwith the three-phase approachtests/GitWorkflowTest.php/tests/SvnWorkflowTest.php— update tests affected by the always-scan-unmodified trade-off; add multi-file batch tests verifying new-file handling and cache hit behaviour