|
| 1 | +<?php declare(strict_types = 1); |
| 2 | + |
| 3 | +namespace PHPStan\Rules\Classes; |
| 4 | + |
| 5 | +use PHPStan\Rules\ClassCaseSensitivityCheck; |
| 6 | +use PHPStan\Rules\ClassForbiddenNameCheck; |
| 7 | +use PHPStan\Rules\ClassNameCheck; |
| 8 | +use PHPStan\Rules\Generics\GenericObjectTypeCheck; |
| 9 | +use PHPStan\Rules\MissingTypehintCheck; |
| 10 | +use PHPStan\Rules\PhpDoc\UnresolvableTypeHelper; |
| 11 | +use PHPStan\Rules\Rule; |
| 12 | +use PHPStan\Testing\RuleTestCase; |
| 13 | + |
| 14 | +/** |
| 15 | + * @extends RuleTestCase<MixinTraitRule> |
| 16 | + */ |
| 17 | +class MixinTraitRuleTest extends RuleTestCase |
| 18 | +{ |
| 19 | + |
| 20 | + protected function getRule(): Rule |
| 21 | + { |
| 22 | + $reflectionProvider = $this->createReflectionProvider(); |
| 23 | + |
| 24 | + return new MixinTraitRule( |
| 25 | + new MixinCheck( |
| 26 | + $reflectionProvider, |
| 27 | + new ClassNameCheck( |
| 28 | + new ClassCaseSensitivityCheck($reflectionProvider, true), |
| 29 | + new ClassForbiddenNameCheck(self::getContainer()), |
| 30 | + ), |
| 31 | + new GenericObjectTypeCheck(), |
| 32 | + new MissingTypehintCheck(true, true, true, true, []), |
| 33 | + new UnresolvableTypeHelper(), |
| 34 | + true, |
| 35 | + true, |
| 36 | + ), |
| 37 | + $reflectionProvider, |
| 38 | + ); |
| 39 | + } |
| 40 | + |
| 41 | + public function testRule(): void |
| 42 | + { |
| 43 | + $this->analyse([__DIR__ . '/data/mixin-trait.php'], [ |
| 44 | + [ |
| 45 | + 'Trait MixinTrait\FooTrait has PHPDoc tag @mixin with no value type specified in iterable type array.', |
| 46 | + 14, |
| 47 | + MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP, |
| 48 | + ], |
| 49 | + ]); |
| 50 | + } |
| 51 | + |
| 52 | +} |
0 commit comments