Skip to content

Commit 90193e2

Browse files
committed
add test for fix bug 7937
1 parent 81b60c6 commit 90193e2

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/PHPStan/Rules/Comparison/BooleanNotConstantConditionRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ public function testBug8797(): void
146146
$this->analyse([__DIR__ . '/data/bug-8797.php'], []);
147147
}
148148

149+
public function testBug7937(): void
150+
{
151+
$this->treatPhpDocTypesAsCertain = true;
152+
$this->analyse([__DIR__ . '/data/bug-7937.php'], []);
153+
}
154+
149155
public function dataReportAlwaysTrueInLastCondition(): iterable
150156
{
151157
yield [false, [
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug7937;
4+
5+
class HelloWorld
6+
{
7+
public function f(int $a, int $b)
8+
{
9+
if (!$a && !$b) {
10+
return "";
11+
}
12+
13+
$output = " ";
14+
15+
if ($a) {
16+
$output .= "$a";
17+
}
18+
19+
\PHPStan\dumpType($a);
20+
21+
if ($b) {
22+
\PHPStan\dumpType($a);
23+
24+
if (!$a) {
25+
$output .= "_";
26+
}
27+
}
28+
29+
return $output;
30+
}
31+
}

0 commit comments

Comments
 (0)