@@ -4639,6 +4639,9 @@ private function processClosureNode(
4639
4639
throw new ShouldNotHappenException ();
4640
4640
}
4641
4641
4642
+ $ returnType = $ closureType ->getReturnType ();
4643
+ $ isAlwaysTerminating = ($ returnType instanceof NeverType && $ returnType ->isExplicit ());
4644
+
4642
4645
$ nodeCallback (new InClosureNode ($ closureType , $ expr ), $ closureScope );
4643
4646
4644
4647
$ executionEnds = [];
@@ -4690,7 +4693,7 @@ private function processClosureNode(
4690
4693
array_merge ($ statementResult ->getImpurePoints (), $ closureImpurePoints ),
4691
4694
), $ closureScope );
4692
4695
4693
- return new ProcessClosureResult ($ scope , $ statementResult ->getThrowPoints (), $ statementResult ->getImpurePoints (), $ invalidateExpressions );
4696
+ return new ProcessClosureResult ($ scope , $ statementResult ->getThrowPoints (), $ statementResult ->getImpurePoints (), $ invalidateExpressions, $ isAlwaysTerminating );
4694
4697
}
4695
4698
4696
4699
$ count = 0 ;
@@ -4736,7 +4739,7 @@ private function processClosureNode(
4736
4739
array_merge ($ statementResult ->getImpurePoints (), $ closureImpurePoints ),
4737
4740
), $ closureScope );
4738
4741
4739
- return new ProcessClosureResult ($ scope ->processClosureScope ($ closureResultScope , null , $ byRefUses ), $ statementResult ->getThrowPoints (), $ statementResult ->getImpurePoints (), $ invalidateExpressions );
4742
+ return new ProcessClosureResult ($ scope ->processClosureScope ($ closureResultScope , null , $ byRefUses ), $ statementResult ->getThrowPoints (), $ statementResult ->getImpurePoints (), $ invalidateExpressions, $ isAlwaysTerminating );
4740
4743
}
4741
4744
4742
4745
/**
@@ -5180,6 +5183,7 @@ private function processArgs(
5180
5183
if ($ callCallbackImmediately ) {
5181
5184
$ throwPoints = array_merge ($ throwPoints , array_map (static fn (ThrowPoint $ throwPoint ) => $ throwPoint ->isExplicit () ? ThrowPoint::createExplicit ($ scope , $ throwPoint ->getType (), $ arg ->value , $ throwPoint ->canContainAnyThrowable ()) : ThrowPoint::createImplicit ($ scope , $ arg ->value ), $ closureResult ->getThrowPoints ()));
5182
5185
$ impurePoints = array_merge ($ impurePoints , $ closureResult ->getImpurePoints ());
5186
+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ closureResult ->isAlwaysTerminating ();
5183
5187
}
5184
5188
5185
5189
$ uses = [];
0 commit comments