From 17b86d4b7728ceeb245226f2735b7b4abf6c58a8 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 9 Jun 2022 13:02:39 +0700 Subject: [PATCH] [CodeQuality] Remove unnecessary check next return removed no SimplifyIfElseToTernaryRector (#2457) --- .../If_/SimplifyIfElseToTernaryRector.php | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php b/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php index de83774a908..8948f046bc9 100644 --- a/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php +++ b/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php @@ -12,10 +12,8 @@ use PhpParser\Node\Expr\Ternary; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\If_; -use PhpParser\Node\Stmt\Return_; use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Rector\AbstractRector; -use Rector\NodeTypeResolver\Node\AttributeKey; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -126,40 +124,12 @@ CODE_SAMPLE return null; } - if ($this->isNextReturnRemoved($node, $ifAssignVar)) { - return null; - } - $expression = new Expression($assign); $this->mirrorComments($expression, $node); return $expression; } - private function isNextReturnRemoved(If_ $if, Expr $expr): bool - { - if (! $this->nodesToRemoveCollector->isActive()) { - return false; - } - - $next = $if->getAttribute(AttributeKey::NEXT_NODE); - - if ($next instanceof Return_ && $next->expr instanceof Expr && $this->nodeComparator->areNodesEqual( - $next->expr, - $expr - )) { - $nodesToRemove = $this->nodesToRemoveCollector->getNodesToRemove(); - - foreach ($nodesToRemove as $nodeToRemove) { - if ($this->nodeComparator->areNodesEqual($next, $nodeToRemove)) { - return true; - } - } - } - - return false; - } - /** * @param Stmt[] $stmts */