Skip to content

Commit

Permalink
Fix unstable hasFullyQualified(Interface|Enum)()
Browse files Browse the repository at this point in the history
Before this change, calling:
```php
$classlikes->hasFullyQualifiedInterfaceName($i); // true
$classlikes->hasFullyQualifiedClassName($i); // false
$classlikes->hasFullyQualifiedInterfaceName($i); // false
```
would result in the last call returning `false`
  • Loading branch information
weirdan committed Jan 27, 2024
1 parent 294220c commit b12c10c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Psalm/Internal/Codebase/ClassLikes.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ public function hasFullyQualifiedClassName(
}
}

// fixme: this looks like a crazy caching hack
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)
Expand Down Expand Up @@ -396,13 +397,14 @@ public function hasFullyQualifiedInterfaceName(
): bool {
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));

// fixme: this looks like a crazy caching hack
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_classes_lc[$fq_class_name_lc])
|| $this->existing_classes_lc[$fq_class_name_lc]
!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)
) {
Expand Down Expand Up @@ -463,13 +465,14 @@ public function hasFullyQualifiedEnumName(
): bool {
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));

// fixme: this looks like a crazy caching hack
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_classes_lc[$fq_class_name_lc])
|| $this->existing_classes_lc[$fq_class_name_lc]
!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)
) {
Expand Down

0 comments on commit b12c10c

Please sign in to comment.