From a1645610409fdf3292f3fee9dbf1172839a4008a Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 13 May 2025 01:15:12 +0700 Subject: [PATCH 1/2] Directly use isName(s) and getName() on rector rules --- .../Class_/ConstructClassMethodToSetUpTestCaseRector.php | 4 ++-- .../Rector/Class_/StaticDataProviderClassMethodRector.php | 2 +- .../Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/CodeQuality/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php b/rules/CodeQuality/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php index dc3a9dca..431af134 100644 --- a/rules/CodeQuality/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php +++ b/rules/CodeQuality/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php @@ -208,7 +208,7 @@ private function isParentCallNamed(Node $node, string $desiredMethodName): bool return false; } - if (! $this->nodeNameResolver->isName($node->class, 'parent')) { + if (! $this->isName($node->class, 'parent')) { return false; } @@ -216,7 +216,7 @@ private function isParentCallNamed(Node $node, string $desiredMethodName): bool return false; } - return $this->nodeNameResolver->isName($node->name, $desiredMethodName); + return $this->isName($node->name, $desiredMethodName); } private function shouldSkipClass(Class_ $class): bool diff --git a/rules/PHPUnit100/Rector/Class_/StaticDataProviderClassMethodRector.php b/rules/PHPUnit100/Rector/Class_/StaticDataProviderClassMethodRector.php index 8b6ec85f..a9298814 100644 --- a/rules/PHPUnit100/Rector/Class_/StaticDataProviderClassMethodRector.php +++ b/rules/PHPUnit100/Rector/Class_/StaticDataProviderClassMethodRector.php @@ -125,7 +125,7 @@ private function skipMethod(ClassMethod $classMethod): bool return (bool) $this->betterNodeFinder->findFirst( $classMethod->stmts, - fn (Node $node): bool => $node instanceof Variable && $this->nodeNameResolver->isName($node, 'this') + fn (Node $node): bool => $node instanceof Variable && $this->isName($node, 'this') ); } } diff --git a/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php b/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php index 39f71a1e..798acc5b 100644 --- a/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php +++ b/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php @@ -43,7 +43,7 @@ public function decorate(Expression $expression): MethodCall|StaticCall|null return null; } - if (! $this->nodeNameResolver->isName($node->name, 'expects')) { + if (! $this->isName($node->name, 'expects')) { return null; } From 7e720ed9b6321fe441522ce3549ca86c3cf97cf2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 13 May 2025 01:18:30 +0700 Subject: [PATCH 2/2] Fix ci --- .../Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php b/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php index 798acc5b..39f71a1e 100644 --- a/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php +++ b/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php @@ -43,7 +43,7 @@ public function decorate(Expression $expression): MethodCall|StaticCall|null return null; } - if (! $this->isName($node->name, 'expects')) { + if (! $this->nodeNameResolver->isName($node->name, 'expects')) { return null; }