From 9b62d9149d06a440e00ce3e375d5584a922c40c4 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 14 May 2020 10:51:18 +0200 Subject: [PATCH] NodeScopeResolver - fix processing args in New_ --- src/Analyser/NodeScopeResolver.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index fcbf334f33..8ec2049d6a 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -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);