-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Description
Bug report
When a method have a return type of array will PHPStan not be able to find any potenial null pointers.
Using @return Foo[] on getFoos() will resolve all issues in the snippet.
Code snippet that reproduces the problem
https://phpstan.org/r/ec493869-6fbb-4511-99f7-3de3630c6297
Expected output
+-----------------------------------------------------------------------------+
| Line | test.php |
+-----------------------------------------------------------------------------+
| 19 | Parameter #1 $foo of function useTheFoo expects Foo, mixed|null given. |
| 22 | Parameter #1 (mixed|null) of echo cannot be converted to string. |
| 25 | Parameter #1 $foo of function useTheFoo expects Foo, mixed|null given. |
+-----------------------------------------------------------------------------+
Edit: Updated the expected output, it said "Foo|null given". But PHPStan have no way of knowing it was Foo returned from getFoos(), changed to mixed|null
Reactions are currently unavailable