Repository navigation
fix(coding-standard): install the standard beside the code, not in it - #397
Merged
marcelmtz merged 1 commit intoNov 12, 2026
Merged
Conversation
The check could not run on PHP 8.4. composer require resolves against the
lock of the project under test, so a project locked to a magento/framework
that caps PHP below the runner's version fails to solve:
- magento/framework 103.0.7-p4 requires php ~8.1.0||~8.2.0||~8.3.0
-> your php version (8.4.27) does not satisfy that requirement.
phpcs reads files statically and never autoloads the project, so it does
not need to share the project's dependency tree. Installing the standard
in a directory of its own under RUNNER_TEMP removes the coupling: the
check no longer inherits the constraints of the code it is checking. A
project that already vendors the standard still uses its own copy.
Two related fixes in the steps this moves:
Registering installed_paths now only happens when nothing else has.
dealerdirect/phpcodesniffer-composer-installer registers every installed
standard, PHPCSUtils among them, which the Magento2 sniffs need;
overwriting that with a hand-written pair of paths dropped it.
The vendor ignore pattern is quoted. Unquoted, bash expanded it against
the working directory whenever a vendor directory was present, turning
--ignore=*vendor/* into a list of real paths plus stray arguments.
Contributor
Author
|
Green on all three matrix entries, including the two PHP 8.4 ones that were failing: run 42060304736. From the The standard resolved and installed with no reference to the project's lock, and the registration guard found the paths the composer plugin had already written and left them alone — PHPCSUtils included, which is what the old overwrite dropped. |
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.
Coding Standardhas been red since May 2026, onmainas well as on PRs. It has only run twice since, because itspathsfilter rarely matches — #396 touches_test/demo-package/**, which brought it back into view.It fails on the PHP 8.4 matrix entries and passes on 8.3:
Why
The action installs the standard into the project under test, so
composer requirehas to solve against that project's lock._test/demo-package/composer.lockpinsmagento/framework 103.0.7-p4, which caps PHP at 8.3, so on a PHP 8.4 runner there is no solution — and the check fails before a single sniff runs.Refreshing the fixture's lock would make this particular red go green, but the coupling is the actual defect, and it recurs for every consumer repository whose lock lags the runner's PHP.
phpcsreads files statically and never autoloads the project, so it has no reason to share the project's dependency tree.What changes
The standard is installed into a directory of its own under
RUNNER_TEMP, andphpcsruns from there againstpath. A project that already vendors the standard still uses its own copy, as before.Two related fixes in the steps this moves:
installed_pathsis only written when nothing else wrote it.dealerdirect/phpcodesniffer-composer-installerregisters every installed standard, PHPCSUtils among them, which theMagento2sniffs need. The old step overwrote that with a hand-written pair of paths and dropped it:*vendor/*against the working directory whenever avendordirectory is present, turning--ignore=*vendor/*into a list of real paths plus stray arguments.Severity inputs now reach the script through
envrather than being interpolated into it.Verified
Locally, with the standard installed in a directory of its own and
phpcsrun against_test/demo-package:No project
vendordirectory involved, and the demo package's own PHP reports no errors. This PR touchescoding-standard/**, so the workflow runs on it and checks itself against the PHP 8.4 entries that were failing.