Skip to content

Commit 2431bb2

Browse files
committed
use NamedVariableFactory
1 parent f3afd0c commit 2431bb2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PhpParser\Node\Expr\Variable;
1616
use PhpParser\Node\Stmt\Expression;
1717
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
18+
use Rector\NodeFactory\NamedVariableFactory;
1819
use Rector\Rector\AbstractRector;
1920
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
2021
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -25,6 +26,12 @@
2526
*/
2627
final class DowngradePipeOperatorRector extends AbstractRector
2728
{
29+
public function __construct(
30+
private readonly NamedVariableFactory $namedVariableFactory
31+
)
32+
{
33+
}
34+
2835
public function getRuleDefinition(): RuleDefinition
2936
{
3037
return new RuleDefinition(
@@ -187,8 +194,7 @@ private function createMultiplePipeReplacement(array $pipeChain, Expression $ori
187194
return null;
188195
}
189196

190-
$tempVarName = 'result' . (++$tempVariableCounter);
191-
$tempVar = new Variable($tempVarName);
197+
$tempVar = $this->namedVariableFactory->createVariable('result', $originalExpression);
192198

193199
$functionCall = $this->createFunctionCall($function, [$input]);
194200
$assign = new Assign($tempVar, $functionCall);

0 commit comments

Comments
 (0)