Skip to content

Variable declaration via list inside foreach not recognized #33

Closed
@gmazzap

Description

@gmazzap

Following is perfectly valid PHP 5.5+ code:

$data = [
    ['foo', 'Foo'],
    ['bar', 'Bar'],
];

foreach ($data as list($name, $label)) {
    printf('<div id="%s">%s</div>', $name, $label);
}

However, it raises the following warnings:

------------------------------------------
WARNING | Variable $name is undefined.
WARNING | Variable $label is undefined.
------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions