Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/PhpParser/AstResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public function resolveClassMethodFromCall(MethodCall|StaticCall|NullsafeMethodC
return $this->resolveClassMethod($className, MethodName::CONSTRUCT);
}

$methodName = $this->nodeNameResolver->getName($call->name);
if ($methodName === null) {
return null;
}

$callerStaticType = ($call instanceof MethodCall || $call instanceof NullsafeMethodCall)
? $this->nodeTypeResolver->getType($call->var)
: $this->nodeTypeResolver->getType($call->class);
Expand All @@ -148,11 +153,6 @@ public function resolveClassMethodFromCall(MethodCall|StaticCall|NullsafeMethodC
return null;
}

$methodName = $this->nodeNameResolver->getName($call->name);
if ($methodName === null) {
return null;
}

return $this->resolveClassMethod($className, $methodName);
}

Expand Down
22 changes: 10 additions & 12 deletions src/Reflection/ReflectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public function resolveMethodReflection(string $className, string $methodName, ?

public function resolveMethodReflectionFromStaticCall(StaticCall $staticCall): ?MethodReflection
{
$methodName = $this->nodeNameResolver->getName($staticCall->name);
if ($methodName === null) {
return null;
}

$objectType = $this->nodeTypeResolver->getType($staticCall->class);

if ($objectType instanceof ShortenedObjectType || $objectType instanceof AliasedObjectType) {
Expand All @@ -148,11 +153,6 @@ public function resolveMethodReflectionFromStaticCall(StaticCall $staticCall): ?
$classNames = $objectType->getObjectClassNames();
}

$methodName = $this->nodeNameResolver->getName($staticCall->name);
if ($methodName === null) {
return null;
}

$scope = $staticCall->getAttribute(AttributeKey::SCOPE);

foreach ($classNames as $className) {
Expand All @@ -167,20 +167,18 @@ public function resolveMethodReflectionFromStaticCall(StaticCall $staticCall): ?

public function resolveMethodReflectionFromMethodCall(MethodCall $methodCall): ?MethodReflection
{
$callerType = $this->nodeTypeResolver->getType($methodCall->var);
$methodName = $this->nodeNameResolver->getName($methodCall->name);
if ($methodName === null) {
return null;
}

$callerType = $this->nodeTypeResolver->getType($methodCall->var);
if ($callerType instanceof BenevolentUnionType) {
$callerType = TypeCombinator::removeFalsey($callerType);
}

$className = ClassNameFromObjectTypeResolver::resolve($callerType);
if ($className === null) {

return null;
}

$methodName = $this->nodeNameResolver->getName($methodCall->name);
if ($methodName === null) {
return null;
}

Expand Down
Loading