🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Confusing messaging for undefined variables in loops #2032

Description

@muglug

I think this was the root of the confusion in #821 (comment)

function noloop(array $foo) {
    if ($undefined) {}
}

function loop(array $foo) {
    foreach ($foo as $bar) {
        if ($undefined) {}
    }
}

Expected:

4: Undefined variable: $undefined
9: Undefined variable: $undefined

Actual:

4: Undefined variable: $undefined
9: Variable $undefined might not be defined.

https://phpstan.org/r/d64a6ad0-4cff-4eb6-95be-ef00b57596c1

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