Skip to content

Commit 37146f4

Browse files
committed
Skip setup/teardown methods in no protected rule
1 parent 720a146 commit 37146f4

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/Rules/Explicit/NoProtectedClassStmtRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function shouldSkipClassMethod(ClassMethod|ClassConst|Property $classStm
8484

8585
// PHPUnit test methods
8686
if (in_array($classStmt->name->toString(), [MethodName::SET_UP, MethodName::TEAR_DOWN])) {
87-
return false;
87+
return true;
8888
}
8989

9090
return $this->isParentMethodOverride($classStmt, $scope);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Symplify\PHPStanRules\Tests\Rules\Explicit\NoProtectedClassStmtRule\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class SkipPHPUnitTetsCase extends TestCase
8+
{
9+
protected function setUp(): void
10+
{
11+
$value = 100;
12+
}
13+
}

tests/Rules/Explicit/NoProtectedClassStmtRule/NoProtectedClassStmtRuleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static function provideData(): Iterator
2424
[NoProtectedClassStmtRule::ERROR_MESSAGE, 7],
2525
]];
2626

27+
yield [__DIR__ . '/Fixture/SkipPHPUnitTetsCase.php', []];
2728
yield [__DIR__ . '/Fixture/SkipParentRequired.php', []];
2829
yield [__DIR__ . '/Fixture/SkipAbstractWithProtected.php', []];
2930
}

0 commit comments

Comments
 (0)