Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,11 @@ public function testBug9142(): void
]);
}

public function testBug4918(): void
{
$this->analyse([__DIR__ . '/data/bug-4918.php'], []);
}

#[RequiresPhp('>= 8.1')]
public function testBug4061(): void
{
Expand Down
27 changes: 27 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-4918.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php declare(strict_types = 1);

namespace Bug4918;

class HelloWorld
{
public function testThrowException(): void
{
$tryCounter = 0;

try {
$this->runCallback(static function () use (&$tryCounter): void {
$tryCounter++;
throw new LogicException('Test exception');
});
} catch (LogicException $e) {
if ($tryCounter === 0) {
throw new LogicException('Should never happen');
}
}
}

public function runCallback(callable $callback): void
{
$callback();
}
}
Loading