[PostRector] Using NodesToAddCollector in Rector rules (#812)

* [PostRector] Using NodesToAddCollector in Rector rules

* addNodes* as well

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Abdul Malik Ikhsan 2021-09-02 13:31:58 +07:00 committed by GitHub
parent c732f61317
commit 49033cecc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 73 additions and 73 deletions

View File

@ -75,7 +75,7 @@ CODE_SAMPLE
$rightArray = $node->expr;
$standaloneAssigns = $this->createStandaloneAssigns($leftArray, $rightArray);
$this->addNodesAfterNode($standaloneAssigns, $node);
$this->nodesToAddCollector->addNodesAfterNode($standaloneAssigns, $node);
$this->removeNode($node);

View File

@ -111,7 +111,7 @@ CODE_SAMPLE
}
$countAssign = new Assign(new Variable($variableName), $countInCond);
$this->addNodeBeforeNode($countAssign, $node);
$this->nodesToAddCollector->addNodeBeforeNode($countAssign, $node);
return $node;
}

View File

@ -92,7 +92,7 @@ CODE_SAMPLE
$this->mirrorComments($assignExpression, $node);
}
$this->addNodeAfterNode($assignExpression, $node);
$this->nodesToAddCollector->addNodeAfterNode($assignExpression, $node);
++$position;
}

View File

@ -142,7 +142,7 @@ CODE_SAMPLE
$preAssign = new Assign($assignVariable, $array);
$currentStatement = $funcCall->getAttribute(AttributeKey::CURRENT_STATEMENT);
$this->addNodeBeforeNode($preAssign, $currentStatement);
$this->nodesToAddCollector->addNodeBeforeNode($preAssign, $currentStatement);
return $expr;
}

View File

@ -75,7 +75,7 @@ CODE_SAMPLE
return null;
}
$this->addNodeAfterNode($node->right, $node);
$this->nodesToAddCollector->addNodeAfterNode($node->right, $node);
return $node->left;
}

View File

@ -117,7 +117,7 @@ CODE_SAMPLE
$jsonDataVariable = new Variable(self::JSON_DATA);
$jsonDataAssign = new Assign($jsonDataVariable, $jsonArray);
$this->addNodeBeforeNode($jsonDataAssign, $node);
$this->nodesToAddCollector->addNodeBeforeNode($jsonDataAssign, $node);
return $jsonEncodeAssign;
}
@ -242,7 +242,7 @@ CODE_SAMPLE
$jsonDataVariable = new Variable(self::JSON_DATA);
$jsonDataAssign = new Assign($jsonDataVariable, $jsonArray);
$this->addNodeBeforeNode($jsonDataAssign, $assign);
$this->nodesToAddCollector->addNodeBeforeNode($jsonDataAssign, $assign);
return $this->createJsonEncodeAssign($assign->var, $jsonArray);
}

View File

@ -78,12 +78,12 @@ CODE_SAMPLE
$newAssign = new Assign($node->var, $node->expr->expr);
if (! $this->isExprCallOrNew($node->expr->expr)) {
$this->addNodeAfterNode($node->expr, $node);
$this->nodesToAddCollector->addNodeAfterNode($node->expr, $node);
return $newAssign;
}
$varAssign = new Assign($node->expr->var, $node->var);
$this->addNodeBeforeNode(new Expression($newAssign), $node);
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($newAssign), $node);
return $varAssign;
}

View File

@ -86,7 +86,7 @@ CODE_SAMPLE
$messageVariable = new Variable('message');
$assign = new Assign($messageVariable, $argValue);
$this->addNodeBeforeNode($assign, $node);
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node);
$node->args[0]->value = $messageVariable;

View File

@ -118,7 +118,7 @@ CODE_SAMPLE
}
$arrayDimFetch->dim = $node->var;
$this->addNodeAfterNode($this->processPrePost($node), $arrayDimFetch);
$this->nodesToAddCollector->addNodeAfterNode($this->processPrePost($node), $arrayDimFetch);
return $arrayDimFetch->dim;
}

View File

@ -151,7 +151,7 @@ CODE_SAMPLE
}
$this->stmtsHashed[$hash] = true;
$this->addNodeAfterNode(new Nop(), $node);
$this->nodesToAddCollector->addNodeAfterNode(new Nop(), $node);
return $node;
}

View File

