Skip to content

NestedFuncCallsToPipeOperatorRector breaks spread operator in input #9710

Closed
rectorphp/rector-src
#7938

Description

@annadamm-check24

Bug Report

Subject Details
Rector version 2.3.9

When the input into a function uses the spread operator, the NestedFuncCallsToPipeOperatorRector breaks the code.

Minimal PHP Code Causing Issue

https://getrector.com/demo/fd1ebd94-1d07-4327-8b99-98dbbb506f80
this results in Warning: Array to string conversion.

Expected Behaviour

// input code
$arrayOfArrays = [['a'], ['a'], ['b']];
$merged = array_unique(array_merge(...$arrayOfArrays));

var_dump($merged); // ['a', 'b']

// this is what rector does
$merged = $arrayOfArrays
    |> array_merge(...) // results in no change, instead of arrays being merged together as in original
    |> array_unique(...); // warning 
var_dump($merged); // ->different! [['a']]

// this is what rector should do
$merged = array_merge(...$arrayOfArrays)
 |> array_unique(...);
var_dump($merged); // -> same as original code: ['a', 'b']

Activity

  1. TomasVotruba commented on Mar 26, 2026

    @TomasVotruba
    Member

    Thank you for your report and demo link!

    We'll need a failing test case in a pull-request, so we have it covered in Rector.
    You can click "Create a Test" button at demo page.

  2. annadamm-check24 commented on Mar 27, 2026

    @annadamm-check24
    Author
  3. github-actions commented on Aug 30, 2026

    @github-actions
    Contributor

    This issue has been automatically locked because it has been closed for 150 days. Please open a new issue if you have a similar problem.

  4. locked as resolved and limited conversation to collaborators on Aug 30, 2026
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