Skip to content

Commit f2a9064

Browse files
committed
lsb
1 parent e7a7968 commit f2a9064

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/Analyser/MutatingScope.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,6 +2044,18 @@ public function resolveTypeByName(Name $name): TypeWithClassName
20442044
return new ObjectType($originalClass);
20452045
}
20462046

2047+
public function resolveStaticCallWithLateStaticBinding(Expr\StaticCall $expr): ?TypeWithClassName
2048+
{
2049+
$objectClasses = TypeCombinator::removeNull($this->getType($expr->class))->getObjectTypeOrClassStringObjectType()->getObjectClassNames();
2050+
if (count($objectClasses) !== 1) {
2051+
return null;
2052+
}
2053+
if (!$expr->name instanceof Identifier) {
2054+
return null;
2055+
}
2056+
return $this->resolveTypeByNameWithLateStaticBinding(new Name($objectClasses[0]), $expr->name);
2057+
}
2058+
20472059
private function resolveTypeByNameWithLateStaticBinding(Name $class, Node\Identifier $name): TypeWithClassName
20482060
{
20492061
$classType = $this->resolveTypeByName($class);

src/Analyser/NodeScopeResolver.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,7 +3354,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
33543354
$classType = $scope->resolveTypeByName($expr->class);
33553355
$methodName = $expr->name->name;
33563356
} elseif ($expr->class instanceof Expr) {
3357-
$classType = TypeCombinator::removeNull($scope->getType($expr->class))->getObjectTypeOrClassStringObjectType();
3357+
$classType = $scope->resolveStaticCallWithLateStaticBinding($expr);
33583358
$methodName = $expr->name->name;
33593359
}
33603360

@@ -3368,11 +3368,9 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
33683368
$methodReflection->getNamedArgumentsVariants(),
33693369
);
33703370

3371-
if (!$expr->class instanceof Expr) {
3372-
$methodThrowPoint = $this->getStaticMethodThrowPoint($methodReflection, $parametersAcceptor, $expr, $scope);
3373-
if ($methodThrowPoint !== null) {
3374-
$throwPoints[] = $methodThrowPoint;
3375-
}
3371+
$methodThrowPoint = $this->getStaticMethodThrowPoint($methodReflection, $parametersAcceptor, $expr, $scope);
3372+
if ($methodThrowPoint !== null) {
3373+
$throwPoints[] = $methodThrowPoint;
33763374
}
33773375

33783376
$declaringClass = $methodReflection->getDeclaringClass();

0 commit comments

Comments
 (0)