Skip to content

Incorrect behavior of ForeachItemsAssignToEmptyArrayToAssignRector #9534

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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