Skip to content

Commit 7ba8abc

Browse files
committed
[BCB] acceptsWithReason renamed to accepts
1 parent a0e688c commit 7ba8abc

File tree

83 files changed

+184
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+184
-515
lines changed

UPGRADING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,6 @@ Instead of `PHPStanTestCase::createBroker()`, call `PHPStanTestCase::createRefle
290290
* Remove `tempResultCachePath` config parameter, use `resultCachePath` instead
291291
* `LevelsTestCase::dataTopics()` data provider made static
292292
* `PHPStan\Node\Printer\Printer` no longer autowired as `PhpParser\PrettyPrinter\Standard`, use `PHPStan\Node\Printer\Printer` in the typehint
293+
* Remove `Type::acceptsWithReason()`, `Type:accepts()` return type changed from `TrinaryLogic` to [`AcceptsResult`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.AcceptsResult.html)
294+
* Remove `CompoundType::isAcceptedWithReasonBy()`, `CompoundType::isAcceptedBy()` return type changed from `TrinaryLogic` to [`AcceptsResult`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.AcceptsResult.html)
295+
* `RuleLevelHelper::accepts()` return type changed from `bool` to [`RuleLevelHelperAcceptsResult`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.AcceptsResult.html)

src/Rules/Constants/ValueAssignedToClassConstantRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private function processSingleConstant(ClassReflection $classReflection, string
6363
return [];
6464
}
6565

66-
$accepts = $nativeType->acceptsWithReason($valueExprType, true);
66+
$accepts = $nativeType->accepts($valueExprType, true);
6767
if ($accepts->yes()) {
6868
return [];
6969
}
@@ -107,7 +107,7 @@ private function processSingleConstant(ClassReflection $classReflection, string
107107
}
108108

109109
$type = $constantReflection->getValueType();
110-
$accepts = $type->acceptsWithReason($valueExprType, true);
110+
$accepts = $type->accepts($valueExprType, true);
111111
if ($accepts->yes()) {
112112
return [];
113113
}

src/Rules/FunctionCallParametersCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public function check(
312312
$parameterType = TypeUtils::resolveLateResolvableTypes($parameter->getType());
313313

314314
if (!$parameter->passedByReference()->createsNewVariable() || !$isBuiltin) {
315-
$accepts = $this->ruleLevelHelper->acceptsWithReason($parameterType, $argumentValueType, $scope->isDeclareStrictTypes());
315+
$accepts = $this->ruleLevelHelper->accepts($parameterType, $argumentValueType, $scope->isDeclareStrictTypes());
316316

317317
if (!$accepts->result) {
318318
$verbosityLevel = VerbosityLevel::getRecommendedLevelByType($parameterType, $argumentValueType);

src/Rules/FunctionReturnTypeCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function checkReturnType(
9090
];
9191
}
9292

93-
$accepts = $this->ruleLevelHelper->acceptsWithReason($returnType, $returnValueType, $scope->isDeclareStrictTypes());
93+
$accepts = $this->ruleLevelHelper->accepts($returnType, $returnValueType, $scope->isDeclareStrictTypes());
9494
if (!$accepts->result) {
9595
return [
9696
RuleErrorBuilder::message(sprintf(

src/Rules/Functions/IncompatibleArrowFunctionDefaultParameterTypeRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array
4444
$parameterType = $parameters[$paramI]->getType();
4545
$parameterType = TemplateTypeHelper::resolveToBounds($parameterType);
4646

47-
$accepts = $parameterType->acceptsWithReason($defaultValueType, true);
47+
$accepts = $parameterType->accepts($defaultValueType, true);
4848
if ($accepts->yes()) {
4949
continue;
5050
}

src/Rules/Functions/IncompatibleClosureDefaultParameterTypeRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array
4444
$parameterType = $parameters[$paramI]->getType();
4545
$parameterType = TemplateTypeHelper::resolveToBounds($parameterType);
4646

47-
$accepts = $parameterType->acceptsWithReason($defaultValueType, true);
47+
$accepts = $parameterType->accepts($defaultValueType, true);
4848
if ($accepts->yes()) {
4949
continue;
5050
}

src/Rules/Functions/IncompatibleDefaultParameterTypeRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function processNode(Node $node, Scope $scope): array
4343
$parameterType = $function->getParameters()[$paramI]->getType();
4444
$parameterType = TemplateTypeHelper::resolveToBounds($parameterType);
4545

46-
$accepts = $parameterType->acceptsWithReason($defaultValueType, true);
46+
$accepts = $parameterType->accepts($defaultValueType, true);
4747
if ($accepts->yes()) {
4848
continue;
4949
}

src/Rules/Generators/YieldFromTypeRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function processNode(Node $node, Scope $scope): array
7878
}
7979

8080
$messages = [];
81-
$acceptsKey = $this->ruleLevelHelper->acceptsWithReason($returnType->getIterableKeyType(), $exprType->getIterableKeyType(), $scope->isDeclareStrictTypes());
81+
$acceptsKey = $this->ruleLevelHelper->accepts($returnType->getIterableKeyType(), $exprType->getIterableKeyType(), $scope->isDeclareStrictTypes());
8282
if (!$acceptsKey->result) {
8383
$verbosityLevel = VerbosityLevel::getRecommendedLevelByType($returnType->getIterableKeyType(), $exprType->getIterableKeyType());
8484
$messages[] = RuleErrorBuilder::message(sprintf(
@@ -92,7 +92,7 @@ public function processNode(Node $node, Scope $scope): array
9292
->build();
9393
}
9494

95-
$acceptsValue = $this->ruleLevelHelper->acceptsWithReason($returnType->getIterableValueType(), $exprType->getIterableValueType(), $scope->isDeclareStrictTypes());
95+
$acceptsValue = $this->ruleLevelHelper->accepts($returnType->getIterableValueType(), $exprType->getIterableValueType(), $scope->isDeclareStrictTypes());
9696
if (!$acceptsValue->result) {
9797
$verbosityLevel = VerbosityLevel::getRecommendedLevelByType($returnType->getIterableValueType(), $exprType->getIterableValueType());
9898
$messages[] = RuleErrorBuilder::message(sprintf(

src/Rules/Generators/YieldTypeRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array
5353
}
5454

5555
$messages = [];
56-
$acceptsKey = $this->ruleLevelHelper->acceptsWithReason($returnType->getIterableKeyType(), $keyType, $scope->isDeclareStrictTypes());
56+
$acceptsKey = $this->ruleLevelHelper->accepts($returnType->getIterableKeyType(), $keyType, $scope->isDeclareStrictTypes());
5757
if (!$acceptsKey->result) {
5858
$verbosityLevel = VerbosityLevel::getRecommendedLevelByType($returnType->getIterableKeyType(), $keyType);
5959
$messages[] = RuleErrorBuilder::message(sprintf(
@@ -72,7 +72,7 @@ public function processNode(Node $node, Scope $scope): array
7272
$valueType = $scope->getType($node->value);
7373
}
7474

75-
$acceptsValue = $this->ruleLevelHelper->acceptsWithReason($returnType->getIterableValueType(), $valueType, $scope->isDeclareStrictTypes());
75+
$acceptsValue = $this->ruleLevelHelper->accepts($returnType->getIterableValueType(), $valueType, $scope->isDeclareStrictTypes());
7676
if (!$acceptsValue->result) {
7777
$verbosityLevel = VerbosityLevel::getRecommendedLevelByType($returnType->getIterableValueType(), $valueType);
7878
$messages[] = RuleErrorBuilder::message(sprintf(

src/Rules/Methods/IncompatibleDefaultParameterTypeRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array
4444
$parameterType = $parameter->getType();
4545
$parameterType = TemplateTypeHelper::resolveToBounds($parameterType);
4646

47-
$accepts = $parameterType->acceptsWithReason($defaultValueType, true);
47+
$accepts = $parameterType->accepts($defaultValueType, true);
4848
if ($accepts->yes()) {
4949
continue;
5050
}

0 commit comments

Comments
 (0)