Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/Type/UnionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ public function isScalar(): TrinaryLogic

public function looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
{
return $this->unionResults(
return $this->notBenevolentUnionResults(
static fn (Type $innerType): TrinaryLogic => $innerType->looseCompare($type, $phpVersion)->toTrinaryLogic()
)->toBooleanType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,10 @@ public function testBug8800(): void
]);
}

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

}
15 changes: 15 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-13098.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Bug13098;

$x = substr($_GET["x"], 0, 10);
if ($x == "") echo "empty";

$x = get_include_path();
if ($x == "") echo "empty";

$x = password_hash("password", PASSWORD_DEFAULT);
if ($x == false) echo "false";

$x = php_sapi_name();
if ($x == false) echo "false";
Loading