When the input into a function uses the spread operator, the NestedFuncCallsToPipeOperatorRector breaks the code.
// 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']
Bug Report
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