Skip to content

Commit 7f7758f

Browse files
authored
Added regression test (#5313)
1 parent 5037bd5 commit 7f7758f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,11 @@ public function testBug9142(): void
813813
]);
814814
}
815815

816+
public function testBug4918(): void
817+
{
818+
$this->analyse([__DIR__ . '/data/bug-4918.php'], []);
819+
}
820+
816821
#[RequiresPhp('>= 8.1')]
817822
public function testBug4061(): void
818823
{
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug4918;
4+
5+
class HelloWorld
6+
{
7+
public function testThrowException(): void
8+
{
9+
$tryCounter = 0;
10+
11+
try {
12+
$this->runCallback(static function () use (&$tryCounter): void {
13+
$tryCounter++;
14+
throw new LogicException('Test exception');
15+
});
16+
} catch (LogicException $e) {
17+
if ($tryCounter === 0) {
18+
throw new LogicException('Should never happen');
19+
}
20+
}
21+
}
22+
23+
public function runCallback(callable $callback): void
24+
{
25+
$callback();
26+
}
27+
}

0 commit comments

Comments
 (0)