|
3 | 3 | namespace PHPStan\Rules\PhpDoc; |
4 | 4 |
|
5 | 5 | use PHPStan\Type\FileTypeMapper; |
| 6 | +use PHPStan\Type\VerbosityLevel; |
6 | 7 |
|
7 | 8 | /** |
8 | 9 | * @extends \PHPStan\Testing\RuleTestCase<InvalidThrowsPhpDocValueRule> |
@@ -67,4 +68,45 @@ public function testInheritedPhpDocs(): void |
67 | 68 | ]); |
68 | 69 | } |
69 | 70 |
|
| 71 | + public function dataMergeInheritedPhpDocs(): array |
| 72 | + { |
| 73 | + return [ |
| 74 | + [ |
| 75 | + \InvalidThrowsPhpDocMergeInherited\Two::class, |
| 76 | + 'method', |
| 77 | + 'InvalidThrowsPhpDocMergeInherited\C|InvalidThrowsPhpDocMergeInherited\D', |
| 78 | + ], |
| 79 | + [ |
| 80 | + \InvalidThrowsPhpDocMergeInherited\Three::class, |
| 81 | + 'method', |
| 82 | + 'InvalidThrowsPhpDocMergeInherited\C|InvalidThrowsPhpDocMergeInherited\D', |
| 83 | + ], |
| 84 | + [ |
| 85 | + \InvalidThrowsPhpDocMergeInherited\Four::class, |
| 86 | + 'method', |
| 87 | + 'InvalidThrowsPhpDocMergeInherited\C|InvalidThrowsPhpDocMergeInherited\D', |
| 88 | + ], |
| 89 | + ]; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * @dataProvider dataMergeInheritedPhpDocs |
| 94 | + * @param string $className |
| 95 | + * @param string $method |
| 96 | + * @param string $expectedType |
| 97 | + */ |
| 98 | + public function testMergeInheritedPhpDocs( |
| 99 | + string $className, |
| 100 | + string $method, |
| 101 | + string $expectedType |
| 102 | + ): void |
| 103 | + { |
| 104 | + $reflectionProvider = $this->createBroker(); |
| 105 | + $reflection = $reflectionProvider->getClass($className); |
| 106 | + $method = $reflection->getNativeMethod($method); |
| 107 | + $throwsType = $method->getThrowType(); |
| 108 | + $this->assertNotNull($throwsType); |
| 109 | + $this->assertSame($expectedType, $throwsType->describe(VerbosityLevel::precise())); |
| 110 | + } |
| 111 | + |
70 | 112 | } |
0 commit comments