From 21fc218e086b066bf4824cdd2d987f971dd71983 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 20 Jun 2022 20:00:08 +0700 Subject: [PATCH] [Core] AbstractScopeAwareRector is ready to be used in custom rules (#2537) --- rules/Php70/Rector/FuncCall/MultiDirnameRector.php | 7 +------ src/Rector/AbstractScopeAwareRector.php | 4 ---- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/rules/Php70/Rector/FuncCall/MultiDirnameRector.php b/rules/Php70/Rector/FuncCall/MultiDirnameRector.php index c1f8abb7675..c38c338f0a9 100644 --- a/rules/Php70/Rector/FuncCall/MultiDirnameRector.php +++ b/rules/Php70/Rector/FuncCall/MultiDirnameRector.php @@ -61,7 +61,7 @@ public function refactor(Node $node): ?Node } // nothing to improve - if ($this->shouldSkip()) { + if ($this->nestingLevel < 2) { return null; } @@ -76,11 +76,6 @@ public function provideMinPhpVersion(): int return PhpVersionFeature::DIRNAME_LEVELS; } - private function shouldSkip(): bool - { - return $this->nestingLevel < 2; - } - private function matchNestedDirnameFuncCall(FuncCall $funcCall): ?FuncCall { if (! $this->isName($funcCall, self::DIRNAME)) { diff --git a/src/Rector/AbstractScopeAwareRector.php b/src/Rector/AbstractScopeAwareRector.php index a05046cd673..22c77dfce38 100644 --- a/src/Rector/AbstractScopeAwareRector.php +++ b/src/Rector/AbstractScopeAwareRector.php @@ -10,10 +10,6 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\NodeTypeResolver\Node\AttributeKey; -/** - * @internal Currently in experimental testing for core Rector rules. So we can verify if this feature is useful or not. - * Do not use outside in custom rules. Go for AbstractRector instead. - */ abstract class AbstractScopeAwareRector extends AbstractRector implements ScopeAwarePhpRectorInterface { /**