Skip to content

Detect declartion of count to check inside foreach #4343

@alexander-schranz

Description

@alexander-schranz

Feature request

When you have a variable defined inside a if (count($array)) and do foreach ($array it would be great if PhpStan would not error as the $variable was defined inside the if statement:

https://phpstan.org/r/4db7dd72-54ac-4432-9104-24a5f29549b2

Maybe possible to fix it the same way as: https://github.com/phpstan/phpstan/releases/tag/0.12.64 was implemented.

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