Skip to content

Commit 071ce2a

Browse files
committed
[Php85] Do not convert to pipe on use directly of spread operator on NestedFuncCallsToPipeOperatorRector
1 parent 01dc92c commit 071ce2a

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<?php
22

3+
namespace Rector\Tests\Php85\Rector\Expression\NestedFuncCallsToPipeOperatorRector\Fixture;
4+
35
$arrayOfArrays = [['a'], ['a'], ['b']];
46
$merged = array_unique(array_merge(...$arrayOfArrays));
57

68
?>
79
-----
810
<?php
911

12+
namespace Rector\Tests\Php85\Rector\Expression\NestedFuncCallsToPipeOperatorRector\Fixture;
13+
14+
$arrayOfArrays = [['a'], ['a'], ['b']];
1015
$merged = array_merge(...$arrayOfArrays)
11-
|> array_unique(...);
16+
|> array_unique(...);
1217

1318
?>

rules/Php85/Rector/Expression/NestedFuncCallsToPipeOperatorRector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ private function processNestedCalls(Expr $expr, bool $deep = false): ?Expr
145145

146146
// If we're deep in recursion and hit a non-FuncCall, this is the base
147147
if ($deep) {
148+
// Spread argument can't be converted to pipe — keep the call as-is
149+
if ($arg->unpack) {
150+
return $expr;
151+
}
152+
148153
// Return a pipe with the base expression on the left
149154
return new Pipe($arg->value, $this->createPlaceholderCall($expr));
150155
}

0 commit comments

Comments
 (0)