Skip to content

Commit

Permalink
NodeScopeResolver - fix processing args in New_
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 14, 2020
1 parent cb479ed commit 9b62d91
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1785,15 +1785,18 @@ static function () use ($expr, $rightResult): MutatingScope {
} elseif ($expr->class instanceof Class_) {
$this->reflectionProvider->getAnonymousClassReflection($expr->class, $scope); // populates $expr->class->name
$this->processStmtNode($expr->class, $scope, $nodeCallback);
} elseif ($this->reflectionProvider->hasClass($expr->class->toString())) {
$classReflection = $this->reflectionProvider->getClass($expr->class->toString());
if ($classReflection->hasConstructor()) {
$constructorReflection = $classReflection->getConstructor();
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
$scope,
$expr->args,
$constructorReflection->getVariants()
);
} else {
$className = $scope->resolveName($expr->class);
if ($this->reflectionProvider->hasClass($className)) {
$classReflection = $this->reflectionProvider->getClass($className);
if ($classReflection->hasConstructor()) {
$constructorReflection = $classReflection->getConstructor();
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
$scope,
$expr->args,
$constructorReflection->getVariants()
);
}
}
}
$result = $this->processArgs($constructorReflection, $parametersAcceptor, $expr->args, $scope, $nodeCallback, $context);
Expand Down

0 comments on commit 9b62d91

Please sign in to comment.