Skip to content

Commit 382f406

Browse files
committed
[ci-review] Rector Rectify
1 parent 1b7755a commit 382f406

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

rules/DeadCode/NodeAnalyzer/ParentClassAnalyzer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
namespace Rector\DeadCode\NodeAnalyzer;
66

7+
use PhpParser\Node\Stmt\Expression;
8+
use PhpParser\Node\Expr\StaticCall;
79
use PhpParser\Node\Stmt\ClassMethod;
810
use Rector\NodeNameResolver\NodeNameResolver;
911

10-
final class ParentClassAnalyzer
12+
final readonly class ParentClassAnalyzer
1113
{
1214
public function __construct(
13-
private readonly NodeNameResolver $nodeNameResolver,
15+
private NodeNameResolver $nodeNameResolver,
1416
) {
1517

1618
}
@@ -28,12 +30,12 @@ public function hasParentCall(ClassMethod $classMethod): bool
2830
$classMethodName = $classMethod->name->name;
2931

3032
foreach ($classMethod->stmts as $stmt) {
31-
if (! $stmt instanceof \PhpParser\Node\Stmt\Expression) {
33+
if (! $stmt instanceof Expression) {
3234
continue;
3335
}
3436

3537
$expr = $stmt->expr;
36-
if (! $expr instanceof \PhpParser\Node\Expr\StaticCall) {
38+
if (! $expr instanceof StaticCall) {
3739
continue;
3840
}
3941

rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,8 @@ private function shouldSkipClassMethod(ClassMethod $classMethod): bool
243243
if ($this->phpAttributeAnalyzer->hasPhpAttribute($classMethod, self::OVERRIDE_CLASS)) {
244244
return true;
245245
}
246-
247246
// skip test setup method override, as rather clutters the code than helps
248-
if ($this->isName($classMethod, 'setUp')) {
249-
if ($this->parentClassAnalyzer->hasParentCall($classMethod)) {
250-
return true;
251-
}
252-
}
253-
254-
return false;
247+
return $this->isName($classMethod, 'setUp') && $this->parentClassAnalyzer->hasParentCall($classMethod);
255248
}
256249

257250
private function shouldSkipParentClassMethod(ClassReflection $parentClassReflection, ClassMethod $classMethod): bool

0 commit comments

Comments
 (0)