Skip to content

Incorrect behavior of ArraySpreadInsteadOfArrayMergeRector #7865

@yguedidi

Description

@yguedidi

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/33491afb-b0b3-4fac-aeb3-6354db4ccabd

<?php

final class DemoFile
{
    public function run()
    {
        $array = ['foo' => 'bar'];
        
        return array_merge(['baz' => 'xxx'], $array);
    }
}

Responsible rules

  • ArraySpreadInsteadOfArrayMergeRector

Expected Behavior

In this case shouldn't it become more: return ['baz' => 'xxx', ...$array];?

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