Skip to content

Commit 19ad9cc

Browse files
committed
return variadic directly
1 parent d5c50b3 commit 19ad9cc

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

rules/Php85/Rector/StmtsAwareInterface/NestedToPipeOperatorRector.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpParser\Node\Arg;
99
use PhpParser\Node\Expr;
1010
use PhpParser\Node\Expr\Assign;
11+
use PhpParser\Node\Expr\BinaryOp\Pipe;
1112
use PhpParser\Node\Expr\Cast\Array_;
1213
use PhpParser\Node\Expr\Cast\String_;
1314
use PhpParser\Node\Expr\ConstFetch;
@@ -230,7 +231,7 @@ private function processAssignmentChain(StmtsAwareInterface $node, array $chain,
230231
foreach ($chain as $chainItem) {
231232
$funcCall = $chainItem['funcCall'];
232233
$placeholderCall = $this->createPlaceholderCall($funcCall);
233-
$pipeExpression = new Node\Expr\BinaryOp\Pipe($pipeExpression, $placeholderCall);
234+
$pipeExpression = new Pipe($pipeExpression, $placeholderCall);
234235
}
235236

236237
if (! $lastAssignment instanceof Assign) {
@@ -309,20 +310,13 @@ private function processNestedCalls(Node $node): ?Expr
309310
return null;
310311
}
311312

312-
private function buildPipeExpression(FuncCall $outerCall, FuncCall $innerCall): Node\Expr\BinaryOp\Pipe
313+
private function buildPipeExpression(FuncCall $outerCall, FuncCall $innerCall): Pipe
313314
{
314-
$pipe = new Node\Expr\BinaryOp\Pipe($innerCall, $this->createPlaceholderCall($outerCall));
315-
316-
return $pipe;
315+
return new Pipe($innerCall, $this->createPlaceholderCall($outerCall));
317316
}
318317

319318
private function createPlaceholderCall(FuncCall $originalCall): FuncCall
320319
{
321-
$newArgs = [];
322-
foreach ($originalCall->args as $arg) {
323-
$newArgs[] = new VariadicPlaceholder();
324-
}
325-
326-
return new FuncCall($originalCall->name, $newArgs);
320+
return new FuncCall($originalCall->name, [new VariadicPlaceholder()]);
327321
}
328322
}

0 commit comments

Comments
 (0)