Skip to content

Commit

Permalink
only return true in Union::is*Type* if there is a single type
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Nov 5, 2021
1 parent b783468 commit 728175f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Psalm/Type/Union.php
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,8 @@ public function isMixed(): bool
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
Expand Down Expand Up @@ -1140,12 +1141,12 @@ public function isAlwaysTruthy(): bool

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
Expand All @@ -1157,7 +1158,7 @@ public function isGenerator(): bool

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
Expand Down

0 comments on commit 728175f

Please sign in to comment.