@ -196,7 +196,7 @@ CODE_SAMPLE
}
if ($this->phpVersionConstraint >= $value->value) {
$this->addNodesBeforeNode($if->stmts, $if);
$this->nodesToAddCollector->addNodesBeforeNode($if->stmts, $if);
$this->removeNode($if);
}
@ -214,7 +214,7 @@ CODE_SAMPLE
}
if ($this->phpVersionConstraint >= $value->value) {
$this->addNodesBeforeNode($if->stmts, $if);
$this->nodesToAddCollector->addNodesBeforeNode($if->stmts, $if);
$this->removeNode($if);
}
@ -259,7 +259,7 @@ CODE_SAMPLE
}
if ($this->phpVersionConstraint >= $value->value) {
$this->addNodesBeforeNode($if->stmts, $if);
$this->nodesToAddCollector->addNodesBeforeNode($if->stmts, $if);
$this->removeNode($if);
}

View File

@ -133,7 +133,7 @@ CODE_SAMPLE
}
if ($if->cond === $instanceof) {
$this->addNodesBeforeNode($if->stmts, $if);
$this->nodesToAddCollector->addNodesBeforeNode($if->stmts, $if);
}
$this->removeNode($if);

View File

@ -70,7 +70,7 @@ CODE_SAMPLE
}
foreach ($node->stmts as $stmt) {
$this->addNodeBeforeNode($stmt, $node);
$this->nodesToAddCollector->addNodeBeforeNode($stmt, $node);
}
$this->removeNode($node);

View File

@ -106,7 +106,7 @@ CODE_SAMPLE
}
$this->removeCurrentNode($node);
$this->addNodesAfterNode($nodesToAdd, $node);
$this->nodesToAddCollector->addNodesAfterNode($nodesToAdd, $node);
return null;
}

View File

@ -129,7 +129,7 @@ CODE_SAMPLE
return null;
}
$this->addNodesBeforeNode($assignAndRootExprAndNodesToAdd->getNodesToAdd(), $node);
$this->nodesToAddCollector->addNodesBeforeNode($assignAndRootExprAndNodesToAdd->getNodesToAdd(), $node);
return $assignAndRootExprAndNodesToAdd->getRootCallerExpr();
}
@ -144,7 +144,7 @@ CODE_SAMPLE
$newVariable = $this->variableFromNewFactory->create($new);
$nodesToAdd[] = $this->fluentMethodCallAsArgFactory->createFluentAsArg($methodCall, $newVariable);
$this->addNodesBeforeNode($nodesToAdd, $methodCall);
$this->nodesToAddCollector->addNodesBeforeNode($nodesToAdd, $methodCall);
$this->removeParentParent($methodCall);
}

View File

@ -101,7 +101,7 @@ CODE_SAMPLE
}
$newStmts = $this->nonFluentChainMethodCallFactory->createFromNewAndRootMethodCall($new, $node);
$this->addNodesBeforeNode($newStmts, $node);
$this->nodesToAddCollector->addNodesBeforeNode($newStmts, $node);
// change new arg to root variable
$newVariable = $this->variableFromNewFactory->create($new);

View File

@ -113,7 +113,7 @@ CODE_SAMPLE
}
$this->fluentNodeRemover->removeCurrentNode($node);
$this->addNodesAfterNode($assignAndRootExprAndNodesToAdd->getNodesToAdd(), $node);
$this->nodesToAddCollector->addNodesAfterNode($assignAndRootExprAndNodesToAdd->getNodesToAdd(), $node);
return null;
}

View File

@ -90,7 +90,7 @@ CODE_SAMPLE
}
$this->fluentNodeRemover->removeCurrentNode($node);
$this->addNodesAfterNode($nodesToAdd, $node);
$this->nodesToAddCollector->addNodesAfterNode($nodesToAdd, $node);
return null;
}

View File

@ -97,7 +97,7 @@ CODE_SAMPLE
}
$this->fluentNodeRemover->removeCurrentNode($node);
$this->addNodesAfterNode($nodesToAdd, $node);
$this->nodesToAddCollector->addNodesAfterNode($nodesToAdd, $node);
return $node;
}

View File

@ -82,7 +82,7 @@ CODE_SAMPLE
$funcName = new Name('ini_set');
$iniSet = new FuncCall($funcName, [new Arg($sessionKey), new Arg($option->value)]);
$this->addNodeBeforeNode(new Expression($iniSet), $currentStatement);
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($iniSet), $currentStatement);
}
unset($node->args[0]);

View File

@ -99,7 +99,7 @@ CODE_SAMPLE
$variableAssignName = $this->variableNaming->createCountedValueName('battleShipcompare', $scope);
$variableAssign = new Variable($variableAssignName);
$assignExpression = $this->getAssignExpression($anonymousFunction, $variableAssign);
$this->addNodeBeforeNode($assignExpression, $currentStatement);
$this->nodesToAddCollector->addNodeBeforeNode($assignExpression, $currentStatement);
return new FuncCall($variableAssign, [new Arg($node->left), new Arg($node->right)]);
}

View File

@ -101,7 +101,7 @@ CODE_SAMPLE
if ($parent instanceof Assign) {
$this->mirrorComments($assignExpressions[0], $parentExpression);
$this->addNodesBeforeNode($assignExpressions, $node);
$this->nodesToAddCollector->addNodesBeforeNode($assignExpressions, $node);
$this->removeNode($parentExpression);
return $node;
@ -117,7 +117,7 @@ CODE_SAMPLE
if ($stmts === []) {
$parent->stmts = $assignExpressions;
} else {
$this->addNodesBeforeNode($assignExpressions, $parent->stmts[0]);
$this->nodesToAddCollector->addNodesBeforeNode($assignExpressions, $parent->stmts[0]);
}
return $parent->valueVar;

View File

@ -70,7 +70,7 @@ CODE_SAMPLE
continue;
}
$this->addNodeAfterNode(new Catch_([$catchType], $catch->var, $catch->stmts), $node->catches[$key]);
$this->nodesToAddCollector->addNodeAfterNode(new Catch_([$catchType], $catch->var, $catch->stmts), $node->catches[$key]);
}
}

View File

@ -275,7 +275,7 @@ CODE_SAMPLE
{
$parent = $funcCall->getAttribute(AttributeKey::PARENT_NODE);
if ($parent instanceof Expression) {
$this->addNodeAfterNode($replaceEmptystringToNull, $funcCall);
$this->nodesToAddCollector->addNodeAfterNode($replaceEmptystringToNull, $funcCall);
return $funcCall;
}
@ -316,12 +316,12 @@ CODE_SAMPLE
? $cond->right
: $cond->left;
if ($this->valueResolver->isFalse($valueCompare)) {
$this->addNodeAfterNode($replaceEmptystringToNull, $if);
$this->nodesToAddCollector->addNodeAfterNode($replaceEmptystringToNull, $if);
}
}
if ($cond instanceof BooleanNot) {
$this->addNodeAfterNode($replaceEmptystringToNull, $if);
$this->nodesToAddCollector->addNodeAfterNode($replaceEmptystringToNull, $if);
}
return $funcCall;
@ -331,7 +331,7 @@ CODE_SAMPLE
{
if ($if->stmts !== []) {
$firstStmt = $if->stmts[0];
$this->addNodeBeforeNode($funcCall, $firstStmt);
$this->nodesToAddCollector->addNodeBeforeNode($funcCall, $firstStmt);
} else {
$if->stmts[0] = new Expression($funcCall);
}

View File

@ -101,7 +101,7 @@ CODE_SAMPLE
$function = $this->createClosure();
$assign = new Assign(new Variable('streamIsatty'), $function);
$this->addNodeBeforeNode($assign, $node);
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node);
return new FuncCall(new Variable('streamIsatty'), $node->args);
}

View File

@ -76,7 +76,7 @@ CODE_SAMPLE
$array = $funcCall->args[0]->value;
$resetFuncCall = $this->nodeFactory->createFuncCall('reset', [$array]);
$this->addNodeBeforeNode($resetFuncCall, $funcCall);
$this->nodesToAddCollector->addNodeBeforeNode($resetFuncCall, $funcCall);
$funcCall->name = new Name('key');
@ -87,7 +87,7 @@ CODE_SAMPLE
{
$array = $funcCall->args[0]->value;
$resetFuncCall = $this->nodeFactory->createFuncCall('end', [$array]);
$this->addNodeBeforeNode($resetFuncCall, $funcCall);
$this->nodesToAddCollector->addNodeBeforeNode($resetFuncCall, $funcCall);
$funcCall->name = new Name('key');

View File

@ -109,7 +109,7 @@ CODE_SAMPLE
// Add new nodes to do the assignment by reference
$newNodes = $this->createAssignRefArrayFromListReferences($node->items, $exprVariable, []);
$this->addNodesAfterNode($newNodes, $node);
$this->nodesToAddCollector->addNodesAfterNode($newNodes, $node);
// Remove the stale params right-most-side
return $this->removeStaleParams($node, $rightSideRemovableParamsCount);

View File

@ -210,7 +210,7 @@ CODE_SAMPLE
);
// Assign the value to the variable, and replace the element with the variable
$newVariable = new Variable($variableName);
$this->addNodeBeforeNode(new Assign($newVariable, $arrayItem->value), $array);
$this->nodesToAddCollector->addNodeBeforeNode(new Assign($newVariable, $arrayItem->value), $array);
return $newVariable;
}

View File

@ -119,7 +119,7 @@ CODE_SAMPLE
);
// Assign the value to the variable
$newVariable = new Variable($variableName);
$this->addNodeBeforeNode(new Assign($newVariable, $allowableTagsParam), $node);
$this->nodesToAddCollector->addNodeBeforeNode(new Assign($newVariable, $allowableTagsParam), $node);
// Apply refactor on the variable
$newExpr = $this->createIsArrayTernaryFromExpression($newVariable);

View File

@ -139,7 +139,7 @@ CODE_SAMPLE
? $ternary->cond
: $ternary->if;
$this->addNodeAfterNode(new Expression($assign), $if);
$this->nodesToAddCollector->addNodeAfterNode(new Expression($assign), $if);
return $if;
}
@ -160,7 +160,7 @@ CODE_SAMPLE
}
$assign->expr = $coalesce->left;
$this->addNodeAfterNode(new Expression($assign), $if);
$this->nodesToAddCollector->addNodeAfterNode(new Expression($assign), $if);
return $if;
}

View File

@ -141,7 +141,7 @@ CODE_SAMPLE
Foreach_ $foreach
): Foreach_ {
$this->removeNode($expression);
$this->addNodeBeforeNode(new Return_($assign->expr), $breaks[0]);
$this->nodesToAddCollector->addNodeBeforeNode(new Return_($assign->expr), $breaks[0]);
$this->removeNode($breaks[0]);
$return->expr = $assignPreviousVariable->expr;

View File

@ -104,7 +104,7 @@ CODE_SAMPLE
$booleanAndConditions = $this->booleanAndAnalyzer->findBooleanAndConditions($expr);
if (! $ifNextReturn instanceof Return_) {
$this->addNodeAfterNode($node->stmts[0], $node);
$this->nodesToAddCollector->addNodeAfterNode($node->stmts[0], $node);
return $this->processReplaceIfs($node, $booleanAndConditions, new Return_());
}
@ -114,7 +114,7 @@ CODE_SAMPLE
$this->removeNode($ifNextReturn);
$ifNextReturn = $node->stmts[0];
$this->addNodeAfterNode($ifNextReturn, $node);
$this->nodesToAddCollector->addNodeAfterNode($ifNextReturn, $node);
$ifNextReturnClone = $ifNextReturn instanceof Return_
? clone $ifNextReturn
@ -128,7 +128,7 @@ CODE_SAMPLE
return null;
}
$this->addNodeAfterNode(new Return_(), $node);
$this->nodesToAddCollector->addNodeAfterNode(new Return_(), $node);
return $this->processReplaceIfs($node, $booleanAndConditions, $ifNextReturnClone);
}
@ -142,7 +142,7 @@ CODE_SAMPLE
$this->mirrorComments($ifs[0], $node);
foreach ($ifs as $if) {
$this->addNodeBeforeNode($if, $node);
$this->nodesToAddCollector->addNodeBeforeNode($if, $node);
}
$this->removeNode($node);

View File

