Skip to content

Commit 2641439

Browse files
committed
fixes after rebase
1 parent 9873aad commit 2641439

13 files changed

+16
-26
lines changed

src/Analyser/ExprHandler/BooleanAndHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use PHPStan\Node\BooleanAndNode;
2020
use PHPStan\Type\BooleanType;
2121
use PHPStan\Type\Constant\ConstantBooleanType;
22-
use PHPStan\Type\NeverType;
2322
use PHPStan\Type\Type;
2423
use function array_merge;
2524

@@ -91,7 +90,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
9190
$leftTruthyScope = $leftResult->getTruthyScope();
9291
$rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftTruthyScope, $storage, $nodeCallback, $context);
9392
$rightExprType = $rightResult->getScope()->getType($expr->right);
94-
if ($rightExprType instanceof NeverType && $rightExprType->isExplicit()) {
93+
if ($rightExprType->isExplicitNever()->yes()) {
9594
$leftMergedWithRightScope = $leftResult->getFalseyScope();
9695
} else {
9796
$leftMergedWithRightScope = $leftResult->getScope()->mergeWith($rightResult->getScope());

src/Analyser/ExprHandler/BooleanOrHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use PHPStan\Node\BooleanOrNode;
1818
use PHPStan\Type\BooleanType;
1919
use PHPStan\Type\Constant\ConstantBooleanType;
20-
use PHPStan\Type\NeverType;
2120
use PHPStan\Type\Type;
2221
use function array_merge;
2322

@@ -75,7 +74,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
7574
$leftFalseyScope = $leftResult->getFalseyScope();
7675
$rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftFalseyScope, $storage, $nodeCallback, $context);
7776
$rightExprType = $rightResult->getScope()->getType($expr->right);
78-
if ($rightExprType instanceof NeverType && $rightExprType->isExplicit()) {
77+
if ($rightExprType->isExplicitNever()->yes()) {
7978
$leftMergedWithRightScope = $leftResult->getTruthyScope();
8079
} else {
8180
$leftMergedWithRightScope = $leftResult->getScope()->mergeWith($rightResult->getScope());

src/Analyser/ExprHandler/CoalesceHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use PHPStan\Analyser\MutatingScope;
1414
use PHPStan\Analyser\NodeScopeResolver;
1515
use PHPStan\DependencyInjection\AutowiredService;
16-
use PHPStan\Type\NeverType;
1716
use PHPStan\Type\Type;
1817
use PHPStan\Type\TypeCombinator;
1918
use function array_merge;
@@ -76,7 +75,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
7675
$rightScope = $scope->filterByFalseyValue($expr);
7776
$rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $rightScope, $storage, $nodeCallback, $context->enterDeep());
7877
$rightExprType = $scope->getType($expr->right);
79-
if ($rightExprType instanceof NeverType && $rightExprType->isExplicit()) {
78+
if ($rightExprType->isExplicitNever()->yes()) {
8079
$scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left]));
8180
} else {
8281
$scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left]))->mergeWith($rightResult->getScope());

src/Analyser/ExprHandler/FuncCallHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
use PHPStan\Type\IntegerType;
5353
use PHPStan\Type\IntersectionType;
5454
use PHPStan\Type\MixedType;
55-
use PHPStan\Type\NeverType;
5655
use PHPStan\Type\NullType;
5756
use PHPStan\Type\ObjectType;
5857
use PHPStan\Type\StringType;
@@ -160,7 +159,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
160159
if ($parametersAcceptor !== null) {
161160
$normalizedExpr = ArgumentsNormalizer::reorderFuncArguments($parametersAcceptor, $expr) ?? $expr;
162161
$returnType = $parametersAcceptor->getReturnType();
163-
$isAlwaysTerminating = $isAlwaysTerminating || $returnType instanceof NeverType && $returnType->isExplicit();
162+
$isAlwaysTerminating = $isAlwaysTerminating || $returnType->isExplicitNever()->yes();
164163
}
165164

