/opt/cpanel/ea-wappspector/vendor/rector/rector/rules/CodeQuality/Rector/If_
NameSizeModeActions
CombineIfRector.php32650644editdlrm
CompleteMissingIfElseBracketRector.php31090644editdlrm
ConsecutiveNullCompareReturnsToNullCoalesceQueueRector.php52790644editdlrm
ExplicitBoolCompareRector.php92690644editdlrm
ShortenElseIfRector.php26280644editdlrm
SimplifyIfElseToTernaryRector.php50300644editdlrm
SimplifyIfNotNullReturnRector.php28630644editdlrm
SimplifyIfNullableReturnRector.php85290644editdlrm
SimplifyIfReturnBoolRector.php76700644editdlrm
Edit: /opt/cpanel/ea-wappspector/vendor/rector/rector/rules/CodeQuality/Rector/If_/CombineIfRector.php (3265B)
commentsMerger = $commentsMerger; $this->phpDocInfoFactory = $phpDocInfoFactory; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Merges nested if statements', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() { if ($cond1) { if ($cond2) { return 'foo'; } } } } CODE_SAMPLE , <<<'CODE_SAMPLE' class SomeClass { public function run() { if ($cond1 && $cond2) { return 'foo'; } } } CODE_SAMPLE )]); } /** * @return array> */ public function getNodeTypes() : array { return [If_::class]; } /** * @param If_ $node */ public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } /** @var If_ $subIf */ $subIf = $node->stmts[0]; if ($this->hasVarTag($subIf)) { return null; } $node->cond->setAttribute(AttributeKey::ORIGINAL_NODE, null); $node->cond = new BooleanAnd($node->cond, $subIf->cond); $node->stmts = $subIf->stmts; $this->commentsMerger->keepComments($node, [$subIf]); return $node; } private function shouldSkip(If_ $if) : bool { if ($if->else instanceof Else_) { return \true; } if (\count($if->stmts) !== 1) { return \true; } if ($if->elseifs !== []) { return \true; } if (!$if->stmts[0] instanceof If_) { return \true; } if ($if->stmts[0]->else instanceof Else_) { return \true; } return (bool) $if->stmts[0]->elseifs; } private function hasVarTag(If_ $if) : bool { $subIfPhpDocInfo = $this->phpDocInfoFactory->createFromNode($if); if (!$subIfPhpDocInfo instanceof PhpDocInfo) { return \false; } return $subIfPhpDocInfo->getVarTagValueNode() instanceof VarTagValueNode; } }