From 5e77f1b9e2c3244bc3f6f44831c37362d3d1baa3 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 25 Jul 2023 11:52:50 +0200 Subject: [PATCH] Fixes --- src/Psalm/Internal/Codebase/ClassLikes.php | 60 ++++++---------------- 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/src/Psalm/Internal/Codebase/ClassLikes.php b/src/Psalm/Internal/Codebase/ClassLikes.php index 2ae62e664..bae1f1029 100644 --- a/src/Psalm/Internal/Codebase/ClassLikes.php +++ b/src/Psalm/Internal/Codebase/ClassLikes.php @@ -356,20 +356,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) { @@ -379,7 +369,7 @@ class ClassLikes ); } - return true; + return $this->existing_classes_lc[$fq_class_name_lc] = true; } public function hasFullyQualifiedInterfaceName( @@ -390,20 +380,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) { @@ -440,7 +420,7 @@ class ClassLikes ); } - return true; + return $this->existing_interfaces_lc[$fq_class_name_lc] = true; } public function hasFullyQualifiedEnumName( @@ -451,20 +431,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) { @@ -501,7 +471,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