Skip to content

Commit 98d04a4

Browse files
Add non regression test
1 parent 8ae740c commit 98d04a4

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,13 @@ public function testReportAlwaysTrueInLastCondition(bool $reportAlwaysTrueInLast
425425
$this->analyse([__DIR__ . '/data/boolean-and-report-always-true-last-condition.php'], $expectedErrors);
426426
}
427427

428+
public function testBug4284(): void
429+
{
430+
$this->treatPhpDocTypesAsCertain = true;
431+
$this->reportAlwaysTrueInLastCondition = true;
432+
$this->analyse([__DIR__ . '/data/bug-4284.php'], []);
433+
}
434+
428435
public function testBug5365(): void
429436
{
430437
$this->treatPhpDocTypesAsCertain = true;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug4284;
4+
5+
class HelloWorld
6+
{
7+
/** @param mixed[] $browser */
8+
public function sayHello(array $browser): void
9+
{
10+
$browserName = '';
11+
$upgradeBrowserLink = '';
12+
13+
if ($browser['name'] === 1) {
14+
$browserName = '123';
15+
$upgradeBrowserLink = '456';
16+
} elseif ($browser['name'] === 2) {
17+
$browserName = '789';
18+
$upgradeBrowserLink = '123';
19+
}
20+
21+
if ($browserName && $upgradeBrowserLink) {
22+
//
23+
}
24+
if ($browserName) {
25+
if ($upgradeBrowserLink) {
26+
//
27+
}
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)