1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

only return true in Union::is*Type* if there is a single type

This commit is contained in:
orklah 2021-11-05 21:14:04 +01:00
parent b7834689e5
commit 728175f82d

View File

@ -943,7 +943,8 @@ class Union implements TypeNode
public function isEmptyMixed(): bool
{
return isset($this->types['mixed'])
&& $this->types['mixed'] instanceof Type\Atomic\TEmptyMixed;
&& $this->types['mixed'] instanceof Type\Atomic\TEmptyMixed
&& count($this->types) === 1;
}
public function isVanillaMixed(): bool
@ -1140,12 +1141,12 @@ class Union implements TypeNode
public function isVoid(): bool
{
return isset($this->types['void']);
return isset($this->types['void']) && count($this->types) === 1;
}
public function isNever(): bool
{
return isset($this->types['never']);
return isset($this->types['never']) && count($this->types) === 1;
}
public function isGenerator(): bool
@ -1157,7 +1158,7 @@ class Union implements TypeNode
public function isEmpty(): bool
{
return isset($this->types['empty']);
return isset($this->types['empty']) && count($this->types) === 1;
}
public function substitute(Union $old_type, ?Union $new_type = null): void