Skip to content

Commit

Permalink
[NodeCollector] Fix non-string value on ArrayCallableMethodMatcher::r…
Browse files Browse the repository at this point in the history
…esolveClassContextType() (#5780)

* [NodeCollector] Fix non-string value on ArrayCallableMethodMatcher::resolveClassContextType()

* [NodeCollector] Fix non-string value on ArrayCallableMethodMatcher::resolveClassContextType()
  • Loading branch information
samsonasik committed Mar 28, 2024
1 parent eb525ca commit 3122ef4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php
Expand Up @@ -144,6 +144,11 @@ private function resolveClassContextType(
): MixedType | ObjectType {
$classConstantReference = $this->valueResolver->getValue($classContext);

// non-class value
if (! is_string($classConstantReference)) {
return new MixedType();
}

if ($this->isRequiredClassReflectionResolution($classConstantReference)) {
$classReflection = $this->reflectionResolver->resolveClassReflection($classContext);
if (! $classReflection instanceof ClassReflection || ! $classReflection->isClass()) {
Expand All @@ -153,11 +158,6 @@ private function resolveClassContextType(
$classConstantReference = $classReflection->getName();
}

// non-class value
if (! is_string($classConstantReference)) {
return new MixedType();
}

if (! $this->reflectionProvider->hasClass($classConstantReference)) {
return new MixedType();
}
Expand Down Expand Up @@ -208,9 +208,7 @@ private function isRequiredClassReflectionResolution(string $classConstantRefere
if ($classConstantReference === ObjectReference::STATIC) {
return true;
}
if ($classConstantReference === '__CLASS__') {
return true;
}
return false;

return $classConstantReference === '__CLASS__';
}
}

0 comments on commit 3122ef4

Please sign in to comment.