Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,18 @@ parameters:
count: 1
path: src/Type/IterableType.php

-
rawMessage: 'Doing instanceof PHPStan\Type\NeverType is error-prone and deprecated. Use Type::isNever() or Type::isExplicitNever() instead.'
identifier: phpstanApi.instanceofType
count: 2
path: src/Type/NeverType.php

-
rawMessage: 'Doing instanceof PHPStan\Type\NeverType is error-prone and deprecated. Use Type::isNever() or Type::isExplicitNever() instead.'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/NonAcceptingNeverType.php

-
rawMessage: 'Doing instanceof PHPStan\Type\ConstantScalarType is error-prone and deprecated. Use Type::isConstantScalarValue() or Type::getConstantScalarTypes() or Type::getConstantScalarValues() instead.'
identifier: phpstanApi.instanceofType
Expand Down Expand Up @@ -1767,6 +1779,12 @@ parameters:
count: 1
path: src/Type/TypehintHelper.php

-
rawMessage: 'Call to an undefined method PHPStan\Type\Type::isSubTypeOf().'
identifier: method.notFound
count: 1
path: src/Type/UnionType.php

-
rawMessage: 'Doing instanceof PHPStan\Type\CallableType is error-prone and deprecated. Use Type::isCallable() and Type::getCallableParametersAcceptors() instead.'
identifier: phpstanApi.instanceofType
Expand Down
3 changes: 1 addition & 2 deletions src/Analyser/ExprHandler/BooleanAndHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use PHPStan\Node\BooleanAndNode;
use PHPStan\Type\BooleanType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\NeverType;
use PHPStan\Type\Type;
use function array_merge;

