Skip to content

Commit e1f4910

Browse files
committed
negate type in TypeSpecifierContext
1 parent 3447717 commit e1f4910

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Analyser/TypeSpecifierContext.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace PHPStan\Analyser;
44

55
use PHPStan\ShouldNotHappenException;
6+
use PHPStan\Type\GeneralizePrecision;
67
use PHPStan\Type\Type;
8+
use PHPStan\Type\TypeCombinator;
79

810
/**
911
* @api
@@ -70,7 +72,9 @@ public function negate(): self
7072
if ($this->value === null) {
7173
throw new ShouldNotHappenException();
7274
}
73-
return self::create(~$this->value & self::CONTEXT_BITMASK);
75+
76+
$baseType = $this->returnType->generalize(GeneralizePrecision::lessSpecific());
77+
return self::create(~$this->value & self::CONTEXT_BITMASK, TypeCombinator::remove($baseType, $this->returnType));
7478
}
7579

7680
public function true(): bool

0 commit comments

Comments
 (0)