Skip to content

Commit a9225a6

Browse files
committed
fix
1 parent 6e321dd commit a9225a6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Type/PHPUnit/DataProviderReturnTypeIgnoreExtension.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Error;
77
use PHPStan\Analyser\IgnoreErrorExtension;
88
use PHPStan\Analyser\Scope;
9-
use PHPStan\Node\InClassMethodNode;
109
use PHPStan\Rules\PHPUnit\DataProviderHelper;
1110
use PHPStan\Rules\PHPUnit\TestMethodsHelper;
1211

@@ -28,16 +27,20 @@ public function __construct(
2827

2928
public function shouldIgnore(Error $error, Node $node, Scope $scope): bool
3029
{
31-
if (! $node instanceof InClassMethodNode) { // @phpstan-ignore phpstanApi.instanceofAssumption
30+
if (!$scope->isInClass()) {
3231
return false;
3332
}
3433

3534
if ($error->getIdentifier() !== 'missingType.iterableValue') {
3635
return false;
3736
}
3837

39-
$classReflection = $node->getClassReflection();
40-
$methodReflection = $node->getMethodReflection();
38+
$methodReflection = $scope->getFunction();
39+
if ($methodReflection === null) {
40+
return false;
41+
}
42+
43+
$classReflection = $scope->getClassReflection();
4144
$testMethods = $this->testMethodsHelper->getTestMethods($classReflection, $scope);
4245
foreach ($testMethods as $testMethod) {
4346
foreach ($this->dataProviderHelper->getDataProviderMethods($scope, $testMethod, $classReflection) as [, $providerMethodName]) {

0 commit comments

Comments
 (0)