Skip to content

Destructuring in foreach leads to undefined variable (PHP 7.1) #22

@klapuch

Description

@klapuch

For level greater than 0, "undefined variable" error is raised during destructuring in foreach.

Sample code:

<?php
foreach($rows as ['id' => $id])
    yield new Foo($id);

Output:

 ------ ---------------------------------------------- 
  69     Undefined variable: $id                       
  70     Undefined variable: $id                       
 ------ ----------------------------------------------

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