rector icon indicating copy to clipboard operation
rector copied to clipboard

Incorrect behavior of ForeachItemsAssignToEmptyArrayToAssignRector

Open jorgsowa opened this issue 2 months ago • 0 comments

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

jorgsowa avatar Dec 05 '25 20:12 jorgsowa