-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Please see https://phpstan.org/r/4670a61f-e909-47cc-84aa-e3b96c4d7f6f.
I'd like to be able to iterate over a SplObjectStorage instance and expect all elements of the collection to be of a certain type by specifying this one place, the property declaration. However, in this case assignment to a property annotated as /** @var SplObjectStorage|T[] */ is detected by PHPStan as a type violation.
Other than specifying the element type during iteration like the following, is there a better way to do that?
/** @var T[] $collection */
foreach ($collection as $item) {
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels