Skip to content

Commit 6e185e8

Browse files
[phpstan] prefer isName() from abstract class over protected service (#6875)
* [phpstan] prefer isName() from abstract class over protected service * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <[email protected]>
1 parent c475fc7 commit 6e185e8

File tree

33 files changed

+126
-43
lines changed

33 files changed

+126
-43
lines changed

phpstan.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ includes:
22
- vendor/symplify/phpstan-rules/config/symplify-rules.neon
33
- vendor/symplify/phpstan-rules/config/rector-rules.neon
44

5+
rules:
6+
- Rector\Utils\PHPStan\Rule\PreferDirectIsNameRule
7+
58
parameters:
69
level: 8
710

@@ -328,3 +331,7 @@ parameters:
328331

329332
- identifier: symplify.noConstructorOverride
330333
path: src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php
334+
335+
-
336+
identifier: symplify.seeAnnotationToTest
337+
path: utils/PHPStan/Rule/PreferDirectIsNameRule.php

rules/CodeQuality/Rector/ClassConstFetch/ConvertStaticPrivateConstantToSelfRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private function isPrivateConstant(ClassConstFetch $classConstFetch, Class_ $cla
114114
}
115115

116116
foreach ($class->getConstants() as $classConst) {
117-
if (! $this->nodeNameResolver->isName($classConst, $constantName)) {
117+
if (! $this->isName($classConst, $constantName)) {
118118
continue;
119119
}
120120

rules/CodeQuality/Rector/Class_/CompleteDynamicPropertiesRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private function shouldSkipClass(Class_ $class): bool
130130
return true;
131131
}
132132

133-
$className = (string) $this->nodeNameResolver->getName($class);
133+
$className = (string) $this->getName($class);
134134
if (! $this->reflectionProvider->hasClass($className)) {
135135
return true;
136136
}

rules/CodeQuality/Rector/Class_/InlineConstructorDefaultToPropertyRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ private function matchAssignedLocalPropertyName(Assign $assign): ?string
137137
}
138138

139139
$propertyFetch = $assign->var;
140-
if (! $this->nodeNameResolver->isName($propertyFetch->var, 'this')) {
140+
if (! $this->isName($propertyFetch->var, 'this')) {
141141
return null;
142142
}
143143

144-
$propertyName = $this->nodeNameResolver->getName($propertyFetch->name);
144+
$propertyName = $this->getName($propertyFetch->name);
145145
if (! is_string($propertyName)) {
146146
return null;
147147
}

rules/CodeQuality/Rector/Identical/SimplifyArraySearchRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function (Node $node): bool {
6262
return false;
6363
}
6464

65-
return $this->nodeNameResolver->isName($node, 'array_search');
65+
return $this->isName($node, 'array_search');
6666
},
6767
fn (Node $node): bool => $node instanceof Expr && $this->valueResolver->isFalse($node)
6868
);

rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function refactor(Node $node): null|array|Node
136136

137137
private function resolveNewConditionNode(Expr $expr, bool $isNegated): ?BinaryOp
138138
{
139-
if ($expr instanceof FuncCall && $this->nodeNameResolver->isName($expr, 'count')) {
139+
if ($expr instanceof FuncCall && $this->isName($expr, 'count')) {
140140
return $this->resolveCount($isNegated, $expr);
141141
}
142142

rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private function renameVariableInStmts(
200200
return null;
201201
}
202202

203-
if (! $this->nodeNameResolver->isName($node, $oldVariableName)) {
203+
if (! $this->isName($node, $oldVariableName)) {
204204
return null;
205205
}
206206

@@ -239,7 +239,7 @@ private function replaceNextUsageVariable(
239239
return null;
240240
}
241241

242-
if (! $this->nodeNameResolver->isName($node, $oldVariableName)) {
242+
if (! $this->isName($node, $oldVariableName)) {
243243
return null;
244244
}
245245

rules/CodingStyle/Rector/ClassMethod/NewlineBeforeNewAssignSetRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private function shouldSkipLeftVariable(Assign | MethodCall $node): bool
177177
}
178178

179179
// local method call
180-
return $this->nodeNameResolver->isName($node->var, 'this');
180+
return $this->isName($node->var, 'this');
181181
}
182182

183183
private function isNewVariableThanBefore(?string $currentStmtVariableName): bool

rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private function isIteratorToArrayFuncCall(Expr $expr): bool
198198
return false;
199199
}
200200

201-
if (! $this->nodeNameResolver->isName($expr, 'iterator_to_array')) {
201+
if (! $this->isName($expr, 'iterator_to_array')) {
202202
return false;
203203
}
204204

rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ private function shouldSkipClassMethod(Class_ $class, ClassMethod $classMethod):
164164
return true;
165165
}
166166

167-
if ($this->nodeNameResolver->isName($classMethod, MethodName::CONSTRUCT)) {
167+
if ($this->isName($classMethod, MethodName::CONSTRUCT)) {
168168
// has parent class?
169169
return $class->extends instanceof FullyQualified;
170170
}
171171

172-
return $this->nodeNameResolver->isName($classMethod, MethodName::INVOKE);
172+
return $this->isName($classMethod, MethodName::INVOKE);
173173
}
174174

175175
private function hasDeprecatedAnnotation(ClassMethod $classMethod): bool

0 commit comments

Comments
 (0)