@@ -81,17 +81,18 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
8181 {
8282 $ parametersAcceptor = null ;
8383 $ constructorReflection = null ;
84+ $ className = null ;
85+ $ classReflection = null ;
8486 $ hasYield = false ;
8587 $ throwPoints = [];
88+ $ deferConstructorThrowPoints = false ;
8689 $ impurePoints = [];
8790 $ isAlwaysTerminating = false ;
8891 $ normalizedExpr = $ expr ;
89- $ className = null ;
90- $ deferConstructorThrowPoints = false ;
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