Skip to content

Commit 601e4ac

Browse files
committed
de-duplicate
1 parent b0fac99 commit 601e4ac

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,7 +3296,9 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
32963296
}
32973297

32983298
$parametersAcceptor = null;
3299+
$classType = null;
32993300
$methodReflection = null;
3301+
$methodName = null;
33003302
if ($expr->name instanceof Expr) {
33013303
$result = $this->processExprNode($stmt, $expr->name, $scope, $storage, $nodeCallback, $context->enterDeep());
33023304
$hasYield = $hasYield || $result->hasYield();
@@ -3306,6 +3308,12 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
33063308
} elseif ($expr->class instanceof Name) {
33073309
$classType = $scope->resolveTypeByName($expr->class);
33083310
$methodName = $expr->name->name;
3311+
} elseif ($expr->class instanceof Expr && $expr->name instanceof Identifier) {
3312+
$classType = TypeCombinator::removeNull($scope->getType($expr->class))->getObjectTypeOrClassStringObjectType();
3313+
$methodName = $expr->name->name;
3314+
}
3315+
3316+
if ($classType !== null && $methodName !== null) {
33093317
if ($classType->hasMethod($methodName)->yes()) {
33103318
$methodReflection = $classType->getMethod($methodName, $scope);
33113319
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
@@ -3381,25 +3389,6 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
33813389
foreach ($additionalThrowPoints as $throwPoint) {
33823390
$throwPoints[] = $throwPoint;
33833391
}
3384-
3385-
if ($expr->name instanceof Identifier && $methodReflection === null) {
3386-
$staticMethodCalledOnType = TypeCombinator::removeNull($scope->getType($expr->class))->getObjectTypeOrClassStringObjectType();
3387-
$methodName = $expr->name->name;
3388-
if ($staticMethodCalledOnType->hasMethod($methodName)->yes()) {
3389-
$methodReflection = $staticMethodCalledOnType->getMethod($methodName, $scope);
3390-
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
3391-
$scope,
3392-
$expr->getArgs(),
3393-
$methodReflection->getVariants(),
3394-
$methodReflection->getNamedArgumentsVariants(),
3395-
);
3396-
3397-
$methodThrowPoint = $this->getStaticMethodThrowPoint($methodReflection, $parametersAcceptor, $expr, $scope);
3398-
if ($methodThrowPoint !== null) {
3399-
$throwPoints[] = $methodThrowPoint;
3400-
}
3401-
}
3402-
}
34033392
}
34043393

34053394
if ($methodReflection !== null) {

0 commit comments

Comments
 (0)