Skip to content

Commit

Permalink
Merge pull request #6829 from orklah/isType
Browse files Browse the repository at this point in the history
only return true in Union::is*Type* if there is a single type
  • Loading branch information
orklah authored Nov 5, 2021
2 parents e6c2313 + 728175f commit f4dcea3
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 f4dcea3

Please sign in to comment.