Skip to content

Incorrect behavior of ForeachItemsAssignToEmptyArrayToAssignRector #9534

@jorgsowa

Description

@jorgsowa

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/6837a4d5-c4d2-46e6-a872-3db3777574b7

<?php
class Class2 {
    public function sort(array $ids): void
    {
            $bindings = [];
            $statement = '<SQL qeury>';
            foreach ($ids as $index => $cID) {
                $bindings[] = $cID;
                $bindings[] = $index + 1;
            }
        	print($statement);
            foreach ($ids as $cID) {
                $bindings[] = $cID;
            }
    }
}

Responsible rules

  • ForeachItemsAssignToEmptyArrayToAssignRector

Expected Behavior

no change

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions