Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ public function refactor(Node $node): ?Node
return null;
}

// remove first arg
$originalArgs = $node->getArgs();
array_shift($originalArgs);

$methodCall = $this->arrayCallableToMethodCallFactory->create($firstArgValue);
if (! $methodCall instanceof MethodCall) {
return null;
}

$originalArgs = $node->args;
unset($originalArgs[0]);

$methodCall->args = $originalArgs;
return $methodCall;
}
Expand Down
4 changes: 4 additions & 0 deletions rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,17 @@ public function refactor(Node $node): ?Node

// remove current Stmt if will be overridden in next stmt
unset($node->stmts[$key]);

$hasChanged = true;
}

if (! $hasChanged) {
return null;
}

// update array keys to fit printer
$node->stmts = array_values($node->stmts);

return $node;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
// Cannot handle variadic args
if ($node->isFirstClassCallable()) {
return null;
}
Expand Down Expand Up @@ -106,13 +107,20 @@ private function removeContextArg(FuncCall|MethodCall $callLike): bool

unset($callLike->args[3 + $methodArgCorrection]);

// update indexed to make printer work as expected
$callLike->args = array_values($callLike->args);

return true;
}

// process named arguments
foreach ($args as $position => $arg) {
if ($arg->name instanceof Identifier && $this->isName($arg->name, 'context')) {
unset($callLike->args[$position]);

// update indexed to make printer work as expected
$callLike->args = array_values($callLike->args);

return true;
}
}
Expand Down