-
-
Notifications
You must be signed in to change notification settings - Fork 742
Closed
rectorphp/rector-src
#7938Labels
Description
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']Reactions are currently unavailable