Closed levu42 closed 10 months ago
For fixing wrong 3rd party PHPDocs there's a feature called Stub files: https://phpstan.org/user-guide/stub-files (so you can do that to set the original property as array<int, string>
.
If you just want to type this in your code:
/** @var array */
public $foo = ['bar'];
Without getting " has no value type specified in iterable type array." then you should use mixed[]
instead of array
.
@ondrejmirtes Thanks for the quick reply - @var mixed[]
did the trick :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
When I have a vendor class that has a member
/** @var array */ public $foo = [];
and I want to override it, I can either also declare the variable asarray
, triggering a "has no value specified in iterable type array" error, or I can explicitly set the types of the items in the array, triggering a type mismatch error:https://phpstan.org/r/9a6aa272-c73a-43ab-a781-f735a68cf24c