Skip to content

Adding a docblock right before a foreach with information on the iterable/array fails #3307

@MetalArend

Description

@MetalArend

Bug report

If you write a docblock with a @var to describe the type of a variable right before a foreach loop, only the $key and $value variables are considered correct names to be used.
All the other variables in the scope are not considered.

Code snippet that reproduces the problem

https://phpstan.org/r/e9da45dc-458e-4cc9-b5bd-c8f37e4d5279

Expected output

At least the array itself should be considered a correct variable to have a @var docblock about. And even the other variables in the scope might be considered.

Thanks for considering this and taking the time to read this issue. I love what you do with phpstan a lot!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions