File tree Expand file tree Collapse file tree
tests/PHPStan/Rules/Comparison Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -819,6 +819,11 @@ public function testBug9142(): void
819819 ]);
820820 }
821821
822+ public function testBug4918 (): void
823+ {
824+ $ this ->analyse ([__DIR__ . '/data/bug-4918.php ' ], []);
825+ }
826+
822827 #[RequiresPhp('>= 8.1 ' )]
823828 public function testBug4061 (): void
824829 {
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments