diff --git a/tests/Type/PHPUnit/DataProviderReturnTypeIgnoreExtensionTest.php b/tests/Type/PHPUnit/DataProviderReturnTypeIgnoreExtensionTest.php index 5335fc0c..e2f7e1d4 100644 --- a/tests/Type/PHPUnit/DataProviderReturnTypeIgnoreExtensionTest.php +++ b/tests/Type/PHPUnit/DataProviderReturnTypeIgnoreExtensionTest.php @@ -2,21 +2,32 @@ namespace PHPStan\Type\PHPUnit; +use PHPStan\Rules\Methods\MissingImplementedMethodReturnTypehintRule; use PHPStan\Rules\Methods\MissingMethodReturnTypehintRule; use PHPStan\Rules\Rule; +use PHPStan\Testing\CompositeRule; use PHPStan\Testing\RuleTestCase; use function array_merge; +use function class_exists; /** - * @extends RuleTestCase + * @extends RuleTestCase */ class DataProviderReturnTypeIgnoreExtensionTest extends RuleTestCase { protected function getRule(): Rule { /** @phpstan-ignore phpstanApi.classConstant */ - $rule = self::getContainer()->getByType(MissingMethodReturnTypehintRule::class); + $rules = [self::getContainer()->getByType(MissingMethodReturnTypehintRule::class)]; - return $rule; + // newer PHPStan versions report missing return types of methods with a body in a separate rule + // @phpstan-ignore phpstanApi.classConstant + if (class_exists(MissingImplementedMethodReturnTypehintRule::class)) { + /** @phpstan-ignore phpstanApi.classConstant */ + $rules[] = self::getContainer()->getByType(MissingImplementedMethodReturnTypehintRule::class); + } + + // @phpstan-ignore argument.type + return new CompositeRule($rules); } public function testRule(): void