Skip to content

PHP 8.2.6RC1 endless foreach #11171

Closed
Closed
@usarise

Description

@usarise

Description

The following code:

<?php

$all = ['test'];

foreach ($all as &$item) {
  $all += [$item];
}

var_dump($all);

Resulted in this output:

endless foreach

But I expected this output instead:

array(1) {
  [0]=>
  &string(4) "test"
}

PHP Version

PHP 8.2.6RC1

Operating System

Debian 11.7

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