diff --git a/src/Psalm/Internal/Codebase/ClassLikes.php b/src/Psalm/Internal/Codebase/ClassLikes.php index 07f15205d..ea7405bce 100644 --- a/src/Psalm/Internal/Codebase/ClassLikes.php +++ b/src/Psalm/Internal/Codebase/ClassLikes.php @@ -358,20 +358,10 @@ class ClassLikes } } - if (!isset($this->existing_classes_lc[$fq_class_name_lc]) - || !$this->existing_classes_lc[$fq_class_name_lc] - || !$this->classlike_storage_provider->has($fq_class_name_lc) - ) { - if (( - !isset($this->existing_classes_lc[$fq_class_name_lc]) - || $this->existing_classes_lc[$fq_class_name_lc] - ) - && !$this->classlike_storage_provider->has($fq_class_name_lc) - ) { - return $this->existing_classes_lc[$fq_class_name_lc] = false; - } - - return false; + if (isset($this->existing_classes_lc[$fq_class_name_lc])) { + return $this->existing_classes_lc[$fq_class_name_lc]; + } elseif (!$this->classlike_storage_provider->has($fq_class_name_lc)) { + return $this->existing_classes_lc[$fq_class_name_lc] = false; } if ($this->collect_locations && $code_location) { @@ -381,7 +371,7 @@ class ClassLikes ); } - return true; + return $this->existing_classes_lc[$fq_class_name_lc] = true; } public function hasFullyQualifiedInterfaceName( @@ -392,20 +382,10 @@ class ClassLikes ): bool { $fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name)); - if (!isset($this->existing_interfaces_lc[$fq_class_name_lc]) - || !$this->existing_interfaces_lc[$fq_class_name_lc] - || !$this->classlike_storage_provider->has($fq_class_name_lc) - ) { - if (( - !isset($this->existing_interfaces_lc[$fq_class_name_lc]) - || $this->existing_interfaces_lc[$fq_class_name_lc] - ) - && !$this->classlike_storage_provider->has($fq_class_name_lc) - ) { - return $this->existing_interfaces_lc[$fq_class_name_lc] = false; - } - - return false; + if (isset($this->existing_interfaces_lc[$fq_class_name_lc])) { + return $this->existing_interfaces_lc[$fq_class_name_lc]; + } elseif (!$this->classlike_storage_provider->has($fq_class_name_lc)) { + return $this->existing_interfaces_lc[$fq_class_name_lc] = false; } if ($this->collect_references && $code_location) { @@ -442,7 +422,7 @@ class ClassLikes ); } - return true; + return $this->existing_interfaces_lc[$fq_class_name_lc] = true; } public function hasFullyQualifiedEnumName( @@ -453,20 +433,10 @@ class ClassLikes ): bool { $fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name)); - if (!isset($this->existing_enums_lc[$fq_class_name_lc]) - || !$this->existing_enums_lc[$fq_class_name_lc] - || !$this->classlike_storage_provider->has($fq_class_name_lc) - ) { - if (( - !isset($this->existing_enums_lc[$fq_class_name_lc]) - || $this->existing_enums_lc[$fq_class_name_lc] - ) - && !$this->classlike_storage_provider->has($fq_class_name_lc) - ) { - return $this->existing_enums_lc[$fq_class_name_lc] = false; - } - - return false; + if (isset($this->existing_enums_lc[$fq_class_name_lc])) { + return $this->existing_enums_lc[$fq_class_name_lc]; + } elseif (!$this->classlike_storage_provider->has($fq_class_name_lc)) { + return $this->existing_enums_lc[$fq_class_name_lc] = false; } if ($this->collect_references && $code_location) { @@ -503,7 +473,7 @@ class ClassLikes ); } - return true; + return $this->existing_enums_lc[$fq_class_name_lc] = true; } public function hasFullyQualifiedTraitName(string $fq_class_name, ?CodeLocation $code_location = null): bool