@ -110,7 +110,7 @@ CODE_SAMPLE
foreach ($nestedIfsWithOnlyReturn as $key => $nestedIfWithOnlyReturn) {
// last item → the return node
if ($nestedIfsWithOnlyReturnCount === $key + 1) {
$this->addNodeAfterNode($nestedIfWithOnlyReturn, $if);
$this->nodesToAddCollector->addNodeAfterNode($nestedIfWithOnlyReturn, $if);
} else {
$this->addStandaloneIfsWithReturn($nestedIfWithOnlyReturn, $if, $nextReturn);
}
@ -127,17 +127,17 @@ CODE_SAMPLE
if ($invertedCondition instanceof BooleanNot && $invertedCondition->expr instanceof BooleanAnd) {
$booleanNotPartIf = new If_(new BooleanNot($invertedCondition->expr->left));
$booleanNotPartIf->stmts = [clone $return];
$this->addNodeAfterNode($booleanNotPartIf, $if);
$this->nodesToAddCollector->addNodeAfterNode($booleanNotPartIf, $if);
$booleanNotPartIf = new If_(new BooleanNot($invertedCondition->expr->right));
$booleanNotPartIf->stmts = [clone $return];
$this->addNodeAfterNode($booleanNotPartIf, $if);
$this->nodesToAddCollector->addNodeAfterNode($booleanNotPartIf, $if);
return;
}
$nestedIfWithOnlyReturn->cond = $invertedCondition;
$nestedIfWithOnlyReturn->stmts = [clone $return];
$this->addNodeAfterNode($nestedIfWithOnlyReturn, $if);
$this->nodesToAddCollector->addNodeAfterNode($nestedIfWithOnlyReturn, $if);
}
}

View File

@ -104,7 +104,7 @@ CODE_SAMPLE
$this->mirrorComments($if, $node);
}
$this->addNodeBeforeNode($if, $node);
$this->nodesToAddCollector->addNodeBeforeNode($if, $node);
}
$this->removeNode($node);

View File

@ -99,7 +99,7 @@ CODE_SAMPLE
$this->mirrorComments($if, $node);
}
$this->addNodeBeforeNode($if, $node);
$this->nodesToAddCollector->addNodeBeforeNode($if, $node);
}
$this->removeNode($node);

View File

@ -87,7 +87,7 @@ CODE_SAMPLE
$if = new If_($node->cond);
$if->stmts = $node->stmts;
$this->addNodeBeforeNode($if, $node);
$this->nodesToAddCollector->addNodeBeforeNode($if, $node);
$this->mirrorComments($if, $node);
/** @var ElseIf_ $firstElseIf */
@ -98,19 +98,19 @@ CODE_SAMPLE
$statements = $this->getStatementsElseIfs($node);
if ($statements !== []) {
$this->addNodesAfterNode($statements, $node);
$this->nodesToAddCollector->addNodesAfterNode($statements, $node);
}
if ($originalNode->else instanceof Else_) {
$node->else = null;
$this->addNodeAfterNode($originalNode->else, $node);
$this->nodesToAddCollector->addNodeAfterNode($originalNode->else, $node);
}
return $node;
}
if ($node->else !== null) {
$this->addNodesAfterNode($node->else->stmts, $node);
$this->nodesToAddCollector->addNodesAfterNode($node->else->stmts, $node);
$node->else = null;
return $node;
}

View File

@ -85,14 +85,14 @@ CODE_SAMPLE
$this->mirrorComments($ifNegations[0], $node);
foreach ($ifNegations as $ifNegation) {
$this->addNodeBeforeNode($ifNegation, $node);
$this->nodesToAddCollector->addNodeBeforeNode($ifNegation, $node);
}
/** @var BooleanAnd $booleanAnd */
$booleanAnd = $node->expr;
$lastReturnExpr = $this->assignAndBinaryMap->getTruthyExpr($booleanAnd->right);
$this->addNodeBeforeNode(new Return_($lastReturnExpr), $node);
$this->nodesToAddCollector->addNodeBeforeNode(new Return_($lastReturnExpr), $node);
$this->removeNode($node);
return $node;

View File

@ -93,11 +93,11 @@ CODE_SAMPLE
$this->mirrorComments($ifs[0], $node);
foreach ($ifs as $if) {
$this->addNodeBeforeNode($if, $node);
$this->nodesToAddCollector->addNodeBeforeNode($if, $node);
}
$lastReturnExpr = $this->assignAndBinaryMap->getTruthyExpr($booleanOr->right);
$this->addNodeBeforeNode(new Return_($lastReturnExpr), $node);
$this->nodesToAddCollector->addNodeBeforeNode(new Return_($lastReturnExpr), $node);
$this->removeNode($node);
return $node;

View File

