@@ -1833,7 +1833,7 @@ private function processStmtNode(
18331833 }
18341834 }
18351835
1836- $ exhaustive = $ scopeForBranches ->getType ($ stmt ->cond ) instanceof NeverType ;
1836+ $ exhaustive = $ scopeForBranches ->getType ($ stmt ->cond )-> isNever ()-> yes () ;
18371837
18381838 if (!$ hasDefaultCase && !$ exhaustive ) {
18391839 $ alwaysTerminating = false ;
@@ -1978,7 +1978,7 @@ private function processStmtNode(
19781978 foreach ($ throwPoints as $ throwPoint ) {
19791979 $ newThrowPoint = $ throwPoint ->subtractCatchType ($ originalCatchType );
19801980
1981- if ($ newThrowPoint ->getType () instanceof NeverType ) {
1981+ if (! $ newThrowPoint ->getType ()-> isNever ()-> no () ) {
19821982 continue ;
19831983 }
19841984
@@ -2553,7 +2553,7 @@ private function findEarlyTerminatingExpr(Expr $expr, Scope $scope): ?Expr
25532553 }
25542554
25552555 $ exprType = $ scope ->getType ($ expr );
2556- if ($ exprType instanceof NeverType && $ exprType -> isExplicit ()) {
2556+ if ($ exprType-> isExplicitNever ()-> yes ()) {
25572557 return $ expr ;
25582558 }
25592559
@@ -2803,7 +2803,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
28032803 if ($ parametersAcceptor !== null ) {
28042804 $ normalizedExpr = ArgumentsNormalizer::reorderFuncArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
28052805 $ returnType = $ parametersAcceptor ->getReturnType ();
2806- $ isAlwaysTerminating = $ isAlwaysTerminating || $ returnType instanceof NeverType && $ returnType -> isExplicit ();
2806+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ returnType-> isExplicitNever ()-> yes ();
28072807 }
28082808
28092809 if (
@@ -3156,7 +3156,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
31563156 if ($ parametersAcceptor !== null ) {
31573157 $ normalizedExpr = ArgumentsNormalizer::reorderMethodArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
31583158 $ returnType = $ parametersAcceptor ->getReturnType ();
3159- $ isAlwaysTerminating = $ returnType instanceof NeverType && $ returnType -> isExplicit ();
3159+ $ isAlwaysTerminating = $ returnType-> isExplicitNever ()-> yes ();
31603160 }
31613161
31623162 $ result = $ this ->processArgs (
@@ -3367,7 +3367,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
33673367 if ($ parametersAcceptor !== null ) {
33683368 $ normalizedExpr = ArgumentsNormalizer::reorderStaticCallArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
33693369 $ returnType = $ parametersAcceptor ->getReturnType ();
3370- $ isAlwaysTerminating = $ returnType instanceof NeverType && $ returnType -> isExplicit ();
3370+ $ isAlwaysTerminating = $ returnType-> isExplicitNever ()-> yes ();
33713371 }
33723372 $ result = $ this ->processArgs ($ stmt , $ methodReflection , null , $ parametersAcceptor , $ normalizedExpr , $ scope , $ storage , $ nodeCallback , $ context , $ closureBindScope ?? null );
33733373 $ scope = $ result ->getScope ();
@@ -3600,7 +3600,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36003600 $ leftResult = $ this ->processExprNode ($ stmt , $ expr ->left , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
36013601 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ leftResult ->getTruthyScope (), $ storage , $ nodeCallback , $ context );
36023602 $ rightExprType = $ rightResult ->getScope ()->getType ($ expr ->right );
3603- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3603+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
36043604 $ leftMergedWithRightScope = $ leftResult ->getFalseyScope ();
36053605 } else {
36063606 $ leftMergedWithRightScope = $ leftResult ->getScope ()->mergeWith ($ rightResult ->getScope ());
@@ -3622,7 +3622,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36223622 $ leftResult = $ this ->processExprNode ($ stmt , $ expr ->left , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
36233623 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ leftResult ->getFalseyScope (), $ storage , $ nodeCallback , $ context );
36243624 $ rightExprType = $ rightResult ->getScope ()->getType ($ expr ->right );
3625- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3625+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
36263626 $ leftMergedWithRightScope = $ leftResult ->getTruthyScope ();
36273627 } else {
36283628 $ leftMergedWithRightScope = $ leftResult ->getScope ()->mergeWith ($ rightResult ->getScope ());
@@ -3649,7 +3649,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36493649 $ rightScope = $ scope ->filterByFalseyValue ($ expr );
36503650 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ rightScope , $ storage , $ nodeCallback , $ context ->enterDeep ());
36513651 $ rightExprType = $ scope ->getType ($ expr ->right );
3652- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3652+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
36533653 $ scope = $ scope ->filterByTruthyValue (new Expr \Isset_ ([$ expr ->left ]));
36543654 } else {
36553655 $ scope = $ scope ->filterByTruthyValue (new Expr \Isset_ ([$ expr ->left ]))->mergeWith ($ rightResult ->getScope ());
@@ -4090,12 +4090,12 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
40904090 } elseif ($ condType ->isFalse ()->yes ()) {
40914091 $ finalScope = $ ifFalseScope ;
40924092 } else {
4093- if ($ ifTrueType instanceof NeverType && $ ifTrueType ->isExplicit ()) {
4093+ if ($ ifTrueType !== null && $ ifTrueType ->isExplicitNever ()-> yes ()) {
40944094 $ finalScope = $ ifFalseScope ;
40954095 } else {
40964096 $ ifFalseType = $ ifFalseScope ->getType ($ expr ->else );
40974097
4098- if ($ ifFalseType instanceof NeverType && $ ifFalseType -> isExplicit ()) {
4098+ if ($ ifFalseType-> isExplicitNever ()-> yes ()) {
40994099 $ finalScope = $ ifTrueScope ;
41004100 } else {
41014101 $ finalScope = $ ifTrueScope ->mergeWith ($ ifFalseScope );
@@ -4355,7 +4355,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
43554355
43564356 if (!$ hasDefaultCond && !$ hasAlwaysTrueCond ) {
43574357 $ remainingType = $ matchScope ->getType ($ expr ->cond );
4358- if (! $ remainingType instanceof NeverType ) {
4358+ if ($ remainingType-> isNever ()-> no () ) {
43594359 $ throwPoints [] = InternalThrowPoint::createExplicit ($ scope , new ObjectType (UnhandledMatchError::class), $ expr , false );
43604360 }
43614361 }
@@ -4668,7 +4668,7 @@ private function getFunctionThrowPoint(
46684668 $ throwType = $ functionReflection ->getThrowType ();
46694669 if ($ throwType === null && $ parametersAcceptor !== null ) {
46704670 $ returnType = $ parametersAcceptor ->getReturnType ();
4671- if ($ returnType instanceof NeverType && $ returnType -> isExplicit ()) {
4671+ if ($ returnType-> isExplicitNever ()-> yes ()) {
46724672 $ throwType = new ObjectType (Throwable::class);
46734673 }
46744674 }
@@ -4726,7 +4726,7 @@ private function getMethodThrowPoint(MethodReflection $methodReflection, Paramet
47264726 $ throwType = $ methodReflection ->getThrowType ();
47274727 if ($ throwType === 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 }
@@ -5038,7 +5038,7 @@ private function processClosureNode(
50385038 }
50395039
50405040 $ returnType = $ closureType ->getReturnType ();
5041- $ isAlwaysTerminating = ($ returnType instanceof NeverType && $ returnType -> isExplicit ());
5041+ $ isAlwaysTerminating = ($ returnType-> isExplicitNever ()-> yes ());
50425042
50435043 $ this ->callNodeCallback ($ nodeCallback , new InClosureNode ($ closureType , $ expr ), $ closureScope , $ storage );
50445044
@@ -5731,7 +5731,7 @@ private function processArgs(
57315731 $ throwPoints = array_merge ($ throwPoints , $ callableThrowPoints );
57325732 $ impurePoints = array_merge ($ impurePoints , array_map (static fn (SimpleImpurePoint $ impurePoint ) => new ImpurePoint ($ scope , $ arg ->value , $ impurePoint ->getIdentifier (), $ impurePoint ->getDescription (), $ impurePoint ->isCertain ()), $ acceptors [0 ]->getImpurePoints ()));
57335733 $ returnType = $ acceptors [0 ]->getReturnType ();
5734- $ isAlwaysTerminating = $ isAlwaysTerminating || ($ returnType instanceof NeverType && $ returnType -> isExplicit ());
5734+ $ isAlwaysTerminating = $ isAlwaysTerminating || ($ returnType-> isExplicitNever ()-> yes ());
57355735 }
57365736 }
57375737 }
@@ -7196,7 +7196,7 @@ private function processCalledMethod(MethodReflection $methodReflection): ?Mutat
71967196 $ endNode = $ executionEnd ->getNode ();
71977197 if ($ endNode instanceof Node \Stmt \Expression) {
71987198 $ exprType = $ statementResult ->getScope ()->getType ($ endNode ->expr );
7199- if ($ exprType instanceof NeverType && $ exprType -> isExplicit ()) {
7199+ if ($ exprType-> isExplicitNever ()-> yes ()) {
72007200 continue ;
72017201 }
72027202 }
0 commit comments