@@ -2934,7 +2934,7 @@ static function (): void {
2934
2934
return new ExpressionResult (
2935
2935
$ scope ,
2936
2936
$ exprResult ->hasYield (),
2937
- false ,
2937
+ $ exprResult -> isAlwaysTerminating () ,
2938
2938
$ exprResult ->getThrowPoints (),
2939
2939
$ exprResult ->getImpurePoints (),
2940
2940
static fn (): MutatingScope => $ scope ->filterByTruthyValue ($ expr ),
@@ -3115,6 +3115,7 @@ static function (): void {
3115
3115
$ hasYield = $ hasYield || $ result ->hasYield ();
3116
3116
$ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
3117
3117
$ impurePoints = array_merge ($ impurePoints , $ result ->getImpurePoints ());
3118
+ $ isAlwaysTerminating = $ result ->isAlwaysTerminating ();
3118
3119
$ scope = $ result ->getScope ();
3119
3120
if ($ this ->phpVersion ->supportsPropertyHooks ()) {
3120
3121
$ throwPoints [] = ThrowPoint::createImplicit ($ scope , $ expr );
@@ -3139,7 +3140,7 @@ static function (): void {
3139
3140
return new ExpressionResult (
3140
3141
$ scope ,
3141
3142
$ exprResult ->hasYield (),
3142
- false ,
3143
+ $ exprResult -> isAlwaysTerminating () ,
3143
3144
$ exprResult ->getThrowPoints (),
3144
3145
$ exprResult ->getImpurePoints (),
3145
3146
static fn (): MutatingScope => $ scope ->filterByTruthyValue ($ expr ),
@@ -3163,13 +3164,15 @@ static function (): void {
3163
3164
$ hasYield = $ result ->hasYield ();
3164
3165
$ throwPoints = $ result ->getThrowPoints ();
3165
3166
$ impurePoints = $ result ->getImpurePoints ();
3167
+ $ isAlwaysTerminating = $ result ->isAlwaysTerminating ();
3166
3168
$ scope = $ result ->getScope ();
3167
3169
}
3168
3170
if ($ expr ->name instanceof Expr) {
3169
3171
$ result = $ this ->processExprNode ($ stmt , $ expr ->name , $ scope , $ nodeCallback , $ context ->enterDeep ());
3170
3172
$ hasYield = $ hasYield || $ result ->hasYield ();
3171
3173
$ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
3172
3174
$ impurePoints = array_merge ($ impurePoints , $ result ->getImpurePoints ());
3175
+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ result ->isAlwaysTerminating ();
3173
3176
$ scope = $ result ->getScope ();
3174
3177
}
3175
3178
} elseif ($ expr instanceof Expr \Closure) {
@@ -3240,13 +3243,15 @@ static function (): void {
3240
3243
$ hasYield = $ result ->hasYield ();
3241
3244
$ throwPoints = $ result ->getThrowPoints ();
3242
3245
$ impurePoints = $ result ->getImpurePoints ();
3246
+ $ isAlwaysTerminating = $ result ->isAlwaysTerminating ();
3243
3247
$ scope = $ result ->getScope ();
3244
3248
}
3245
3249
3246
3250
$ result = $ this ->processExprNode ($ stmt , $ expr ->var , $ scope , $ nodeCallback , $ context ->enterDeep ());
3247
3251
$ hasYield = $ hasYield || $ result ->hasYield ();
3248
3252
$ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
3249
3253
$ impurePoints = array_merge ($ impurePoints , $ result ->getImpurePoints ());
3254
+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ result ->isAlwaysTerminating ();
3250
3255
$ scope = $ result ->getScope ();
3251
3256
} elseif ($ expr instanceof Array_) {
3252
3257
$ itemNodes = [];
@@ -3457,6 +3462,7 @@ static function (): void {
3457
3462
$ hasYield = $ result ->hasYield ();
3458
3463
$ throwPoints = $ result ->getThrowPoints ();
3459
3464
$ impurePoints = $ result ->getImpurePoints ();
3465
+ $ isAlwaysTerminating = $ result ->isAlwaysTerminating ();
3460
3466
} else {
3461
3467
$ hasYield = false ;
3462
3468
$ throwPoints = [];
@@ -3470,6 +3476,7 @@ static function (): void {
3470
3476
$ hasYield = $ hasYield || $ result ->hasYield ();
3471
3477
$ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
3472
3478
$ impurePoints = array_merge ($ impurePoints , $ result ->getImpurePoints ());
3479
+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ result ->isAlwaysTerminating ();
3473
3480
} else {
3474
3481
$ nodeCallback ($ expr ->name , $ scope );
3475
3482
}
@@ -3520,6 +3527,7 @@ static function (): void {
3520
3527
$ hasYield = $ hasYield || $ result ->hasYield ();
3521
3528
$ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
3522
3529
$ impurePoints = array_merge ($ impurePoints , $ result ->getImpurePoints ());
3530
+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ result ->isAlwaysTerminating ();
3523
3531
}
3524
3532
} elseif ($ expr instanceof List_) {
3525
3533
// only in assign and foreach, processed elsewhere
@@ -3549,6 +3557,7 @@ static function (): void {
3549
3557
$ hasYield = $ result ->hasYield ();
3550
3558
$ throwPoints = $ result ->getThrowPoints ();
3551
3559
$ impurePoints = $ result ->getImpurePoints ();
3560
+ $ isAlwaysTerminating = $ result ->isAlwaysTerminating ();
3552
3561
foreach ($ additionalThrowPoints as $ throwPoint ) {
3553
3562
$ throwPoints [] = $ throwPoint ;
3554
3563
}
@@ -3644,6 +3653,7 @@ static function (): void {
3644
3653
$ hasYield = $ hasYield || $ result ->hasYield ();
3645
3654
$ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
3646
3655
$ impurePoints = array_merge ($ impurePoints , $ result ->getImpurePoints ());
3656
+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ result ->isAlwaysTerminating ();
3647
3657
} elseif (
3648
3658
$ expr instanceof Expr \PreInc
3649
3659
|| $ expr instanceof Expr \PostInc
0 commit comments