From 728175f82d3806b71825b28b6da9b7fd3658b49b Mon Sep 17 00:00:00 2001 From: orklah Date: Fri, 5 Nov 2021 21:14:04 +0100 Subject: [PATCH] only return true in Union::is*Type* if there is a single type --- src/Psalm/Type/Union.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index 71082929e..a5e0a48df 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -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