Expand Down Expand Up @@ -91,7 +90,7 @@
$leftTruthyScope = $leftResult->getTruthyScope();
$rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftTruthyScope, $storage, $nodeCallback, $context);
$rightExprType = $rightResult->getScope()->getType($expr->right);
if ($rightExprType instanceof NeverType && $rightExprType->isExplicit()) {
if ($rightExprType->isExplicitNever()->yes()) {

Check warning on line 93 in src/Analyser/ExprHandler/BooleanAndHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $leftTruthyScope = $leftResult->getTruthyScope(); $rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftTruthyScope, $storage, $nodeCallback, $context); $rightExprType = $rightResult->getScope()->getType($expr->right); - if ($rightExprType->isExplicitNever()->yes()) { + if (!$rightExprType->isExplicitNever()->no()) { $leftMergedWithRightScope = $leftResult->getFalseyScope(); } else { $leftMergedWithRightScope = $leftResult->getScope()->mergeWith($rightResult->getScope());

Check warning on line 93 in src/Analyser/ExprHandler/BooleanAndHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $leftTruthyScope = $leftResult->getTruthyScope(); $rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftTruthyScope, $storage, $nodeCallback, $context); $rightExprType = $rightResult->getScope()->getType($expr->right); - if ($rightExprType->isExplicitNever()->yes()) { + if (!$rightExprType->isExplicitNever()->no()) { $leftMergedWithRightScope = $leftResult->getFalseyScope(); } else { $leftMergedWithRightScope = $leftResult->getScope()->mergeWith($rightResult->getScope());
$leftMergedWithRightScope = $leftResult->getFalseyScope();
} else {
$leftMergedWithRightScope = $leftResult->getScope()->mergeWith($rightResult->getScope());
Expand Down
3 changes: 1 addition & 2 deletions src/Analyser/ExprHandler/BooleanOrHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use PHPStan\Node\BooleanOrNode;
use PHPStan\Type\BooleanType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\NeverType;
use PHPStan\Type\Type;
use function array_merge;

Expand Down Expand Up @@ -75,7 +74,7 @@
$leftFalseyScope = $leftResult->getFalseyScope();
$rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftFalseyScope, $storage, $nodeCallback, $context);
$rightExprType = $rightResult->getScope()->getType($expr->right);
if ($rightExprType instanceof NeverType && $rightExprType->isExplicit()) {
if ($rightExprType->isExplicitNever()->yes()) {

Check warning on line 77 in src/Analyser/ExprHandler/BooleanOrHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $leftFalseyScope = $leftResult->getFalseyScope(); $rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftFalseyScope, $storage, $nodeCallback, $context); $rightExprType = $rightResult->getScope()->getType($expr->right); - if ($rightExprType->isExplicitNever()->yes()) { + if (!$rightExprType->isExplicitNever()->no()) { $leftMergedWithRightScope = $leftResult->getTruthyScope(); } else { $leftMergedWithRightScope = $leftResult->getScope()->mergeWith($rightResult->getScope());

Check warning on line 77 in src/Analyser/ExprHandler/BooleanOrHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $leftFalseyScope = $leftResult->getFalseyScope(); $rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftFalseyScope, $storage, $nodeCallback, $context); $rightExprType = $rightResult->getScope()->getType($expr->right); - if ($rightExprType->isExplicitNever()->yes()) { + if (!$rightExprType->isExplicitNever()->no()) { $leftMergedWithRightScope = $leftResult->getTruthyScope(); } else { $leftMergedWithRightScope = $leftResult->getScope()->mergeWith($rightResult->getScope());
$leftMergedWithRightScope = $leftResult->getTruthyScope();
} else {
$leftMergedWithRightScope = $leftResult->getScope()->mergeWith($rightResult->getScope());
Expand Down
3 changes: 1 addition & 2 deletions src/Analyser/ExprHandler/CoalesceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use PHPStan\Analyser\MutatingScope;
use PHPStan\Analyser\NodeScopeResolver;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Type\NeverType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use function array_merge;
Expand Down Expand Up @@ -76,7 +75,7 @@
$rightScope = $scope->filterByFalseyValue($expr);
$rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $rightScope, $storage, $nodeCallback, $context->enterDeep());
$rightExprType = $scope->getType($expr->right);
if ($rightExprType instanceof NeverType && $rightExprType->isExplicit()) {
if ($rightExprType->isExplicitNever()->yes()) {

Check warning on line 78 in src/Analyser/ExprHandler/CoalesceHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $rightScope = $scope->filterByFalseyValue($expr); $rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $rightScope, $storage, $nodeCallback, $context->enterDeep()); $rightExprType = $scope->getType($expr->right); - if ($rightExprType->isExplicitNever()->yes()) { + if (!$rightExprType->isExplicitNever()->no()) { $scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left])); } else { $scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left]))->mergeWith($rightResult->getScope());

Check warning on line 78 in src/Analyser/ExprHandler/CoalesceHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $rightScope = $scope->filterByFalseyValue($expr); $rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $rightScope, $storage, $nodeCallback, $context->enterDeep()); $rightExprType = $scope->getType($expr->right); - if ($rightExprType->isExplicitNever()->yes()) { + if (!$rightExprType->isExplicitNever()->no()) { $scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left])); } else { $scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left]))->mergeWith($rightResult->getScope());
$scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left]));
} else {
$scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left]))->mergeWith($rightResult->getScope());
Expand Down
5 changes: 2 additions & 3 deletions src/Analyser/ExprHandler/FuncCallHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
use PHPStan\Type\IntegerType;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StringType;
Expand Down Expand Up @@ -160,7 +159,7 @@
if ($parametersAcceptor !== null) {
$normalizedExpr = ArgumentsNormalizer::reorderFuncArguments($parametersAcceptor, $expr) ?? $expr;
$returnType = $parametersAcceptor->getReturnType();
$isAlwaysTerminating = $isAlwaysTerminating || $returnType instanceof NeverType && $returnType->isExplicit();
$isAlwaysTerminating = $isAlwaysTerminating || $returnType->isExplicitNever()->yes();

Check warning on line 162 in src/Analyser/ExprHandler/FuncCallHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ if ($parametersAcceptor !== null) { $normalizedExpr = ArgumentsNormalizer::reorderFuncArguments($parametersAcceptor, $expr) ?? $expr; $returnType = $parametersAcceptor->getReturnType(); - $isAlwaysTerminating = $isAlwaysTerminating || $returnType->isExplicitNever()->yes(); + $isAlwaysTerminating = $isAlwaysTerminating || !$returnType->isExplicitNever()->no(); } if (

Check warning on line 162 in src/Analyser/ExprHandler/FuncCallHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ if ($parametersAcceptor !== null) { $normalizedExpr = ArgumentsNormalizer::reorderFuncArguments($parametersAcceptor, $expr) ?? $expr; $returnType = $parametersAcceptor->getReturnType(); - $isAlwaysTerminating = $isAlwaysTerminating || $returnType->isExplicitNever()->yes(); + $isAlwaysTerminating = $isAlwaysTerminating || !$returnType->isExplicitNever()->no(); } if (
}

if (
Expand Down Expand Up @@ -511,7 +510,7 @@
$throwType = $functionReflection->getThrowType();
if ($throwType === null && $parametersAcceptor !== null) {
$returnType = $parametersAcceptor->getReturnType();
if ($returnType instanceof NeverType && $returnType->isExplicit()) {
if ($returnType->isExplicitNever()->yes()) {

Check warning on line 513 in src/Analyser/ExprHandler/FuncCallHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $throwType = $functionReflection->getThrowType(); if ($throwType === null && $parametersAcceptor !== null) { $returnType = $parametersAcceptor->getReturnType(); - if ($returnType->isExplicitNever()->yes()) { + if (!$returnType->isExplicitNever()->no()) { $throwType = new ObjectType(Throwable::class); } }

Check warning on line 513 in src/Analyser/ExprHandler/FuncCallHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $throwType = $functionReflection->getThrowType(); if ($throwType === null && $parametersAcceptor !== null) { $returnType = $parametersAcceptor->getReturnType(); - if ($returnType->isExplicitNever()->yes()) { + if (!$returnType->isExplicitNever()->no()) { $throwType = new ObjectType(Throwable::class); } }
$throwType = new ObjectType(Throwable::class);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Analyser/ExprHandler/InstanceofHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use PHPStan\Type\BooleanType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StaticType;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -75,7 +74,7 @@
) {
return new BooleanType();
}
if ($expressionType instanceof NeverType) {
if ($expressionType->isNever()->yes()) {

Check warning on line 77 in src/Analyser/ExprHandler/InstanceofHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ ) { return new BooleanType(); } - if ($expressionType->isNever()->yes()) { + if (!$expressionType->isNever()->no()) { return new ConstantBooleanType(false); }

Check warning on line 77 in src/Analyser/ExprHandler/InstanceofHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ ) { return new BooleanType(); } - if ($expressionType->isNever()->yes()) { + if (!$expressionType->isNever()->no()) { return new ConstantBooleanType(false); }
return new ConstantBooleanType(false);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Analyser/ExprHandler/MatchHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
$isExhaustive = $hasDefaultCond || $hasAlwaysTrueCond;
if (!$isExhaustive) {
$remainingType = $matchScope->getType($expr->cond);
if ($remainingType instanceof NeverType) {
if ($remainingType->isNever()->yes()) {

Check warning on line 445 in src/Analyser/ExprHandler/MatchHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $isExhaustive = $hasDefaultCond || $hasAlwaysTrueCond; if (!$isExhaustive) { $remainingType = $matchScope->getType($expr->cond); - if ($remainingType->isNever()->yes()) { + if (!$remainingType->isNever()->no()) { $isExhaustive = true; } }

Check warning on line 445 in src/Analyser/ExprHandler/MatchHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $isExhaustive = $hasDefaultCond || $hasAlwaysTrueCond; if (!$isExhaustive) { $remainingType = $matchScope->getType($expr->cond); - if ($remainingType->isNever()->yes()) { + if (!$remainingType->isNever()->no()) { $isExhaustive = true; } }
$isExhaustive = true;
}
}
Expand Down Expand Up @@ -548,7 +548,7 @@
{
foreach ($varNames as $varName) {
$type = $scope->getVariableType($varName);
if ($type instanceof NeverType) {
if ($type->isNever()->yes()) {

Check warning on line 551 in src/Analyser/ExprHandler/MatchHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ { foreach ($varNames as $varName) { $type = $scope->getVariableType($varName); - if ($type->isNever()->yes()) { + if (!$type->isNever()->no()) { return true; } }

Check warning on line 551 in src/Analyser/ExprHandler/MatchHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ { foreach ($varNames as $varName) { $type = $scope->getVariableType($varName); - if ($type->isNever()->yes()) { + if (!$type->isNever()->no()) { return true; } }
return true;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/Analyser/ExprHandler/MethodCallHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
use PHPStan\Type\Generic\TemplateTypeVariance;
use PHPStan\Type\Generic\TemplateTypeVarianceMap;
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
Expand Down Expand Up @@ -140,7 +139,7 @@
if ($parametersAcceptor !== null) {
$normalizedExpr = ArgumentsNormalizer::reorderMethodArguments($parametersAcceptor, $expr) ?? $expr;
$returnType = $parametersAcceptor->getReturnType();
$isAlwaysTerminating = $returnType instanceof NeverType && $returnType->isExplicit();
$isAlwaysTerminating = $returnType->isExplicitNever()->yes();

Check warning on line 142 in src/Analyser/ExprHandler/MethodCallHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ if ($parametersAcceptor !== null) { $normalizedExpr = ArgumentsNormalizer::reorderMethodArguments($parametersAcceptor, $expr) ?? $expr; $returnType = $parametersAcceptor->getReturnType(); - $isAlwaysTerminating = $returnType->isExplicitNever()->yes(); + $isAlwaysTerminating = !$returnType->isExplicitNever()->no(); } $argsResult = $nodeScopeResolver->processArgs(

Check warning on line 142 in src/Analyser/ExprHandler/MethodCallHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ if ($parametersAcceptor !== null) { $normalizedExpr = ArgumentsNormalizer::reorderMethodArguments($parametersAcceptor, $expr) ?? $expr; $returnType = $parametersAcceptor->getReturnType(); - $isAlwaysTerminating = $returnType->isExplicitNever()->yes(); + $isAlwaysTerminating = !$returnType->isExplicitNever()->no(); } $argsResult = $nodeScopeResolver->processArgs(
}

$argsResult = $nodeScopeResolver->processArgs(
Expand Down Expand Up @@ -262,7 +261,7 @@
$throwType = $methodReflection->getThrowType();
if ($throwType === null) {
$returnType = $parametersAcceptor->getReturnType();
if ($returnType instanceof NeverType && $returnType->isExplicit()) {
if ($returnType->isExplicitNever()->yes()) {

Check warning on line 264 in src/Analyser/ExprHandler/MethodCallHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $throwType = $methodReflection->getThrowType(); if ($throwType === null) { $returnType = $parametersAcceptor->getReturnType(); - if ($returnType->isExplicitNever()->yes()) { + if (!$returnType->isExplicitNever()->no()) { $throwType = new ObjectType(Throwable::class); } }

Check warning on line 264 in src/Analyser/ExprHandler/MethodCallHandler.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $throwType = $methodReflection->getThrowType(); if ($throwType === null) { $returnType = $parametersAcceptor->getReturnType(); - if ($returnType->isExplicitNever()->yes()) { + if (!$returnType->isExplicitNever()->no()) { $throwType = new ObjectType(Throwable::class); } }
$throwType = new ObjectType(Throwable::class);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Analyser/ExprHandler/NewHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
use PHPStan\Type\Generic\GenericStaticType;
use PHPStan\Type\Generic\TemplateType;
use PHPStan\Type\Generic\TemplateTypeMap;
use PHPStan\Type\NeverType;
use PHPStan\Type\NonexistentParentClassType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StaticType;
Expand Down Expand Up @@ -394,7 +393,7 @@ private function exactInstantiation(MutatingScope $scope, New_ $node, Name $clas
}

$methodResult = $scope->getType($methodCall);
if ($methodResult instanceof NeverType && $methodResult->isExplicit()) {
if ($methodResult->isExplicitNever()->yes()) {
return $methodResult;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Analyser/ExprHandler/StaticCallHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Type\ErrorType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StaticType;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -197,7 +196,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
if ($parametersAcceptor !== null) {
$normalizedExpr = ArgumentsNormalizer::reorderStaticCallArguments($parametersAcceptor, $expr) ?? $expr;
$returnType = $parametersAcceptor->getReturnType();
$isAlwaysTerminating = $returnType instanceof NeverType && $returnType->isExplicit();
$isAlwaysTerminating = $returnType->isExplicitNever()->yes();
}
$argsResult = $nodeScopeResolver->processArgs($stmt, $methodReflection, null, $parametersAcceptor, $normalizedExpr, $scope, $storage, $nodeCallback, $context, $closureBindScope);
$scope = $argsResult->getScope();
Expand Down
5 changes: 2 additions & 3 deletions src/Analyser/ExprHandler/TernaryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use PHPStan\Analyser\NodeScopeResolver;
use PHPStan\Analyser\NoopNodeCallback;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Type\NeverType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use function array_merge;
Expand Down Expand Up @@ -104,12 +103,12 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
} elseif ($condType->isFalse()->yes()) {
$finalScope = $ifFalseScope;
} else {
if ($ifTrueType instanceof NeverType && $ifTrueType->isExplicit()) {
if ($ifTrueType !== null && $ifTrueType->isExplicitNever()->yes()) {
$finalScope = $ifFalseScope;
} else {
$ifFalseType = $ifFalseScope->getType($expr->else);

if ($ifFalseType instanceof NeverType && $ifFalseType->isExplicit()) {
if ($ifFalseType->isExplicitNever()->yes()) {
$finalScope = $ifTrueScope;
} else {
$finalScope = $ifTrueScope->mergeWith($ifFalseScope);
Expand Down
9 changes: 4 additions & 5 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
use PHPStan\Type\IntegerType;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StaticType;
Expand Down Expand Up @@ -3023,12 +3022,12 @@ public function addTypeToExpression(Expr $expr, Type $type): self

public function removeTypeFromExpression(Expr $expr, Type $typeToRemove): self
{
if ($typeToRemove instanceof NeverType) {
if ($typeToRemove->isNever()->yes()) {
return $this;
}

$exprType = $this->getType($expr);
if ($exprType instanceof NeverType) {
if ($exprType->isNever()->yes()) {
return $this;
}

Expand Down Expand Up @@ -4532,7 +4531,7 @@ public function getIterableKeyType(Type $iteratee): Type
{
if ($iteratee instanceof UnionType) {
$filtered = $iteratee->filterTypes(static fn (Type $innerType) => $innerType->isIterable()->yes());
if (!$filtered instanceof NeverType) {
if ($filtered->isNever()->no()) {
$iteratee = $filtered;
}
}
Expand All @@ -4544,7 +4543,7 @@ public function getIterableValueType(Type $iteratee): Type
{
if ($iteratee instanceof UnionType) {
$filtered = $iteratee->filterTypes(static fn (Type $innerType) => $innerType->isIterable()->yes());
if (!$filtered instanceof NeverType) {
if ($filtered->isNever()->no()) {
$iteratee = $filtered;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@ public function processStmtNode(
}
}

$exhaustive = $scopeForBranches->getType($stmt->cond) instanceof NeverType;
$exhaustive = $scopeForBranches->getType($stmt->cond)->isNever()->yes();

if (!$hasDefaultCase && !$exhaustive) {
$alwaysTerminating = false;
Expand Down Expand Up @@ -1949,7 +1949,7 @@ public function processStmtNode(
foreach ($throwPoints as $throwPoint) {
$newThrowPoint = $throwPoint->subtractCatchType($originalCatchType);

if ($newThrowPoint->getType() instanceof NeverType) {
if (!$newThrowPoint->getType()->isNever()->no()) {
continue;
}

Expand Down Expand Up @@ -2460,7 +2460,7 @@ private function findEarlyTerminatingExpr(Expr $expr, Scope $scope): ?Expr
}

$exprType = $scope->getType($expr);
if ($exprType instanceof NeverType && $exprType->isExplicit()) {
if ($exprType->isExplicitNever()->yes()) {
return $expr;
}

Expand Down Expand Up @@ -2723,7 +2723,7 @@ public function processClosureNode(
}

$returnType = $closureType->getReturnType();
$isAlwaysTerminating = ($returnType instanceof NeverType && $returnType->isExplicit());
$isAlwaysTerminating = ($returnType->isExplicitNever()->yes());

$this->callNodeCallback($nodeCallback, new InClosureNode($closureType, $expr), $closureScope, $storage);

Expand Down Expand Up @@ -3416,7 +3416,7 @@ public function processArgs(
$throwPoints = array_merge($throwPoints, $callableThrowPoints);
$impurePoints = array_merge($impurePoints, array_map(static fn (SimpleImpurePoint $impurePoint) => new ImpurePoint($scope, $arg->value, $impurePoint->getIdentifier(), $impurePoint->getDescription(), $impurePoint->isCertain()), $acceptors[0]->getImpurePoints()));
$returnType = $acceptors[0]->getReturnType();
$isAlwaysTerminating = $isAlwaysTerminating || ($returnType instanceof NeverType && $returnType->isExplicit());
$isAlwaysTerminating = $isAlwaysTerminating || ($returnType->isExplicitNever()->yes());
}
}
}
Expand Down Expand Up @@ -4088,7 +4088,7 @@ public function processCalledMethod(MethodReflection $methodReflection): ?Mutati
$endNode = $executionEnd->getNode();
if ($endNode instanceof Node\Stmt\Expression) {
$exprType = $statementResult->getScope()->getType($endNode->expr);
if ($exprType instanceof NeverType && $exprType->isExplicit()) {
if ($exprType->isExplicitNever()->yes()) {
continue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/TypeSpecifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ private function getConditionalSpecifiedTypes(
(
$argumentExpr instanceof Node\Scalar
|| ($argumentExpr instanceof ConstFetch && in_array(strtolower($argumentExpr->name->toString()), ['true', 'false', 'null'], true))
) && ($ifType instanceof NeverType || $elseType instanceof NeverType)
) && ($ifType->isNever()->yes() || $elseType->isNever()->yes())
) {
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Node/ClassPropertiesNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use PHPStan\Reflection\MethodReflection;
use PHPStan\Rules\Properties\ReadWritePropertiesExtensionProvider;
use PHPStan\TrinaryLogic;
use PHPStan\Type\NeverType;
use PHPStan\Type\TypeUtils;
use function array_diff_key;
use function array_key_exists;
Expand Down Expand Up @@ -276,7 +275,7 @@ private function collectUninitializedProperties(array $constructors, array $unin
if ($statementResult->isAlwaysTerminating()) {
if ($endNode instanceof Node\Stmt\Expression) {
$exprType = $statementResult->getScope()->getType($endNode->expr);
if ($exprType instanceof NeverType && $exprType->isExplicit()) {
if ($exprType->isExplicitNever()->yes()) {
continue;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Callables/FunctionCallableVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use PHPStan\TrinaryLogic;
use PHPStan\Type\Generic\TemplateTypeMap;
use PHPStan\Type\Generic\TemplateTypeVarianceMap;
use PHPStan\Type\NeverType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Throwable;
Expand Down Expand Up @@ -98,7 +97,7 @@ public function getThrowPoints(): array
$returnType = $this->variant->getReturnType();
$throwType = $this->function->getThrowType();
if ($throwType === null) {
if ($returnType instanceof NeverType && $returnType->isExplicit()) {
if ($returnType->isExplicitNever()->yes()) {
$throwType = new ObjectType(Throwable::class);
}
}
Expand Down
Loading
Loading