Skip to content

Commit c3fcbe2

Browse files
committed
move is-test-case check into TestMethodsHelper
1 parent 4bf9ac2 commit c3fcbe2

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/Rules/PHPUnit/DataProviderDataRule.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PHPStan\Rules\Rule;
99
use PHPStan\Type\ObjectType;
1010
use PHPStan\Type\Type;
11-
use PHPUnit\Framework\TestCase;
1211
use function array_slice;
1312
use function count;
1413
use function max;
@@ -62,10 +61,7 @@ public function processNode(Node $node, Scope $scope): array
6261

6362
$method = $scope->getFunction();
6463
$classReflection = $scope->getClassReflection();
65-
if (
66-
$classReflection === null
67-
|| !$classReflection->is(TestCase::class)
68-
) {
64+
if ($classReflection === null) {
6965
return [];
7066
}
7167

src/Rules/PHPUnit/TestMethodsHelper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHPStan\PhpDoc\ResolvedPhpDocBlock;
77
use PHPStan\Reflection\ClassReflection;
88
use PHPStan\Type\FileTypeMapper;
9+
use PHPUnit\Framework\TestCase;
910
use ReflectionMethod;
1011
use function str_starts_with;
1112
use function strtolower;
@@ -31,6 +32,10 @@ public function __construct(
3132
*/
3233
public function getTestMethods(ClassReflection $classReflection, Scope $scope): array
3334
{
35+
if (!$classReflection->is(TestCase::class)) {
36+
return [];
37+
}
38+
3439
$testMethods = [];
3540
foreach ($classReflection->getNativeReflection()->getMethods() as $reflectionMethod) {
3641
if (!$reflectionMethod->isPublic()) {

tests/Type/PHPUnit/DataProviderReturnTypeIgnoreExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ protected function getRule(): Rule
1414
{
1515
/** @phpstan-ignore phpstanApi.classConstant */
1616
$rule = self::getContainer()->getByType(MissingMethodReturnTypehintRule::class);
17-
17+
1818
return $rule;
1919
}
2020

0 commit comments

Comments
 (0)