Skip to content

Commit f1eba82

Browse files
Simplify
1 parent ccf0a02 commit f1eba82

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/Analyser/ExprHandler/NewHandler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
8181
{
8282
$parametersAcceptor = null;
8383
$constructorReflection = null;
84+
$classReflection = null;
8485
$hasYield = false;
8586
$throwPoints = [];
8687
$impurePoints = [];
@@ -91,7 +92,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
9192
if ($expr->class instanceof Name) {
9293
$className = $scope->resolveName($expr->class);
9394

94-
[$constructorReflection, $parametersAcceptor, $constructorImpurePoints] = $this->processConstructorReflection($className, $expr, $scope);
95+
[$constructorReflection, $classReflection, $parametersAcceptor, $constructorImpurePoints] = $this->processConstructorReflection($className, $expr, $scope);
9596
$impurePoints = array_merge($impurePoints, $constructorImpurePoints);
9697
$deferConstructorThrowPoints = true;
9798

@@ -178,7 +179,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
178179
$throwPoints = array_merge($throwPoints, $additionalThrowPoints);
179180

180181
if ($className !== null) {
181-
[$constructorReflection, $parametersAcceptor, $constructorImpurePoints] = $this->processConstructorReflection($className, $expr, $scope);
182+
[$constructorReflection, $classReflection, $parametersAcceptor, $constructorImpurePoints] = $this->processConstructorReflection($className, $expr, $scope);
182183
$impurePoints = array_merge($impurePoints, $constructorImpurePoints);
183184
$deferConstructorThrowPoints = true;
184185
} else {
@@ -205,13 +206,12 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
205206
$isAlwaysTerminating = $isAlwaysTerminating || $argsResult->isAlwaysTerminating();
206207

207208
if ($deferConstructorThrowPoints && $className !== null) {
208-
if ($constructorReflection !== null && $parametersAcceptor !== null && $this->reflectionProvider->hasClass($className)) {
209-
$classReflection = $this->reflectionProvider->getClass($className);
209+
if ($constructorReflection !== null && $parametersAcceptor !== null && $classReflection !== null) {
210210
$constructorThrowPoint = $this->getConstructorThrowPoint($constructorReflection, $parametersAcceptor, $classReflection, $expr, new Name\FullyQualified($className), $expr->getArgs(), $scope);
211211
if ($constructorThrowPoint !== null) {
212212
$throwPoints[] = $constructorThrowPoint;
213213
}
214-
} elseif (!$this->reflectionProvider->hasClass($className)) {
214+
} elseif ($classReflection === null) {
215215
$throwPoints[] = InternalThrowPoint::createImplicit($scope, $expr);
216216
}
217217
}
@@ -226,7 +226,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
226226
}
227227

228228
/**
229-
* @return array{?MethodReflection, ?ParametersAcceptor, ImpurePoint[]}
229+
* @return array{?MethodReflection, ?ClassReflection, ?ParametersAcceptor, ImpurePoint[]}
230230
*/
231231
private function processConstructorReflection(string $className, New_ $expr, MutatingScope $scope): array
232232
{
@@ -269,7 +269,7 @@ private function processConstructorReflection(string $className, New_ $expr, Mut
269269
);
270270
}
271271

272-
return [$constructorReflection, $parametersAcceptor, $impurePoints];
272+
return [$constructorReflection, $classReflection, $parametersAcceptor, $impurePoints];
273273
}
274274

275275
/**

0 commit comments

Comments
 (0)