Skip to content

Spam of FPs when typehinting IteratorAggregate::getIterator() implementation with Generator #4224

@dktapps

Description

@dktapps

Bug report

https://phpstan.org/r/7d6e60fb-1639-45d9-886d-3f97038849f8

The Generator doesn't have key/value types hinted, which I can kinda understand being a problem, since it's a little difficult to automatically infer types in this context.

However, the lack of a Generator generic type also causes no value type specified in iterable type to be generated absolutely everywhere the class is used, generating (in my case) a huge spam of false errors.

The iterable value type should be known irrespective of whether getIterator()'s return has fully specified types, because of the @phpstan-implements annotation.

Expected output

The final line should not report any error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions