You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Conditional return type in @method is not resolved #12205
A conditional return type on a class-level @method tag is not resolved at the call site when the condition refers to a parameter (conditionals on an already-bound class template do resolve). The template Psalm generates for the parameter stays in the inferred type:
Trace: $a: (TGeneratedFromParam1 is true ? string : list<string>)
Trace: $b: (TGeneratedFromParam1 is true ? string : list<string>)
Expected list<string> and string. The same conditional in @return on a real method resolves to exactly that, and PHPStan (2.2.x-dev) resolves this @method form too.
Reproduced on 6.x @ b2e7f20 and master @ fe996e2, with and without native parameter types in the tag.
Real-world case: FakerPHP/Faker#1075 proposes this annotation for words() on Faker\Generator.
Hey @alies-dev, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.
Activity
psalm-github-bot commentedon Oct 7, 2026
Hey @alies-dev, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.
fix(call): resolve conditional return type in @method #12205
orklah commentedon Nov 14, 2026
Fixed by #12206, now on master too:
$g->words(3, false)inferslist<string>and$g->words(3, true)infersstring. Closing.