Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions tests/Type/PHPUnit/DataProviderReturnTypeIgnoreExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<MissingMethodReturnTypehintRule>
* @extends RuleTestCase<CompositeRule>
*/
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
Expand Down