Skip to content

Commit

Permalink
Codestyle fixes, sure.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrala committed Jan 17, 2024
1 parent cdc3c55 commit 4a2e739
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions src/Drupal8/Rector/Deprecation/DBRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,37 +98,37 @@ public function refactor(Node $node): ?Node
{
assert($node instanceof Node\Stmt\Expression);

$isFuncCall = $node->expr instanceof Node\Expr\FuncCall;
$isMethodCall = $node->expr instanceof Node\Expr\MethodCall;
$isAssignedFuncCall = $node->expr instanceof Node\Expr\Assign && $node->expr->expr instanceof Node\Expr\FuncCall;
$isFuncCall = $node->expr instanceof Expr\FuncCall;
$isMethodCall = $node->expr instanceof MethodCall;
$isAssignedFuncCall = $node->expr instanceof Expr\Assign && $node->expr->expr instanceof Expr\FuncCall;
if (!$isFuncCall && !$isAssignedFuncCall && !$isMethodCall) {
return null;
}

foreach ($this->configuration as $configuration) {
if ($node->expr instanceof Node\Expr\FuncCall && $this->getName($node->expr->name) !== $configuration->getDeprecatedMethodName()) {
if ($node->expr instanceof Expr\FuncCall && $this->getName($node->expr->name) !== $configuration->getDeprecatedMethodName()) {
continue;
}

if ($node->expr instanceof Node\Expr\Assign && $node->expr->expr instanceof Node\Expr\FuncCall && $this->getName($node->expr->expr->name) !== $configuration->getDeprecatedMethodName()) {
if ($node->expr instanceof Expr\Assign && $node->expr->expr instanceof Expr\FuncCall && $this->getName($node->expr->expr->name) !== $configuration->getDeprecatedMethodName()) {
continue;
}

if ($node->expr instanceof Node\Expr\FuncCall) {
if ($node->expr instanceof Expr\FuncCall) {
$methodCall = $this->getMethodCall($node->expr, $node, $configuration);
$node->expr = $methodCall;

return $node;
}

if ($node->expr instanceof Node\Expr\Assign && $node->expr->expr instanceof Node\Expr\FuncCall) {
if ($node->expr instanceof Expr\Assign && $node->expr->expr instanceof Expr\FuncCall) {
$methodCall = $this->getMethodCall($node->expr->expr, $node, $configuration);
$node->expr->expr = $methodCall;

return $node;
}

if ($node->expr instanceof Node\Expr\MethodCall) {
if ($node->expr instanceof MethodCall) {
$funcCall = $this->findRootFuncCallForMethodCall($node->expr);
if ($funcCall === null || $this->getName($funcCall->name) !== $configuration->getDeprecatedMethodName()) {
continue;
Expand Down Expand Up @@ -187,7 +187,7 @@ public function replaceFuncCallForMethodCall(MethodCall $expr, MethodCall $metho
return null;
}

public function getMethodCall(Node\Expr\FuncCall $expr, Node\Stmt\Expression $statement, DBConfiguration $configuration): Node\Expr\MethodCall
public function getMethodCall(Expr\FuncCall $expr, Node\Stmt\Expression $statement, DBConfiguration $configuration): MethodCall
{
// TODO: Check if we have are in a class and inject \Drupal\Core\Database\Connection
// TODO: Check if we have are in a class and don't have access to the container, use `\Drupal\core\Database\Database::getConnection()`.
Expand Down Expand Up @@ -229,11 +229,11 @@ public function getMethodCall(Node\Expr\FuncCall $expr, Node\Stmt\Expression $st
$this->commentService->addDrupalRectorComment($statement, 'You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.');
}

$var = new Node\Expr\StaticCall($name, $call, $method_arguments);
$var = new Expr\StaticCall($name, $call, $method_arguments);

$method_name = new Node\Identifier(substr($configuration->getDeprecatedMethodName(), 3));

$methodCall = new Node\Expr\MethodCall($var, $method_name, $expr->args);
$methodCall = new MethodCall($var, $method_name, $expr->args);

return $methodCall;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Drupal8/Rector/Deprecation/EntityLoadRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function refactor(Node $node): ?Node
if (!class_exists('\PhpParser\Node\ArrayItem')) {
$arrayItems = [new Node\Expr\ArrayItem($entity_id->value)];
} else {
$arrayItems = [new \PhpParser\Node\ArrayItem($entity_id->value)];
$arrayItems = [new Node\ArrayItem($entity_id->value)];
}

$reset_args = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getNodeTypes(): array
}

/**
* @param \PhpParser\Node\Stmt\Class_ $node
* @param Node\Stmt\Class_ $node
*/
public function refactorWithScope(Node $node, Scope $scope): ?Node
{
Expand Down
2 changes: 1 addition & 1 deletion src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getNodeTypes(): array
* @param string $method
* @param array<Arg|VariadicPlaceholder> $args
*
* @return \PhpParser\Node\Expr\MethodCall
* @return Node\Expr\MethodCall
*/
protected function createAssertSessionMethodCall(string $method, array $args): Node\Expr\MethodCall
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function refactor(Node $node): ?Node
* @param string $method
* @param array<Arg|VariadicPlaceholder> $args
*
* @return \PhpParser\Node\Expr\MethodCall
* @return Node\Expr\MethodCall
*/
protected function createAssertSessionMethodCall(string $method, array $args): Node\Expr\MethodCall
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getNodeTypes(): array
}

/**
* @param \PhpParser\Node\Expr\MethodCall $node
* @param Node\Expr\MethodCall $node
*
* @throws ShouldNotHappenException
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getNodeTypes(): array
}

/**
* @param \PhpParser\Node\Stmt\Property $node
* @param Node\Stmt\Property $node
*/
public function refactor(Node $node): ?Node
{
Expand Down

0 comments on commit 4a2e739

Please sign in to comment.