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
Since the body of arrow functions is a single statement, when psalm is unable to infer the return type there isn't an immediate place to put the annotation needed.
If no VariableReference is given, the annotation tells Psalm that the right hand side of the expression, whether an assignment or a return, is of type Type.
Is it possible to expand on that (or another annotation?) to allow doing
Psalm output (using commit 5db75df):
INFO: MixedReturnStatement - 20:6 - Could not infer a return type
INFO: MixedInferredReturnType - 19:30 - Could not verify return type 'bool' for /var/www/vhosts/psalm.dev/httpdocs/src/somefile.php:19:334:-:closure
Since the body of arrow functions is a single statement, when psalm is unable to infer the return type there isn't an immediate place to put the annotation needed.
A contrived but demonstrating example is https://psalm.dev/r/926254686a
If the body of the function is made an assignment (since assignment returns the value too) an annotation can then be added that works, e.g.
but this has forced us to introduce an unused variable.
This works because of the support documented here https://psalm.dev/docs/annotating_code/supported_annotations/ under "Off-label usage of the @var tag", specifically
Is it possible to expand on that (or another annotation?) to allow doing
and so removing the redundant variable?
The text was updated successfully, but these errors were encountered: