File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace PHPStan \Type \PHPUnit ;
44
5+ use PHPStan \Rules \Methods \MissingImplementedMethodReturnTypehintRule ;
56use PHPStan \Rules \Methods \MissingMethodReturnTypehintRule ;
67use PHPStan \Rules \Rule ;
8+ use PHPStan \Testing \CompositeRule ;
79use PHPStan \Testing \RuleTestCase ;
810use function array_merge ;
11+ use function class_exists ;
912
1013/**
11- * @extends RuleTestCase<MissingMethodReturnTypehintRule >
14+ * @extends RuleTestCase<CompositeRule >
1215 */
1316class 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
You can’t perform that action at this time.
0 commit comments