Skip to content

Commit 9a7ce62

Browse files
committed
Test merged inherited @throws
1 parent b803293 commit 9a7ce62

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/PHPStan/Rules/PhpDoc/InvalidThrowsPhpDocValueRuleTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Rules\PhpDoc;
44

55
use PHPStan\Type\FileTypeMapper;
6+
use PHPStan\Type\VerbosityLevel;
67

78
/**
89
* @extends \PHPStan\Testing\RuleTestCase<InvalidThrowsPhpDocValueRule>
@@ -67,4 +68,45 @@ public function testInheritedPhpDocs(): void
6768
]);
6869
}
6970

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+
70112
}

0 commit comments

Comments
 (0)