Repository navigation
Conversation
GromNaN
force-pushed
the
native-type-ignores-no-named-arguments
branch
from
October 24, 2026 20:05
8afa421 to
db5b675
Compare
The native type of a variadic parameter used acceptsNamedArguments(), which comes from the @no-named-arguments PHPDoc tag. That contradicts getNativeType(), which is documented as ignoring PHPDoc, and makes an @phpstan-assert on such a parameter report as redundant under treatPhpDocTypesAsCertain: false. Only the PHPDoc-aware type now uses acceptsNamedArguments(). The native type keeps string keys whenever the PHP version supports named arguments.
GromNaN
force-pushed
the
native-type-ignores-no-named-arguments
branch
from
October 24, 2026 20:08
db5b675 to
4bc93c4
Compare
GromNaN
marked this pull request as ready for review
October 24, 2026 20:11
Collaborator
|
This pull request has been marked as ready for review. |
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.
getNativeType()is documented as returning only what PHP's native type system knows, ignoring PHPDoc. The native type of a variadic parameter does not follow that rule: it usesacceptsNamedArguments(), which comes from the@no-named-argumentsPHPDoc tag.As a result, with
treatPhpDocTypesAsCertain: false, PHPStan still reports an@phpstan-asserton such a parameter as redundant, even though the report relies on PHPDoc:The native parameter type now keeps string keys whenever the PHP version supports named arguments, and only the PHPDoc-aware type uses
acceptsNamedArguments(). WithtreatPhpDocTypesAsCertain: false,$groupByisarray<int<0, max>|string, string>for the analyser, the assertion narrows, and nothing is reported. With the defaulttrue, the PHPDoc-aware type is stilllist<string>and the call is reported as before.The native mirror in
turbo-ext/src/MutatingScope.cppapplies the same change.tests/PHPStan/Analyser/nsrt/no-named-arguments.phpnow expectsarray<int<0, max>|string, float>fromassertNativeType, and a rule test covers thetreatPhpDocTypesAsCertain: falsecase.The other half of the
@phpstan-assertbehaviour, method templates resolved to their bound, is in #6823.