Repository navigation
fix: declare nikic/php-parser and make the CI matrix real - #11
Merged
Merged
Conversation
`src/` imports 71 distinct `PhpParser\*` symbols across 465 references, but `nikic/php-parser` was never declared in `require`. It only resolved because `phpunit/phpunit` allowed it, so the version was never ours to control. That mattered once #10 widened the `args` annotations to accept `ArgPlaceholder`, a class added in php-parser 5.9.0. On `prefer-lowest` composer resolves 5.8.0, where that class does not exist, so `composer test:types` fails with 23 `class.notFound` errors. `static.yml` declared a `prefer-lowest` matrix entry but hardcoded `composer update --prefer-stable` in the install step, so both legs installed the same dependency set and PHPStan never saw the floor. CI was green while the code was broken. Adds a `composer audit --locked` step so an abandoned transitive dependency fails CI, which is what the v5.0.5 change was for in the first place. Verified on both legs, at the corner CI resolves (rector 2.7.0, phpstan 2.3.0): composer test:types 0 errors composer test:unit 290/290 composer audit clean Refs #1940
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.
Follow-up to #10. That PR fixed the abandoned
symplify/rule-doc-generator-contractsdependency correctly, but it also widened theargsannotations to acceptPhpParser\Node\ArgPlaceholder, which introduced a problem on the lowest supported dependency set.The bug
nikic/php-parserwas never declared inrequire.src/imports 71 distinctPhpParser\*symbols across 465 references, and the package only resolved becausephpunit/phpunithappened to allow it. The version was never ours to control.ArgPlaceholderwas added in php-parser 5.9.0. Onprefer-lowest, composer resolves 5.8.0, where that class does not exist:Why CI did not catch it
static.ymldeclared aprefer-lowestmatrix entry but hardcoded the install:Both legs installed the same dependency set, so PHPStan only ever saw 5.9.0 where the fix is valid. The CI log confirms it, the job named
prefer-lowestlocksnikic/php-parser (v5.9.0). Meanwhiletests.ymldoes honour the matrix and itsprefer-lowestleg genuinely installs 5.8.0, but it only runscomposer test:unit, and the references are docblock-only with no runtime effect, so tests pass either way.Nothing was checking the dependency set where the code actually breaks. Fixing the matrix is the durable part here, since it makes this whole class of undeclared dependency visible automatically from now on.
Changes
composer.json: declare"nikic/php-parser": "^5.9"static.yml: install with${{ matrix.dependency-version }}static.yml: add acomposer audit --lockedstep, so an abandoned transitive dependency fails CI rather than reaching a releaseVerification
Both matrix legs, at the corner CI actually resolves (rector 2.7.0, phpstan 2.3.0):
composer test:typescomposer test:unitcomposer auditcomposer validate --strictAlso checked a prod-only consumer (
composer update --no-dev, plugin as the only requirement):Two notes for review
phpstan/phpstanstays inrequire-dev.UsesToExtendRectorconstructor-injectsPHPStan\Reflection\ReflectionProvider, which looks like the same class of bug, but it is not:rector/rectorrequiresphpstan/phpstan: ^2.3.0in its ownrequire, so it arrives transitively in production. I checked the import list acrosssrc/andconfig/and that is the only other root namespace beyondPest\Rector,PhpParser,PHPStanandRector.rector/rector: ^2.6.1is already resolving to 2.7.0 in CI. Not changed here, but flagging it since CI and a localprefer-stableinstall can drift apart over time.Out of scope
docs/rules.mdwas deleted in #10, so the repo now ships no rule documentation.getRuleDefinition()is implemented by all 61 rules and called by nothing. The data is still there, so a renderer plus a test that fails when the file drifts is a reasonable follow-up. Not holding this PR for it.Refs #1940