Skip to content

Commit 92b1b5b

Browse files
authored
Directly use isName(s) and getName() on rector rules (#277)
1 parent 9d2e956 commit 92b1b5b

8 files changed

+11
-11
lines changed

rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ private function resolveVariableFromCallLikeScope(CallLike $callLike, ?Scope $sc
126126
{
127127
/** @var MethodCall|FuncCall|StaticCall|New_|NullsafeMethodCall $callLike */
128128
if ($callLike instanceof New_) {
129-
$variableName = (string) $this->nodeNameResolver->getName($callLike->class);
129+
$variableName = (string) $this->getName($callLike->class);
130130
} else {
131-
$variableName = (string) $this->nodeNameResolver->getName($callLike->name);
131+
$variableName = (string) $this->getName($callLike->name);
132132
}
133133

134134
if ($variableName === '') {
@@ -253,7 +253,7 @@ private function resolveCastedArray(Expr $expr): Expr|Variable
253253
$scope = $expr->getAttribute(AttributeKey::SCOPE);
254254

255255
$variableName = $this->variableNaming->createCountedValueName(
256-
(string) $this->nodeNameResolver->getName($expr->expr),
256+
(string) $this->getName($expr->expr),
257257
$scope
258258
);
259259

rules/DowngradePhp80/Rector/ClassMethod/DowngradeRecursiveDirectoryIteratorHasChildrenRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function refactor(Node $node): ?Node
7373
continue;
7474
}
7575

76-
if (! $this->nodeNameResolver->isName($classMethod, 'hasChildren')) {
76+
if (! $this->isName($classMethod, 'hasChildren')) {
7777
continue;
7878
}
7979

rules/DowngradePhp80/Rector/ClassMethod/DowngradeStringReturnTypeOnToStringRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private function shouldSkip(ClassMethod $classMethod): bool
9999
return true;
100100
}
101101

102-
if (! $this->nodeNameResolver->isName($classMethod, '__toString')) {
102+
if (! $this->isName($classMethod, '__toString')) {
103103
return true;
104104
}
105105

rules/DowngradePhp80/Rector/FuncCall/DowngradeNumberFormatNoFourthArgRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function refactor(Node $node): ?Node
8181

8282
private function shouldSkip(FuncCall $funcCall): bool
8383
{
84-
if (! $this->nodeNameResolver->isName($funcCall, 'number_format')) {
84+
if (! $this->isName($funcCall, 'number_format')) {
8585
return true;
8686
}
8787

rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionClassGetConstantsFilterRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ private function shouldSkipClassConstFetch(ClassConstFetch $classConstFetch): bo
238238
}
239239

240240
$constants = array_keys(self::MAP_CONSTANT_TO_METHOD);
241-
return ! $this->nodeNameResolver->isNames($classConstFetch->name, $constants);
241+
return ! $this->isNames($classConstFetch->name, $constants);
242242
}
243243

244244
private function shouldSkipMethodCall(MethodCall $methodCall): bool
245245
{
246-
if (! $this->nodeNameResolver->isName($methodCall->name, 'getConstants')) {
246+
if (! $this->isName($methodCall->name, 'getConstants')) {
247247
return true;
248248
}
249249

rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionPropertyGetDefaultValueRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getNodeTypes(): array
5959
*/
6060
public function refactor(Node $node): ?Node
6161
{
62-
if (! $this->nodeNameResolver->isName($node->name, 'getDefaultValue')) {
62+
if (! $this->isName($node->name, 'getDefaultValue')) {
6363
return null;
6464
}
6565

rules/DowngradePhp81/Rector/FuncCall/DowngradeArrayIsListRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private function shouldSkip(CallLike $callLike): bool
140140
return false;
141141
}
142142

143-
if (! $this->nodeNameResolver->isName($callLike, 'array_is_list')) {
143+
if (! $this->isName($callLike, 'array_is_list')) {
144144
return true;
145145
}
146146

rules/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHashRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private function shouldSkip(FuncCall $funcCall): bool
108108
return true;
109109
}
110110

111-
return ! $this->nodeNameResolver->isName($funcCall, 'hash');
111+
return ! $this->isName($funcCall, 'hash');
112112
}
113113

114114
/**

0 commit comments

Comments
 (0)