Skip to content

Foreach overwrites $variable with its value variable. - false positive? #194

@lulco

Description

@lulco

I can't reproduce this issue on https://phpstan.org/try, is the rule overwriteVariablesWithLoop set to true there?

If I use foreach twice I got error on second run Foreach overwrites $var with its value variable. But $var is local variable here so it shouldn't be reported imho.

foreach ($variable as $var) {
    // do something
}

foreach ($variable as $var) {
    // do something else
}

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