@@ -1748,7 +1748,7 @@ private function processStmtNode(
17481748 }
17491749 }
17501750
1751- $ exhaustive = $ scopeForBranches ->getType ($ stmt ->cond ) instanceof NeverType ;
1751+ $ exhaustive = $ scopeForBranches ->getType ($ stmt ->cond )-> isNever ()-> yes () ;
17521752
17531753 if (!$ hasDefaultCase && !$ exhaustive ) {
17541754 $ alwaysTerminating = false ;
@@ -1893,7 +1893,7 @@ private function processStmtNode(
18931893 foreach ($ throwPoints as $ throwPoint ) {
18941894 $ newThrowPoint = $ throwPoint ->subtractCatchType ($ originalCatchType );
18951895
1896- if ($ newThrowPoint ->getType () instanceof NeverType ) {
1896+ if (! $ newThrowPoint ->getType ()-> isNever ()-> no () ) {
18971897 continue ;
18981898 }
18991899
@@ -2489,7 +2489,7 @@ private function findEarlyTerminatingExpr(Expr $expr, Scope $scope): ?Expr
24892489 }
24902490
24912491 $ exprType = $ scope ->getType ($ expr );
2492- if ($ exprType instanceof NeverType && $ exprType -> isExplicit ()) {
2492+ if ($ exprType-> isExplicitNever ()-> yes ()) {
24932493 return $ expr ;
24942494 }
24952495
@@ -2709,7 +2709,7 @@ static function (): void {
27092709 if ($ parametersAcceptor !== null ) {
27102710 $ expr = ArgumentsNormalizer::reorderFuncArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
27112711 $ returnType = $ parametersAcceptor ->getReturnType ();
2712- $ isAlwaysTerminating = $ isAlwaysTerminating || $ returnType instanceof NeverType && $ returnType -> isExplicit ();
2712+ $ isAlwaysTerminating = $ isAlwaysTerminating || $ returnType-> isExplicitNever ()-> yes ();
27132713 }
27142714
27152715 if (
@@ -3032,7 +3032,7 @@ static function (): void {
30323032 if ($ parametersAcceptor !== null ) {
30333033 $ expr = ArgumentsNormalizer::reorderMethodArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
30343034 $ returnType = $ parametersAcceptor ->getReturnType ();
3035- $ isAlwaysTerminating = $ returnType instanceof NeverType && $ returnType -> isExplicit ();
3035+ $ isAlwaysTerminating = $ returnType-> isExplicitNever ()-> yes ();
30363036 }
30373037
30383038 $ result = $ this ->processArgs (
@@ -3224,7 +3224,7 @@ static function (): void {
32243224 if ($ parametersAcceptor !== null ) {
32253225 $ expr = ArgumentsNormalizer::reorderStaticCallArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
32263226 $ returnType = $ parametersAcceptor ->getReturnType ();
3227- $ isAlwaysTerminating = $ returnType instanceof NeverType && $ returnType -> isExplicit ();
3227+ $ isAlwaysTerminating = $ returnType-> isExplicitNever ()-> yes ();
32283228 }
32293229 $ result = $ this ->processArgs ($ stmt , $ methodReflection , null , $ parametersAcceptor , $ expr , $ scope , $ nodeCallback , $ context , $ closureBindScope ?? null );
32303230 $ scope = $ result ->getScope ();
@@ -3450,7 +3450,7 @@ static function (): void {
34503450 $ leftResult = $ this ->processExprNode ($ stmt , $ expr ->left , $ scope , $ nodeCallback , $ context ->enterDeep ());
34513451 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ leftResult ->getTruthyScope (), $ nodeCallback , $ context );
34523452 $ rightExprType = $ rightResult ->getScope ()->getType ($ expr ->right );
3453- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3453+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
34543454 $ leftMergedWithRightScope = $ leftResult ->getFalseyScope ();
34553455 } else {
34563456 $ leftMergedWithRightScope = $ leftResult ->getScope ()->mergeWith ($ rightResult ->getScope ());
@@ -3471,7 +3471,7 @@ static function (): void {
34713471 $ leftResult = $ this ->processExprNode ($ stmt , $ expr ->left , $ scope , $ nodeCallback , $ context ->enterDeep ());
34723472 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ leftResult ->getFalseyScope (), $ nodeCallback , $ context );
34733473 $ rightExprType = $ rightResult ->getScope ()->getType ($ expr ->right );
3474- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3474+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
34753475 $ leftMergedWithRightScope = $ leftResult ->getTruthyScope ();
34763476 } else {
34773477 $ leftMergedWithRightScope = $ leftResult ->getScope ()->mergeWith ($ rightResult ->getScope ());
@@ -3498,7 +3498,7 @@ static function (): void {
34983498 $ rightScope = $ scope ->filterByFalseyValue ($ expr );
34993499 $ rightResult = $ this ->processExprNode ($ stmt , $ expr ->right , $ rightScope , $ nodeCallback , $ context ->enterDeep ());
35003500 $ rightExprType = $ scope ->getType ($ expr ->right );
3501- if ($ rightExprType instanceof NeverType && $ rightExprType -> isExplicit ()) {
3501+ if ($ rightExprType-> isExplicitNever ()-> yes ()) {
35023502 $ scope = $ scope ->filterByTruthyValue (new Expr \Isset_ ([$ expr ->left ]));
35033503 } else {
35043504 $ scope = $ scope ->filterByTruthyValue (new Expr \Isset_ ([$ expr ->left ]))->mergeWith ($ rightResult ->getScope ());
@@ -3936,12 +3936,12 @@ static function (): void {
39363936 } elseif ($ condType ->isFalse ()->yes ()) {
39373937 $ finalScope = $ ifFalseScope ;
39383938 } else {
3939- if ($ ifTrueType instanceof NeverType && $ ifTrueType ->isExplicit ()) {
3939+ if ($ ifTrueType !== null && $ ifTrueType ->isExplicitNever ()-> yes ()) {
39403940 $ finalScope = $ ifFalseScope ;
39413941 } else {
39423942 $ ifFalseType = $ ifFalseScope ->getType ($ expr ->else );
39433943
3944- if ($ ifFalseType instanceof NeverType && $ ifFalseType -> isExplicit ()) {
3944+ if ($ ifFalseType-> isExplicitNever ()-> yes ()) {
39453945 $ finalScope = $ ifTrueScope ;
39463946 } else {
39473947 $ finalScope = $ ifTrueScope ->mergeWith ($ ifFalseScope );
@@ -4196,7 +4196,7 @@ static function (): void {
41964196 }
41974197
41984198 $ remainingType = $ matchScope ->getType ($ expr ->cond );
4199- if (!$ hasDefaultCond && !$ hasAlwaysTrueCond && ! $ remainingType instanceof NeverType ) {
4199+ if (!$ hasDefaultCond && !$ hasAlwaysTrueCond && $ remainingType-> isNever ()-> no () ) {
42004200 $ throwPoints [] = ThrowPoint::createExplicit ($ scope , new ObjectType (UnhandledMatchError::class), $ expr , false );
42014201 }
42024202
@@ -4502,7 +4502,7 @@ private function getFunctionThrowPoint(
45024502 $ throwType = $ functionReflection ->getThrowType ();
45034503 if ($ throwType === null && $ parametersAcceptor !== null ) {
45044504 $ returnType = $ parametersAcceptor ->getReturnType ();
4505- if ($ returnType instanceof NeverType && $ returnType -> isExplicit ()) {
4505+ if ($ returnType-> isExplicitNever ()-> yes ()) {
45064506 $ throwType = new ObjectType (Throwable::class);
45074507 }
45084508 }
@@ -4560,7 +4560,7 @@ private function getMethodThrowPoint(MethodReflection $methodReflection, Paramet
45604560 $ throwType = $ methodReflection ->getThrowType ();
45614561 if ($ throwType === null ) {
45624562 $ returnType = $ parametersAcceptor ->getReturnType ();
4563- if ($ returnType instanceof NeverType && $ returnType -> isExplicit ()) {
4563+ if ($ returnType-> isExplicitNever ()-> yes ()) {
45644564 $ throwType = new ObjectType (Throwable::class);
45654565 }
45664566 }
@@ -4857,7 +4857,7 @@ private function processClosureNode(
48574857 }
48584858
48594859 $ returnType = $ closureType ->getReturnType ();
4860- $ isAlwaysTerminating = ($ returnType instanceof NeverType && $ returnType -> isExplicit ());
4860+ $ isAlwaysTerminating = ($ returnType-> isExplicitNever ()-> yes ());
48614861
48624862 $ nodeCallback (new InClosureNode ($ closureType , $ expr ), $ closureScope );
48634863
@@ -5545,7 +5545,7 @@ private function processArgs(
55455545 $ throwPoints = array_merge ($ throwPoints , $ callableThrowPoints );
55465546 $ impurePoints = array_merge ($ impurePoints , array_map (static fn (SimpleImpurePoint $ impurePoint ) => new ImpurePoint ($ scope , $ arg ->value , $ impurePoint ->getIdentifier (), $ impurePoint ->getDescription (), $ impurePoint ->isCertain ()), $ acceptors [0 ]->getImpurePoints ()));
55475547 $ returnType = $ acceptors [0 ]->getReturnType ();
5548- $ isAlwaysTerminating = $ isAlwaysTerminating || ($ returnType instanceof NeverType && $ returnType -> isExplicit ());
5548+ $ isAlwaysTerminating = $ isAlwaysTerminating || ($ returnType-> isExplicitNever ()-> yes ());
55495549 }
55505550 }
55515551 }
@@ -6961,7 +6961,7 @@ private function processCalledMethod(MethodReflection $methodReflection): ?Mutat
69616961 $ endNode = $ executionEnd ->getNode ();
69626962 if ($ endNode instanceof Node \Stmt \Expression) {
69636963 $ exprType = $ statementResult ->getScope ()->getType ($ endNode ->expr );
6964- if ($ exprType instanceof NeverType && $ exprType -> isExplicit ()) {
6964+ if ($ exprType-> isExplicitNever ()-> yes ()) {
69656965 continue ;
69666966 }
69676967 }
0 commit comments