Skip to content
Closed
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 @@ -425,6 +425,13 @@ public function testReportAlwaysTrueInLastCondition(bool $reportAlwaysTrueInLast
$this->analyse([__DIR__ . '/data/boolean-and-report-always-true-last-condition.php'], $expectedErrors);
}

public function testBug4284(): void
{
$this->treatPhpDocTypesAsCertain = true;
$this->reportAlwaysTrueInLastCondition = true;
$this->analyse([__DIR__ . '/data/bug-4284.php'], []);
}

public function testBug5365(): void
{
$this->treatPhpDocTypesAsCertain = true;
Expand Down
30 changes: 30 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-4284.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php declare(strict_types = 1);

namespace Bug4284;

class HelloWorld
{
/** @param mixed[] $browser */
public function sayHello(array $browser): void
{
$browserName = '';
$upgradeBrowserLink = '';

if ($browser['name'] === 1) {
$browserName = '123';
$upgradeBrowserLink = '456';
} elseif ($browser['name'] === 2) {
$browserName = '789';
$upgradeBrowserLink = '123';
}

if ($browserName && $upgradeBrowserLink) {
//
}
if ($browserName) {
if ($upgradeBrowserLink) {
//
}
}
}
}
Loading