@@ -261,7 +261,7 @@ public function processNodes(
261
261
}
262
262
263
263
/**
264
- * @param \PhpParser\Node\Stmt|\PhpParser\Node\Expr $parentNode
264
+ * @param \PhpParser\Node $parentNode
265
265
* @param \PhpParser\Node\Stmt[] $stmts
266
266
* @param \PHPStan\Analyser\MutatingScope $scope
267
267
* @param callable(\PhpParser\Node $node, Scope $scope): void $nodeCallback
@@ -298,7 +298,6 @@ public function processStmtNodes(
298
298
$ nodeCallback (new ExecutionEndNode (
299
299
$ stmt ,
300
300
new StatementResult (
301
- $ stmt ,
302
301
$ scope ,
303
302
$ hasYield ,
304
303
$ statementResult ->isAlwaysTerminating (),
@@ -324,7 +323,7 @@ public function processStmtNodes(
324
323
break ;
325
324
}
326
325
327
- $ statementResult = new StatementResult ($ parentNode instanceof Node \Stmt ? $ parentNode : new Node \ Stmt \ Expression ( $ parentNode ), $ scope , $ hasYield , $ alreadyTerminated , $ exitPoints , $ throwPoints );
326
+ $ statementResult = new StatementResult ($ scope , $ hasYield , $ alreadyTerminated , $ exitPoints , $ throwPoints );
328
327
if ($ stmtCount === 0 && $ shouldCheckLastStatement ) {
329
328
/** @var Node\Stmt\Function_|Node\Stmt\ClassMethod|Expr\Closure $parentNode */
330
329
$ parentNode = $ parentNode ;
@@ -373,12 +372,12 @@ private function processStmtNode(
373
372
) {
374
373
$ methodReflection = $ scope ->getClassReflection ()->getNativeMethod ($ stmt ->name ->toString ());
375
374
if ($ methodReflection instanceof NativeMethodReflection) {
376
- return new StatementResult ($ stmt , $ scope , false , false , [], []);
375
+ return new StatementResult ($ scope , false , false , [], []);
377
376
}
378
377
if ($ methodReflection instanceof PhpMethodReflection) {
379
378
$ declaringTrait = $ methodReflection ->getDeclaringTrait ();
380
379
if ($ declaringTrait === null || $ declaringTrait ->getName () !== $ scope ->getTraitReflection ()->getName ()) {
381
- return new StatementResult ($ stmt , $ scope , false , false , [], []);
380
+ return new StatementResult ($ scope , false , false , [], []);
382
381
}
383
382
}
384
383
}
@@ -561,7 +560,7 @@ private function processStmtNode(
561
560
$ throwPoints = [];
562
561
}
563
562
564
- return new StatementResult ($ stmt , $ scope , $ hasYield , true , [
563
+ return new StatementResult ($ scope , $ hasYield , true , [
565
564
new StatementExitPoint ($ stmt , $ scope ),
566
565
], $ throwPoints );
567
566
} elseif ($ stmt instanceof Continue_ || $ stmt instanceof Break_) {
@@ -575,7 +574,7 @@ private function processStmtNode(
575
574
$ throwPoints = [];
576
575
}
577
576
578
- return new StatementResult ($ stmt , $ scope , $ hasYield , true , [
577
+ return new StatementResult ($ scope , $ hasYield , true , [
579
578
new StatementExitPoint ($ stmt , $ scope ),
580
579
], $ throwPoints );
581
580
} elseif ($ stmt instanceof Node \Stmt \Expression) {
@@ -590,11 +589,11 @@ private function processStmtNode(
590
589
$ hasYield = $ result ->hasYield ();
591
590
$ throwPoints = $ result ->getThrowPoints ();
592
591
if ($ earlyTerminationExpr !== null ) {
593
- return new StatementResult ($ stmt , $ scope , $ hasYield , true , [
592
+ return new StatementResult ($ scope , $ hasYield , true , [
594
593
new StatementExitPoint ($ stmt , $ scope ),
595
594
], $ throwPoints );
596
595
}
597
- return new StatementResult ($ stmt , $ scope , $ hasYield , false , [], $ throwPoints );
596
+ return new StatementResult ($ scope , $ hasYield , false , [], $ throwPoints );
598
597
} elseif ($ stmt instanceof Node \Stmt \Namespace_) {
599
598
if ($ stmt ->name !== null ) {
600
599
$ scope = $ scope ->enterNamespace ($ stmt ->name ->toString ());
@@ -604,7 +603,7 @@ private function processStmtNode(
604
603
$ hasYield = false ;
605
604
$ throwPoints = [];
606
605
} elseif ($ stmt instanceof Node \Stmt \Trait_) {
607
- return new StatementResult ($ stmt , $ scope , false , false , [], []);
606
+ return new StatementResult ($ scope , false , false , [], []);
608
607
} elseif ($ stmt instanceof Node \Stmt \ClassLike) {
609
608
$ hasYield = false ;
610
609
$ throwPoints = [];
@@ -680,7 +679,7 @@ private function processStmtNode(
680
679
$ result = $ this ->processExprNode ($ stmt ->expr , $ scope , $ nodeCallback , ExpressionContext::createDeep ());
681
680
$ throwPoints = $ result ->getThrowPoints ();
682
681
$ throwPoints [] = ThrowPoint::createExplicit ($ result ->getScope (), $ scope ->getType ($ stmt ->expr ), false );
683
- return new StatementResult ($ stmt , $ result ->getScope (), $ result ->hasYield (), true , [
682
+ return new StatementResult ($ result ->getScope (), $ result ->hasYield (), true , [
684
683
new StatementExitPoint ($ stmt , $ scope ),
685
684
], $ throwPoints );
686
685
} elseif ($ stmt instanceof If_) {
@@ -768,7 +767,7 @@ private function processStmtNode(
768
767
$ finalScope = $ scope ;
769
768
}
770
769
771
- return new StatementResult ($ stmt , $ finalScope , $ hasYield , $ alwaysTerminating , $ exitPoints , $ throwPoints );
770
+ return new StatementResult ($ finalScope , $ hasYield , $ alwaysTerminating , $ exitPoints , $ throwPoints );
772
771
} elseif ($ stmt instanceof Node \Stmt \TraitUse) {
773
772
$ hasYield = false ;
774
773
$ throwPoints = [];
@@ -834,7 +833,6 @@ private function processStmtNode(
834
833
}
835
834
836
835
return new StatementResult (
837
- $ stmt ,
838
836
$ finalScope ,
839
837
$ finalScopeResult ->hasYield () || $ condResult ->hasYield (),
840
838
$ isIterableAtLeastOnce ->yes () && $ finalScopeResult ->isAlwaysTerminating (),
@@ -908,7 +906,6 @@ private function processStmtNode(
908
906
}
909
907
910
908
return new StatementResult (
911
- $ stmt ,
912
909
$ finalScope ,
913
910
$ finalScopeResult ->hasYield () || $ condResult ->hasYield (),
914
911
$ isAlwaysTerminating ,
@@ -977,7 +974,6 @@ private function processStmtNode(
977
974
}
978
975
979
976
return new StatementResult (
980
- $ stmt ,
981
977
$ finalScope ,
982
978
$ bodyScopeResult ->hasYield () || $ hasYield ,
983
979
$ alwaysTerminating ,
@@ -1061,7 +1057,6 @@ private function processStmtNode(
1061
1057
$ finalScope = $ finalScope ->mergeWith ($ scope );
1062
1058
1063
1059
return new StatementResult (
1064
- $ stmt ,
1065
1060
$ finalScope ,
1066
1061
$ finalScopeResult ->hasYield () || $ hasYield ,
1067
1062
false /* $finalScopeResult->isAlwaysTerminating() && $isAlwaysIterable*/ ,
@@ -1133,7 +1128,7 @@ private function processStmtNode(
1133
1128
$ finalScope = $ scope ->mergeWith ($ finalScope );
1134
1129
}
1135
1130
1136
- return new StatementResult ($ stmt , $ finalScope , $ hasYield , $ alwaysTerminating , $ exitPointsForOuterLoop , $ throwPoints );
1131
+ return new StatementResult ($ finalScope , $ hasYield , $ alwaysTerminating , $ exitPointsForOuterLoop , $ throwPoints );
1137
1132
} elseif ($ stmt instanceof TryCatch) {
1138
1133
$ branchScopeResult = $ this ->processStmtNodes ($ stmt , $ stmt ->stmts , $ scope , $ nodeCallback );
1139
1134
$ branchScope = $ branchScopeResult ->getScope ();
@@ -1303,7 +1298,7 @@ private function processStmtNode(
1303
1298
$ exitPoints = array_merge ($ exitPoints , $ finallyResult ->getExitPoints ());
1304
1299
}
1305
1300
1306
- return new StatementResult ($ stmt , $ finalScope , $ hasYield , $ alwaysTerminating , $ exitPoints , array_merge ($ throwPoints , $ throwPointsForLater ));
1301
+ return new StatementResult ($ finalScope , $ hasYield , $ alwaysTerminating , $ exitPoints , array_merge ($ throwPoints , $ throwPointsForLater ));
1307
1302
} elseif ($ stmt instanceof Unset_) {
1308
1303
$ hasYield = false ;
1309
1304
$ throwPoints = [];
@@ -1398,7 +1393,7 @@ private function processStmtNode(
1398
1393
$ throwPoints = [];
1399
1394
}
1400
1395
1401
- return new StatementResult ($ stmt , $ scope , $ hasYield , false , [], $ throwPoints );
1396
+ return new StatementResult ($ scope , $ hasYield , false , [], $ throwPoints );
1402
1397
}
1403
1398
1404
1399
private function getCurrentClassReflection (Node \Stmt \ClassLike $ stmt , Scope $ scope ): ClassReflection
0 commit comments