Skip to content

Commit 016d568

Browse files
Add test
1 parent 235c090 commit 016d568

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

tests/PHPStan/Rules/Exceptions/ThrowsVoidMethodWithExplicitThrowPointRuleTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,17 @@ public function testRule(bool $missingCheckedExceptionInThrows, array $checkedEx
100100
$this->analyse([__DIR__ . '/data/throws-void-method.php'], $errors);
101101
}
102102

103+
#[RequiresPhp('>= 8.0')]
103104
public function testBug13642(): void
104105
{
105106
$this->missingCheckedExceptionInThrows = false;
106107
$this->checkedExceptionClasses = [ValueError::class];
107-
$this->analyse([__DIR__ . '/data/bug-13642.php'], []);
108+
$this->analyse([__DIR__ . '/data/bug-13642.php'], [
109+
[
110+
'Method Bug13642\HelloWorld::sayHello2() throws exception ValueError but the PHPDoc contains @throws void.',
111+
21,
112+
],
113+
]);
108114
}
109115

110116
#[RequiresPhp('>= 8.0')]

tests/PHPStan/Rules/Exceptions/data/bug-13642.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,15 @@ public function sayHello(): void
99
{
1010
array_combine([1, 2], [1, 2]);
1111
}
12+
13+
/**
14+
* @param mixed $mixed1
15+
* @param mixed $mixed2
16+
*
17+
* @throws void
18+
*/
19+
public function sayHello2($mixed1, $mixed2): void
20+
{
21+
array_combine($mixed1, $mixed2);
22+
}
1223
}

0 commit comments

Comments
 (0)