Skip to content

Commit 68ab89b

Browse files
committed
Test the data provider ignore extension with MissingImplementedMethodReturnTypehintRule too
PHPStan reports missing return types of methods with a body in MissingImplementedMethodReturnTypehintRule since phpstan/phpstan-src#7283. Amp-Thread-ID: https://ampcode.com/threads/T-01a22c96-9e21-771f-9a29-4627539ba301
1 parent 80d6e8e commit 68ab89b

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎tests/Type/PHPUnit/DataProviderReturnTypeIgnoreExtensionTest.php‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,32 @@
22

33
namespace PHPStan\Type\PHPUnit;
44

5+
use PHPStan\Rules\Methods\MissingImplementedMethodReturnTypehintRule;
56
use PHPStan\Rules\Methods\MissingMethodReturnTypehintRule;
67
use PHPStan\Rules\Rule;
8+
use PHPStan\Testing\CompositeRule;
79
use PHPStan\Testing\RuleTestCase;
810
use function array_merge;
11+
use function class_exists;
912

1013
/**
11-
* @extends RuleTestCase<MissingMethodReturnTypehintRule>
14+
* @extends RuleTestCase<CompositeRule>
1215
*/
1316
class DataProviderReturnTypeIgnoreExtensionTest extends RuleTestCase {
1417
protected function getRule(): Rule
1518
{
1619
/** @phpstan-ignore phpstanApi.classConstant */
17-
$rule = self::getContainer()->getByType(MissingMethodReturnTypehintRule::class);
20+
$rules = [self::getContainer()->getByType(MissingMethodReturnTypehintRule::class)];
1821

19-
return $rule;
22+
// newer PHPStan versions report missing return types of methods with a body in a separate rule
23+
// @phpstan-ignore phpstanApi.classConstant
24+
if (class_exists(MissingImplementedMethodReturnTypehintRule::class)) {
25+
/** @phpstan-ignore phpstanApi.classConstant */
26+
$rules[] = self::getContainer()->getByType(MissingImplementedMethodReturnTypehintRule::class);
27+
}
28+
29+
// @phpstan-ignore argument.type
30+
return new CompositeRule($rules);
2031
}
2132

2233
public function testRule(): void

0 commit comments

Comments
 (0)