Replies: 1 comment
-
Hi, I didn't found a solution too ; so I think it require a new feature request. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's say I have a function that returns the first non-null value passed to a variadic parameter, or
null
if every value passed isnull
.How would you annotate this? Being able to do it successfully would help eliminate a bunch of false positives :P
The example code reflects the conclusion of this feature request, but I've tried many other combinations of template types and syntax to no avail. The return type always resolves to a union of the types passed.
Playground: https://phpstan.org/r/0ff2728c-e64d-46f2-ba0b-88ec146a35f2
This should produce:
string
null
string
string
But PHPStan reports:
string
null
string|null
string|null
Would value your advice! 🙏🏻
Beta Was this translation helpful? Give feedback.
All reactions