-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Feature request
The error message here may be difficult to understand: https://phpstan.org/r/8da415e2-4d69-4a0c-b583-0153db6033fc
One may think that since the function should return T of X, it should accept a X (which is not the case, because T may be more specific than than).
I think that omitting the bounds in this error message would help. So, instead of this error:
Function f() should return T of X but returns X.
We would have:
Function f() should return T but returns X.
We should omit the bound when describing a template type used as RHS. For example when describing the type of a property in a property assignment, or the type of a parameter in a method call: https://phpstan.org/r/795c7498-e452-4348-96f6-5f43fae07fd8
Mentioning bounds is still useful in LHS context. For example in arguments: https://phpstan.org/r/110df499-8de5-4784-ae21-f70f33abb4f4 or other contexts: https://phpstan.org/r/9303ebd7-7e26-4b86-8455-ef966ab34fe7