@ -108,7 +108,7 @@ CODE_SAMPLE
$newFuncCall = new FuncCall(new Name('mysql_fetch_array'), [$funcCall->args[0]]);
$newAssignNode = new Assign($assign->var, new ArrayDimFetch($newFuncCall, new LNumber(0)));
$this->addNodeAfterNode($newAssignNode, $assign);
$this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign);
return $funcCall;
}
@ -120,10 +120,10 @@ CODE_SAMPLE
$mysqlFetchRowFuncCall = new FuncCall(new Name('mysqli_fetch_row'), [$funcCall->args[0]]);
$fetchVariable = new Variable('fetch');
$newAssignNode = new Assign($fetchVariable, $mysqlFetchRowFuncCall);
$this->addNodeAfterNode($newAssignNode, $assign);
$this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign);
$newAssignNode = new Assign($assign->var, new ArrayDimFetch($fetchVariable, new LNumber(0)));
$this->addNodeAfterNode($newAssignNode, $assign);
$this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign);
return $funcCall;
}
@ -133,7 +133,7 @@ CODE_SAMPLE
$funcCall->name = new Name('mysqli_select_db');
$newAssignNode = new Assign($assign->var, new FuncCall(new Name('mysqli_query'), [$funcCall->args[1]]));
$this->addNodeAfterNode($newAssignNode, $assign);
$this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign);
unset($funcCall->args[1]);
@ -162,10 +162,10 @@ CODE_SAMPLE
$mysqlFetchArrayFuncCall = new FuncCall(new Name('mysqli_fetch_array'), [$funcCall->args[0]]);
$fetchVariable = new Variable('fetch');
$newAssignNode = new Assign($fetchVariable, $mysqlFetchArrayFuncCall);
$this->addNodeAfterNode($newAssignNode, $assign);
$this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign);
$newAssignNode = new Assign($assign->var, new ArrayDimFetch($fetchVariable, $fetchField ?? new LNumber(0)));
$this->addNodeAfterNode($newAssignNode, $assign);
$this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign);
return $funcCall;
}

View File

@ -86,7 +86,7 @@ final class NonVariableToVariableOnFunctionCallRector extends AbstractRector
$current = $node->getAttribute(AttributeKey::CURRENT_STATEMENT);
$currentStatement = $node->getAttribute(AttributeKey::CURRENT_STATEMENT);
$this->addNodeBeforeNode(
$this->nodesToAddCollector->addNodeBeforeNode(
$replacements->getAssign(),
$current instanceof Return_ ? $current : $currentStatement
);

View File

@ -81,7 +81,7 @@ CODE_SAMPLE
// only value: list(, $value) = each($values);
if ($listNode->items[1] && $listNode->items[0] === null) {
$nextFuncCall = $this->nodeFactory->createFuncCall('next', $eachFuncCall->args);
$this->addNodeAfterNode($nextFuncCall, $node);
$this->nodesToAddCollector->addNodeAfterNode($nextFuncCall, $node);
$currentFuncCall = $this->nodeFactory->createFuncCall('current', $eachFuncCall->args);
@ -98,10 +98,10 @@ CODE_SAMPLE
}
$assign = new Assign($secondArrayItem->value, $currentFuncCall);
$this->addNodeAfterNode($assign, $node);
$this->nodesToAddCollector->addNodeAfterNode($assign, $node);
$nextFuncCall = $this->nodeFactory->createFuncCall('next', $eachFuncCall->args);
$this->addNodeAfterNode($nextFuncCall, $node);
$this->nodesToAddCollector->addNodeAfterNode($nextFuncCall, $node);
$keyFuncCall = $this->nodeFactory->createFuncCall('key', $eachFuncCall->args);

View File

@ -73,7 +73,7 @@ CODE_SAMPLE
$assignVariable = $node->var;
$newNodes = $this->createNewNodes($assignVariable, $eachedVariable);
$this->addNodesAfterNode($newNodes, $node);
$this->nodesToAddCollector->addNodesAfterNode($newNodes, $node);
$this->removeNode($node);
return null;

View File

@ -258,7 +258,7 @@ final class PhpSpecPromisesToPHPUnitAssertRector extends AbstractPhpSpecToPHPUni
$methodCall->args = [];
$funcCall->args[] = new Arg($methodCall);
$this->addNodesAfterNode([$assign, $funcCall], $methodCall);
$this->nodesToAddCollector->addNodesAfterNode([$assign, $funcCall], $methodCall);
$this->removeNode($methodCall);

View File

@ -109,7 +109,7 @@ CODE_SAMPLE
$unwrappedNodes = $this->unwrapClosureFactory->createAssign($resultVariable, $arg);
$arg->value = $resultVariable;
$this->addNodesBeforeNode($unwrappedNodes, $node);
$this->nodesToAddCollector->addNodesBeforeNode($unwrappedNodes, $node);
return $node;
}