File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
tests/PHPStan/Rules/Comparison Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments