@@ -86,13 +86,12 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
8686 $ impurePoints = [];
8787 $ isAlwaysTerminating = false ;
8888 $ normalizedExpr = $ expr ;
89- $ classReflection = null ;
90- $ classFound = true ;
89+ $ className = null ;
9190 $ deferConstructorThrowPoints = false ;
9291 if ($ expr ->class instanceof Name) {
9392 $ className = $ scope ->resolveName ($ expr ->class );
9493
95- [$ constructorReflection , $ parametersAcceptor , $ classReflection , $ classFound , $ constructorImpurePoints ] = $ this ->processConstructorReflection ($ className , $ expr , $ scope );
94+ [$ constructorReflection , $ parametersAcceptor , $ constructorImpurePoints ] = $ this ->processConstructorReflection ($ className , $ expr , $ scope );
9695 $ impurePoints = array_merge ($ impurePoints , $ constructorImpurePoints );
9796 $ deferConstructorThrowPoints = true ;
9897
@@ -179,7 +178,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
179178 $ throwPoints = array_merge ($ throwPoints , $ additionalThrowPoints );
180179
181180 if ($ className !== null ) {
182- [$ constructorReflection , $ parametersAcceptor , $ classReflection , $ classFound , $ constructorImpurePoints ] = $ this ->processConstructorReflection ($ className , $ expr , $ scope );
181+ [$ constructorReflection , $ parametersAcceptor , $ constructorImpurePoints ] = $ this ->processConstructorReflection ($ className , $ expr , $ scope );
183182 $ impurePoints = array_merge ($ impurePoints , $ constructorImpurePoints );
184183 $ deferConstructorThrowPoints = true ;
185184 } else {
@@ -205,13 +204,14 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
205204 $ impurePoints = array_merge ($ impurePoints , $ argsResult ->getImpurePoints ());
206205 $ isAlwaysTerminating = $ isAlwaysTerminating || $ argsResult ->isAlwaysTerminating ();
207206
208- if ($ deferConstructorThrowPoints ) {
209- if ($ classReflection !== null && $ constructorReflection !== null && $ parametersAcceptor !== null ) {
210- $ constructorThrowPoint = $ this ->getConstructorThrowPoint ($ constructorReflection , $ parametersAcceptor , $ classReflection , $ expr , new Name \FullyQualified ($ classReflection ->getName ()), $ expr ->getArgs (), $ scope );
207+ if ($ deferConstructorThrowPoints && $ className !== null ) {
208+ if ($ constructorReflection !== null && $ parametersAcceptor !== null && $ this ->reflectionProvider ->hasClass ($ className )) {
209+ $ classReflection = $ this ->reflectionProvider ->getClass ($ className );
210+ $ constructorThrowPoint = $ this ->getConstructorThrowPoint ($ constructorReflection , $ parametersAcceptor , $ classReflection , $ expr , new Name \FullyQualified ($ className ), $ expr ->getArgs (), $ scope );
211211 if ($ constructorThrowPoint !== null ) {
212212 $ throwPoints [] = $ constructorThrowPoint ;
213213 }
214- } elseif (!$ classFound ) {
214+ } elseif (!$ this -> reflectionProvider -> hasClass ( $ className ) ) {
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, ?ClassReflection, bool, ImpurePoint[]}
229+ * @return array{?MethodReflection, ?ParametersAcceptor, ImpurePoint[]}
230230 */
231231 private function processConstructorReflection (string $ className , New_ $ expr , MutatingScope $ scope ): array
232232 {
@@ -235,7 +235,6 @@ private function processConstructorReflection(string $className, New_ $expr, Mut
235235 $ impurePoints = [];
236236
237237 $ classReflection = null ;
238- $ classFound = true ;
239238 if ($ this ->reflectionProvider ->hasClass ($ className )) {
240239 $ classReflection = $ this ->reflectionProvider ->getClass ($ className );
241240 if ($ classReflection ->hasConstructor ()) {
@@ -247,8 +246,6 @@ private function processConstructorReflection(string $className, New_ $expr, Mut
247246 $ constructorReflection ->getNamedArgumentsVariants (),
248247 );
249248 }
250- } else {
251- $ classFound = false ;
252249 }
253250
254251 if ($ constructorReflection !== null ) {
@@ -272,7 +269,7 @@ private function processConstructorReflection(string $className, New_ $expr, Mut
272269 );
273270 }
274271
275- return [$ constructorReflection , $ parametersAcceptor , $ classReflection , $ classFound , $ impurePoints ];
272+ return [$ constructorReflection , $ parametersAcceptor , $ impurePoints ];
276273 }
277274
278275 /**
0 commit comments