166165
if (
@@ -511,7 +510,7 @@ private function getFunctionThrowPoint(
511510
$throwType = $functionReflection->getThrowType();
512511
if ($throwType === null && $parametersAcceptor !== null) {
513512
$returnType = $parametersAcceptor->getReturnType();
514-
if ($returnType instanceof NeverType && $returnType->isExplicit()) {
513+
if ($returnType->isExplicitNever()->yes()) {
515514
$throwType = new ObjectType(Throwable::class);
516515
}
517516
}

src/Analyser/ExprHandler/InstanceofHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use PHPStan\Type\BooleanType;
1818
use PHPStan\Type\Constant\ConstantBooleanType;
1919
use PHPStan\Type\MixedType;
20-
use PHPStan\Type\NeverType;
2120
use PHPStan\Type\ObjectType;
2221
use PHPStan\Type\StaticType;
2322
use PHPStan\Type\Type;
@@ -75,7 +74,7 @@ public function resolveType(MutatingScope $scope, Expr $expr): Type
7574
) {
7675
return new BooleanType();
7776
}
78-
if ($expressionType instanceof NeverType) {
77+
if ($expressionType->isNever()->yes()) {
7978
return new ConstantBooleanType(false);
8079
}
8180

src/Analyser/ExprHandler/MatchHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
442442
$isExhaustive = $hasDefaultCond || $hasAlwaysTrueCond;
443443
if (!$isExhaustive) {
444444
$remainingType = $matchScope->getType($expr->cond);
445-
if ($remainingType instanceof NeverType) {
445+
if ($remainingType->isNever()->yes()) {
446446
$isExhaustive = true;
447447
}
448448
}
@@ -548,7 +548,7 @@ private function scopeHasNeverVariable(MutatingScope $scope, array $varNames): b
548548
{
549549
foreach ($varNames as $varName) {
550550
$type = $scope->getVariableType($varName);
551-
if ($type instanceof NeverType) {
551+
if ($type->isNever()->yes()) {
552552
return true;
553553
}
554554
}

src/Analyser/ExprHandler/MethodCallHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
use PHPStan\Type\Generic\TemplateTypeVariance;
3535
use PHPStan\Type\Generic\TemplateTypeVarianceMap;
3636
use PHPStan\Type\MixedType;
37-
use PHPStan\Type\NeverType;
3837
use PHPStan\Type\ObjectType;
3938
use PHPStan\Type\Type;
4039
use PHPStan\Type\TypeCombinator;
@@ -140,7 +139,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
140139
if ($parametersAcceptor !== null) {
141140
$normalizedExpr = ArgumentsNormalizer::reorderMethodArguments($parametersAcceptor, $expr) ?? $expr;
142141
$returnType = $parametersAcceptor->getReturnType();
143-
$isAlwaysTerminating = $returnType instanceof NeverType && $returnType->isExplicit();
142+
$isAlwaysTerminating = $returnType->isExplicitNever()->yes();
144143
}
145144

146145
$argsResult = $nodeScopeResolver->processArgs(
@@ -262,7 +261,7 @@ private function getMethodThrowPoint(MethodReflection $methodReflection, Paramet
262261
$throwType = $methodReflection->getThrowType();
263262
if ($throwType === null) {
264263
$returnType = $parametersAcceptor->getReturnType();
265-
if ($returnType instanceof NeverType && $returnType->isExplicit()) {
264+
if ($returnType->isExplicitNever()->yes()) {
266265
$throwType = new ObjectType(Throwable::class);
267266
}
268267
}

src/Analyser/ExprHandler/NewHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
use PHPStan\Type\Generic\GenericStaticType;
4242
use PHPStan\Type\Generic\TemplateType;
4343
use PHPStan\Type\Generic\TemplateTypeMap;
44-
use PHPStan\Type\NeverType;
4544
use PHPStan\Type\NonexistentParentClassType;
4645
use PHPStan\Type\ObjectType;
4746
use PHPStan\Type\StaticType;
@@ -394,7 +393,7 @@ private function exactInstantiation(MutatingScope $scope, New_ $node, Name $clas
394393
}
395394

396395
$methodResult = $scope->getType($methodCall);
397-
if ($methodResult instanceof NeverType && $methodResult->isExplicit()) {
396+
if ($methodResult->isExplicitNever()->yes()) {
398397
return $methodResult;
399398
}
400399

src/Analyser/ExprHandler/StaticCallHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
use PHPStan\Reflection\ParametersAcceptorSelector;
3434
use PHPStan\Type\ErrorType;
3535
use PHPStan\Type\MixedType;
36-
use PHPStan\Type\NeverType;
3736
use PHPStan\Type\ObjectType;
3837
use PHPStan\Type\StaticType;
3938
use PHPStan\Type\Type;
@@ -197,7 +196,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
197196
if ($parametersAcceptor !== null) {
198197
$normalizedExpr = ArgumentsNormalizer::reorderStaticCallArguments($parametersAcceptor, $expr) ?? $expr;
199198
$returnType = $parametersAcceptor->getReturnType();
200-
$isAlwaysTerminating = $returnType instanceof NeverType && $returnType->isExplicit();
199+
$isAlwaysTerminating = $returnType->isExplicitNever()->yes();
201200
}
202201
$argsResult = $nodeScopeResolver->processArgs($stmt, $methodReflection, null, $parametersAcceptor, $normalizedExpr, $scope, $storage, $nodeCallback, $context, $closureBindScope);
203202
$scope = $argsResult->getScope();

src/Analyser/ExprHandler/TernaryHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use PHPStan\Analyser\NodeScopeResolver;
1414
use PHPStan\Analyser\NoopNodeCallback;
1515
use PHPStan\DependencyInjection\AutowiredService;
16-
use PHPStan\Type\NeverType;
1716
use PHPStan\Type\Type;
1817
use PHPStan\Type\TypeCombinator;
1918
use function array_merge;
@@ -104,12 +103,12 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
104103
} elseif ($condType->isFalse()->yes()) {
105104
$finalScope = $ifFalseScope;
106105
} else {
107-
if ($ifTrueType instanceof NeverType && $ifTrueType->isExplicit()) {
106+
if ($ifTrueType !== null && $ifTrueType->isExplicitNever()->yes()) {
108107
$finalScope = $ifFalseScope;
109108
} else {
110109
$ifFalseType = $ifFalseScope->getType($expr->else);
111110

112-
if ($ifFalseType instanceof NeverType && $ifFalseType->isExplicit()) {
111+
if ($ifFalseType->isExplicitNever()->yes()) {
113112
$finalScope = $ifTrueScope;
114113
} else {
115114
$finalScope = $ifTrueScope->mergeWith($ifFalseScope);

0 commit comments

Comments
 (0)