Skip to content

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

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
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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