@@ -2552,6 +2552,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context): Exp
25522552 $ scope = $ nameResult ->getScope ();
25532553 $ throwPoints = $ nameResult ->getThrowPoints ();
25542554 $ impurePoints = $ nameResult ->getImpurePoints ();
2555+ $ isAlwaysTerminating = $ nameResult ->isAlwaysTerminating ();
25552556 if (
25562557 $ nameType ->isObject ()->yes ()
25572558 && $ nameType ->isCallable ()->yes ()
@@ -2567,6 +2568,7 @@ static function (): void {
25672568 );
25682569 $ throwPoints = array_merge ($ throwPoints , $ invokeResult ->getThrowPoints ());
25692570 $ impurePoints = array_merge ($ impurePoints , $ invokeResult ->getImpurePoints ());
2571+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ invokeResult ->isAlwaysTerminating ();
25702572 } elseif ($ parametersAcceptor instanceof CallableParametersAcceptor) {
25712573 $ callableThrowPoints = array_map (static fn (SimpleThrowPoint $ throwPoint ) => $ throwPoint ->isExplicit () ? ThrowPoint::createExplicit ($ scope , $ throwPoint ->getType (), $ expr , $ throwPoint ->canContainAnyThrowable ()) : ThrowPoint::createImplicit ($ scope , $ expr ), $ parametersAcceptor ->getThrowPoints ());
25722574 if (!$ this ->implicitThrows ) {
@@ -2602,13 +2604,14 @@ static function (): void {
26022604 if ($ parametersAcceptor !== null ) {
26032605 $ expr = ArgumentsNormalizer::reorderFuncArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
26042606 $ returnType = $ parametersAcceptor ->getReturnType ();
2605- $ isAlwaysTerminating = $ returnType instanceof NeverType && $ returnType ->isExplicit ();
2607+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ returnType instanceof NeverType && $ returnType ->isExplicit ();
26062608 }
26072609 $ result = $ this ->processArgs ($ stmt , $ functionReflection , null , $ parametersAcceptor , $ expr , $ scope , $ nodeCallback , $ context );
26082610 $ scope = $ result ->getScope ();
26092611 $ hasYield = $ result ->hasYield ();
26102612 $ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
26112613 $ impurePoints = array_merge ($ impurePoints , $ result ->getImpurePoints ());
2614+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ result ->isAlwaysTerminating ();
26122615
26132616 if ($ functionReflection !== null ) {
26142617 $ functionThrowPoint = $ this ->getFunctionThrowPoint ($ functionReflection , $ parametersAcceptor , $ expr , $ scope );
@@ -5009,6 +5012,7 @@ private function processArgs(
50095012 $ hasYield = false ;
50105013 $ throwPoints = [];
50115014 $ impurePoints = [];
5015+ $ isAlwaysTerminating = false ;
50125016 foreach ($ args as $ i => $ arg ) {
50135017 $ assignByReference = false ;
50145018 $ parameter = null ;
@@ -5158,6 +5162,7 @@ private function processArgs(
51585162 $ exprResult = $ this ->processExprNode ($ stmt , $ arg ->value , $ scopeToPass , $ nodeCallback , $ context ->enterDeep ());
51595163 $ throwPoints = array_merge ($ throwPoints , $ exprResult ->getThrowPoints ());
51605164 $ impurePoints = array_merge ($ impurePoints , $ exprResult ->getImpurePoints ());
5165+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ exprResult ->isAlwaysTerminating ();
51615166 $ scope = $ exprResult ->getScope ();
51625167 $ hasYield = $ hasYield || $ exprResult ->hasYield ();
51635168
@@ -5282,7 +5287,7 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
52825287 }
52835288 }
52845289
5285- return new ExpressionResult ($ scope , $ hasYield , $ throwPoints , $ impurePoints );
5290+ return new ExpressionResult ($ scope , $ hasYield , $ throwPoints , $ impurePoints, isAlwaysTerminating: $ isAlwaysTerminating );
52865291 }
52875292
52885293 /**
0 commit comments