@@ -1834,7 +1834,7 @@ private function processStmtNode(
18341834 }
18351835 }
18361836
1837- $ exhaustive = $ scopeForBranches ->getType ($ stmt ->cond ) instanceof NeverType ;
1837+ $ exhaustive = $ scopeForBranches ->getType ($ stmt ->cond )-> isNever ()-> yes () ;
18381838
18391839 if (!$ hasDefaultCase && !$ exhaustive ) {
18401840 $ alwaysTerminating = false ;
@@ -1979,7 +1979,7 @@ private function processStmtNode(
19791979 foreach ($ throwPoints as $ throwPoint ) {
19801980 $ newThrowPoint = $ throwPoint ->subtractCatchType ($ originalCatchType );
19811981
1982- if ($ newThrowPoint ->getType () instanceof NeverType ) {
1982+ if (! $ newThrowPoint ->getType ()-> isNever ()-> no () ) {
19831983 continue ;
19841984 }
19851985
@@ -2575,7 +2575,7 @@ private function findEarlyTerminatingExpr(Expr $expr, Scope $scope): ?Expr
25752575 }
25762576
25772577 $ exprType = $ scope ->getType ($ expr );
2578- if ($ exprType instanceof NeverType && $ exprType -> isExplicit ()) {
2578+ if ($ exprType-> isExplicitNever ()-> yes ()) {
25792579 return $ expr ;
25802580 }
25812581
@@ -2825,7 +2825,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
28252825 if ($ parametersAcceptor !== null ) {
28262826 $ normalizedExpr = ArgumentsNormalizer::reorderFuncArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
28272827 $ returnType = $ parametersAcceptor ->getReturnType ();
2828- $ isAlwaysTerminating = $ isAlwaysTerminating || $ returnType instanceof NeverType && $ returnType -> isExplicit ();
2828+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ returnType-> isExplicitNever ()-> yes ();
28292829 }
28302830
28312831 if (
@@ -3188,7 +3188,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
31883188 if ($ parametersAcceptor !== null ) {
31893189 $ normalizedExpr = ArgumentsNormalizer::reorderMethodArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
31903190 $ returnType = $ parametersAcceptor ->getReturnType ();
3191- $ isAlwaysTerminating = $ returnType instanceof NeverType && $ returnType -> isExplicit ();
3191+ $ isAlwaysTerminating = $ returnType-> isExplicitNever ()-> yes ();
31923192 }
31933193
31943194 $ result = $ this ->processArgs (
@@ -3399,7 +3399,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
33993399 if ($ parametersAcceptor !== null ) {
34003400 $ normalizedExpr = ArgumentsNormalizer::reorderStaticCallArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
34013401 $ returnType = $ parametersAcceptor ->getReturnType ();
3402- $ isAlwaysTerminating = $ returnType instanceof NeverType && $ returnType -> isExplicit ();
3402+ $ isAlwaysTerminating = $ returnType-> isExplicitNever ()-> yes ();
34033403 }
34043404 $ result = $ this ->processArgs ($ stmt , $ methodReflection , null , $ parametersAcceptor , $ normalizedExpr , $ scope , $ storage , $ nodeCallback , $ context , $ closureBindScope ?? null );
34053405 $ scope = $ result ->getScope ();
@@ -3632,7 +3632,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36323632 $ leftResult = $ this ->processExprNode ($ stmt , $ expr ->left , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
36333633 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ leftResult ->getTruthyScope (), $ storage , $ nodeCallback , $ context );
36343634 $ rightExprType = $ rightResult ->getScope ()->getType ($ expr ->right );
3635- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3635+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
36363636 $ leftMergedWithRightScope = $ leftResult ->getFalseyScope ();
36373637 } else {
36383638 $ leftMergedWithRightScope = $ leftResult ->getScope ()->mergeWith ($ rightResult ->getScope ());
@@ -3654,7 +3654,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36543654 $ leftResult = $ this ->processExprNode ($ stmt , $ expr ->left , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
36553655 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ leftResult ->getFalseyScope (), $ storage , $ nodeCallback , $ context );
36563656 $ rightExprType = $ rightResult ->getScope ()->getType ($ expr ->right );
3657- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3657+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
36583658 $ leftMergedWithRightScope = $ leftResult ->getTruthyScope ();
36593659 } else {
36603660 $ leftMergedWithRightScope = $ leftResult ->getScope ()->mergeWith ($ rightResult ->getScope ());
@@ -3681,7 +3681,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36813681 $ rightScope = $ scope ->filterByFalseyValue ($ expr );
36823682 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ rightScope , $ storage , $ nodeCallback , $ context ->enterDeep ());
36833683 $ rightExprType = $ scope ->getType ($ expr ->right );
3684- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3684+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
36853685 $ scope = $ scope ->filterByTruthyValue (new Expr \Isset_ ([$ expr ->left ]));
36863686 } else {
36873687 $ scope = $ scope ->filterByTruthyValue (new Expr \Isset_ ([$ expr ->left ]))->mergeWith ($ rightResult ->getScope ());
@@ -4122,12 +4122,12 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
41224122 } elseif ($ condType ->isFalse ()->yes ()) {
41234123 $ finalScope = $ ifFalseScope ;
41244124 } else {
4125- if ($ ifTrueType instanceof NeverType && $ ifTrueType ->isExplicit ()) {
4125+ if ($ ifTrueType !== null && $ ifTrueType ->isExplicitNever ()-> yes ()) {
41264126 $ finalScope = $ ifFalseScope ;
41274127 } else {
41284128 $ ifFalseType = $ ifFalseScope ->getType ($ expr ->else );
41294129
4130- if ($ ifFalseType instanceof NeverType && $ ifFalseType -> isExplicit ()) {
4130+ if ($ ifFalseType-> isExplicitNever ()-> yes ()) {
41314131 $ finalScope = $ ifTrueScope ;
41324132 } else {
41334133 $ finalScope = $ ifTrueScope ->mergeWith ($ ifFalseScope );
@@ -4396,7 +4396,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
43964396 $ isExhaustive = $ hasDefaultCond || $ hasAlwaysTrueCond ;
43974397 if (!$ isExhaustive ) {
43984398 $ remainingType = $ matchScope ->getType ($ expr ->cond );
4399- if ($ remainingType instanceof NeverType ) {
4399+ if ($ remainingType-> isNever ()-> no () ) {
44004400 $ isExhaustive = true ;
44014401 }
44024402 }
@@ -4726,7 +4726,7 @@ private function getFunctionThrowPoint(
47264726 $ throwType = $ functionReflection ->getThrowType ();
47274727 if ($ throwType === null && $ parametersAcceptor !== null ) {
47284728 $ returnType = $ parametersAcceptor ->getReturnType ();
4729- if ($ returnType instanceof NeverType && $ returnType -> isExplicit ()) {
4729+ if ($ returnType-> isExplicitNever ()-> yes ()) {
47304730 $ throwType = new ObjectType (Throwable::class);
47314731 }
47324732 }
@@ -4784,7 +4784,7 @@ private function getMethodThrowPoint(MethodReflection $methodReflection, Paramet
47844784 $ throwType = $ methodReflection ->getThrowType ();
47854785 if ($ throwType === null ) {
47864786 $ returnType = $ parametersAcceptor ->getReturnType ();
4787- if ($ returnType instanceof NeverType && $ returnType -> isExplicit ()) {
4787+ if ($ returnType-> isExplicitNever ()-> yes ()) {
47884788 $ throwType = new ObjectType (Throwable::class);
47894789 }
47904790 }
@@ -5096,7 +5096,7 @@ private function processClosureNode(
50965096 }
50975097
50985098 $ returnType = $ closureType ->getReturnType ();
5099- $ isAlwaysTerminating = ($ returnType instanceof NeverType && $ returnType -> isExplicit ());
5099+ $ isAlwaysTerminating = ($ returnType-> isExplicitNever ()-> yes ());
51005100
51015101 $ this ->callNodeCallback ($ nodeCallback , new InClosureNode ($ closureType , $ expr ), $ closureScope , $ storage );
51025102
@@ -5789,7 +5789,7 @@ private function processArgs(
57895789 $ throwPoints = array_merge ($ throwPoints , $ callableThrowPoints );
57905790 $ impurePoints = array_merge ($ impurePoints , array_map (static fn (SimpleImpurePoint $ impurePoint ) => new ImpurePoint ($ scope , $ arg ->value , $ impurePoint ->getIdentifier (), $ impurePoint ->getDescription (), $ impurePoint ->isCertain ()), $ acceptors [0 ]->getImpurePoints ()));
57915791 $ returnType = $ acceptors [0 ]->getReturnType ();
5792- $ isAlwaysTerminating = $ isAlwaysTerminating || ($ returnType instanceof NeverType && $ returnType -> isExplicit ());
5792+ $ isAlwaysTerminating = $ isAlwaysTerminating || ($ returnType-> isExplicitNever ()-> yes ());
57935793 }
57945794 }
57955795 }
@@ -7254,7 +7254,7 @@ private function processCalledMethod(MethodReflection $methodReflection): ?Mutat
72547254 $ endNode = $ executionEnd ->getNode ();
72557255 if ($ endNode instanceof Node \Stmt \Expression) {
72567256 $ exprType = $ statementResult ->getScope ()->getType ($ endNode ->expr );
7257- if ($ exprType instanceof NeverType && $ exprType -> isExplicit ()) {
7257+ if ($ exprType-> isExplicitNever ()-> yes ()) {
72587258 continue ;
72597259 }
72607260 }
0 commit comments