Skip to content

Commit 35a7641

Browse files
committed
Update TypeSpecifierContext.php
1 parent f4984d2 commit 35a7641

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Analyser/TypeSpecifierContext.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,13 @@ public function negate(): self
7373
throw new ShouldNotHappenException();
7474
}
7575

76-
$baseType = $this->returnType->generalize(GeneralizePrecision::lessSpecific());
77-
return self::create(~$this->value & self::CONTEXT_BITMASK, TypeCombinator::remove($baseType, $this->returnType));
76+
$negatedReturnType = null;
77+
if ($this->returnType !== null) {
78+
$baseType = $this->returnType->generalize(GeneralizePrecision::lessSpecific());
79+
$negatedReturnType = TypeCombinator::remove($baseType, $this->returnType);
80+
}
81+
82+
return self::create(~$this->value & self::CONTEXT_BITMASK, $negatedReturnType);
7883
}
7984

8085
public function true(): bool

0 commit comments

Comments
 (0)