Skip to content

incorrect Empty array passed to foreach. error when iterating over an intersection of X&Traversable #13248

@azjezz

Description

@azjezz

Bug report

when iterating over Something&Traversable<X, Y> the key should be of type K, and the value of type Y, however, phpstan seems to incorrectly thing the iterable is an empty array.

Code snippet that reproduces the problem

https://phpstan.org/r/d182e50f-2110-4b76-9ba5-7cdd09f1b5d4

Expected output

No issues.

Did PHPStan help you today? Did it make you happy in any way?

No response

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