Skip to content

Commit

Permalink
Added regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Dec 22, 2024
1 parent b5ecab0 commit 684c599
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/PHPStan/Rules/Comparison/ConstantLooseComparisonRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,15 @@ public function testBug11694(): void
$this->analyse([__DIR__ . '/data/bug-11694.php'], $expectedErrors);
}

public function testBug8800(): void
{
$this->treatPhpDocTypesAsCertain = true;
$this->analyse([__DIR__ . '/data/bug-8800.php'], [
[
'Loose comparison using == between 0|1|false and 2 will always evaluate to false.',
9,
],
]);
}

}
11 changes: 11 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-8800.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);

namespace Bug8800;

class HelloWorld
{
public function sayHello(string $s): void
{
var_dump(preg_match('{[A-Z]}', $s) == 2);
}
}

0 comments on commit 684c599

Please sign in to comment.