Skip to content

Commit 4d24433

Browse files
committed
lsb
1 parent a297b6a commit 4d24433

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/Analyser/MutatingScope.php

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

1924+
public function resolveStaticCallWithLateStaticBinding(Expr\StaticCall $expr): ?TypeWithClassName
1925+
{
1926+
$objectClasses = TypeCombinator::removeNull($this->getType($expr->class))->getObjectTypeOrClassStringObjectType()->getObjectClassNames();
1927+
if (count($objectClasses) !== 1) {
1928+
return null;
1929+
}
1930+
if (!$expr->name instanceof Identifier) {
1931+
return null;
1932+
}
1933+
return $this->resolveTypeByNameWithLateStaticBinding(new Name($objectClasses[0]), $expr->name);
1934+
}
1935+
19241936
private function resolveTypeByNameWithLateStaticBinding(Name $class, Node\Identifier $name): TypeWithClassName
19251937
{
19261938
$classType = $this->resolveTypeByName($class);

src/Analyser/NodeScopeResolver.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,7 +3309,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
33093309
$classType = $scope->resolveTypeByName($expr->class);
33103310
$methodName = $expr->name->name;
33113311
} elseif ($expr->class instanceof Expr) {
3312-
$classType = TypeCombinator::removeNull($scope->getType($expr->class))->getObjectTypeOrClassStringObjectType();
3312+
$classType = $scope->resolveStaticCallWithLateStaticBinding($expr);
33133313
$methodName = $expr->name->name;
33143314
}
33153315

@@ -3323,11 +3323,9 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
33233323
$methodReflection->getNamedArgumentsVariants(),
33243324
);
33253325

3326-
if (!$expr->class instanceof Expr) {
3327-
$methodThrowPoint = $this->getStaticMethodThrowPoint($methodReflection, $parametersAcceptor, $expr, $scope);
3328-
if ($methodThrowPoint !== null) {
3329-
$throwPoints[] = $methodThrowPoint;
3330-
}
3326+
$methodThrowPoint = $this->getStaticMethodThrowPoint($methodReflection, $parametersAcceptor, $expr, $scope);
3327+
if ($methodThrowPoint !== null) {
3328+
$throwPoints[] = $methodThrowPoint;
33313329
}
33323330

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

0 commit comments

Comments
 (0)