Repository navigation
Conversation
GromNaN
marked this pull request as ready for review
October 24, 2026 19:15
Collaborator
|
This pull request has been marked as ready for review. |
This was referenced Oct 24, 2026
The unresolved template check skipped every template whose resolved type equals its bound. That is the expected fallback for class templates the call does not provide, but a method template is inferred from the arguments: a template inferred as `mixed` equals its default bound and was wrongly skipped. This suppressed the already-narrowed report for @phpstan-assert calls whose asserted type was already satisfied.
GromNaN
force-pushed
the
method-template-bound-assert
branch
from
October 24, 2026 20:06
879663f to
14f3893
Compare
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.
A
@phpstan-assertis not reported as redundant when its type contains a method template inferred asmixed. Example from doctrine/orm#12513:$groupByand$selectare both lists because of@no-named-arguments, so the assertion is already satisfied in both cases. OnlygroupBy()is reported today.Every template has a bound,
mixedwhen noofis declared. For a class template, "resolved type equals bound" means the call did not specify it, so the template is unknown. For a method template, the type is inferred from the arguments:TItemresolved tomixedis a real answer that happens to equal the default bound. The old check treated both as unresolved.The bound fallback now applies to class templates only (
TemplateTypeScope::getFunctionName() === null). Method templates resolved to their bound are treated as resolved, so their assertion is applied and the already-satisfied report runs.Class templates that are really unresolved are still skipped. The native mirror in
turbo-ext/src/DefaultNarrowingHelper.cppapplies the same change, and regression tests are intests/PHPStan/Rules/Comparison/data/no-named-arguments-assert.php.