Fix Type\shape cross-major Psl compatibility (positional allowUnknownFields)#5
Merged
Merged
Conversation
…r support The package supports php-standard-library ^4.0 || ^5.0 || ^6.0, but Psl renamed Type\shape()'s second parameter between majors: `allow_unknown_fields` in 4.x and `allowUnknownFields` in 5.x/6.x. Calling it by name therefore only ever works on a subset of supported majors — under Psl 4.x the named call throws "Unknown named parameter $allowUnknownFields" at rule-registration, which aborts PHPStan for every downstream consumer pinned to 4.x. Pass the argument positionally instead; the parameter's position is stable across all supported majors, so the rule works regardless of the Psl version resolved by the consumer. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pre-existing failures unrelated to the Psl arg fix, surfaced now that the suite runs to completion: - StrictComparisonOfObjectsRule::processNode() must return list<IdentifierRuleError>; add ->identifier() so the builder yields one. - basepath(): realpath() is string|false. Guard both calls so preg_match receives a string and the function never returns false. - RestrictImplicitDependencyUsage test used Psl\Collection\Vector as the "undefined package" example, but php-standard-library is now a declared dependency (the rule itself uses Psl\Type), so Psl\ is an allowed namespace. Use SebastianBergmann\Diff\Differ — installed transitively via phpunit but not declared — which is genuinely an implicit dependency. - Raise phpstan/phpstan floor to ^2.1.13: the rule implements RestrictedClassNameUsageExtension, added in 2.1.13, so prefer-lowest previously resolved 2.1.0 (missing the interface) and fatal-errored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
On windows-latest + PHP 8.3 + prefer-stable, php-standard-library 5.x/6.x require PHP ~8.4, so composer must resolve to 4.x — which requires ext-sodium. sodium is bundled on the Ubuntu images but not enabled on Windows unless requested, so the install step failed there. Add it to the setup-php extensions list. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
erikgaal
approved these changes
Jun 11, 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.
Problem
The package requires
php-standard-library: ^4.0 || ^5.0 || ^6.0, but Psl renamedType\shape()'s second parameter between majors:bool $allow_unknown_fieldsbool $allowUnknownFieldsRestrictImplicitDependencyUsagecalls it by name (allowUnknownFields:), so it only works on a subset of supported majors. Under Psl 4.x it throwsUnknown named parameter $allowUnknownFieldsat rule registration, which aborts PHPStan entirely for any downstream consumer pinned to Psl 4.x (e.g. product-catalogue). Worse, PHPStan exits 0 in that state, so the consumer's type-check silently passes without analysing anything.The commit that introduced this (
c81f12f) switched snake→camel to satisfy Psl 6.x in this repo's own dev env, inadvertently breaking 4.x consumers.Fix
Pass the argument positionally (
Type\shape([...], true)). The parameter's position is stable across all supported majors, so the rule works regardless of which Psl major the consumer resolves.Verification
Validated locally against both majors:
allowUnknownFields:(before)Unknown parameter $allowUnknownFieldsFollow-up suggestion
Add a Psl-version matrix (4.x / 5.x / 6.x) to CI so a named-arg regression like this fails here instead of in consumers.
🤖 Generated with Claude Code