Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php
Original file line number Diff line number Diff line change
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__';
}
}