Skip to content

Commit b80ae7a

Browse files
committed
Updated PHPStan
1 parent e5140e0 commit b80ae7a

8 files changed

+29
-15
lines changed

Diff for: src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Rules\BooleansInConditions;
44

5+
use PHPStan\Type\VerbosityLevel;
6+
57
class BooleanInBooleanAndRule implements \PHPStan\Rules\Rule
68
{
79

@@ -23,15 +25,15 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
2325
if (!BooleanRuleHelper::passesAsBoolean($leftType)) {
2426
$messages[] = sprintf(
2527
'Only booleans are allowed in &&, %s given on the left side.',
26-
$leftType->describe()
28+
$leftType->describe(VerbosityLevel::typeOnly())
2729
);
2830
}
2931

3032
$rightType = $scope->getType($node->right);
3133
if (!BooleanRuleHelper::passesAsBoolean($rightType)) {
3234
$messages[] = sprintf(
3335
'Only booleans are allowed in &&, %s given on the right side.',
34-
$rightType->describe()
36+
$rightType->describe(VerbosityLevel::typeOnly())
3537
);
3638
}
3739

Diff for: src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Rules\BooleansInConditions;
44

5+
use PHPStan\Type\VerbosityLevel;
6+
57
class BooleanInBooleanNotRule implements \PHPStan\Rules\Rule
68
{
79

@@ -25,7 +27,7 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
2527
return [
2628
sprintf(
2729
'Only booleans are allowed in a negated boolean, %s given.',
28-
$expressionType->describe()
30+
$expressionType->describe(VerbosityLevel::typeOnly())
2931
),
3032
];
3133
}

Diff for: src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Rules\BooleansInConditions;
44

5+
use PHPStan\Type\VerbosityLevel;
6+
57
class BooleanInBooleanOrRule implements \PHPStan\Rules\Rule
68
{
79

@@ -22,15 +24,15 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
2224
if (!BooleanRuleHelper::passesAsBoolean($leftType)) {
2325
$messages[] = sprintf(
2426
'Only booleans are allowed in ||, %s given on the left side.',
25-
$leftType->describe()
27+
$leftType->describe(VerbosityLevel::typeOnly())
2628
);
2729
}
2830

2931
$rightType = $scope->getType($node->right);
3032
if (!BooleanRuleHelper::passesAsBoolean($rightType)) {
3133
$messages[] = sprintf(
3234
'Only booleans are allowed in ||, %s given on the right side.',
33-
$rightType->describe()
35+
$rightType->describe(VerbosityLevel::typeOnly())
3436
);
3537
}
3638

Diff for: src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Rules\BooleansInConditions;
44

5+
use PHPStan\Type\VerbosityLevel;
6+
57
class BooleanInElseIfConditionRule implements \PHPStan\Rules\Rule
68
{
79

@@ -25,7 +27,7 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
2527
return [
2628
sprintf(
2729
'Only booleans are allowed in an elseif condition, %s given.',
28-
$conditionExpressionType->describe()
30+
$conditionExpressionType->describe(VerbosityLevel::typeOnly())
2931
),
3032
];
3133
}

Diff for: src/Rules/BooleansInConditions/BooleanInIfConditionRule.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Rules\BooleansInConditions;
44

5+
use PHPStan\Type\VerbosityLevel;
6+
57
class BooleanInIfConditionRule implements \PHPStan\Rules\Rule
68
{
79

@@ -25,7 +27,7 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
2527
return [
2628
sprintf(
2729
'Only booleans are allowed in an if condition, %s given.',
28-
$conditionExpressionType->describe()
30+
$conditionExpressionType->describe(VerbosityLevel::typeOnly())
2931
),
3032
];
3133
}

Diff for: src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Rules\BooleansInConditions;
44

5+
use PHPStan\Type\VerbosityLevel;
6+
57
class BooleanInTernaryOperatorRule implements \PHPStan\Rules\Rule
68
{
79

@@ -29,7 +31,7 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
2931
return [
3032
sprintf(
3133
'Only booleans are allowed in a ternary operator condition, %s given.',
32-
$conditionExpressionType->describe()
34+
$conditionExpressionType->describe(VerbosityLevel::typeOnly())
3335
),
3436
];
3537
}

Diff for: src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Rules\SwitchConditions;
44

5+
use PHPStan\Type\VerbosityLevel;
6+
57
class MatchingTypeInSwitchCaseConditionRule implements \PHPStan\Rules\Rule
68
{
79

@@ -39,9 +41,9 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
3941

4042
$messages[] = sprintf(
4143
'Switch condition type (%s) does not match case condition %s (%s).',
42-
$conditionType->describe(),
44+
$conditionType->describe(VerbosityLevel::value()),
4345
$this->printer->prettyPrintExpr($case->cond),
44-
$caseType->describe()
46+
$caseType->describe(VerbosityLevel::typeOnly())
4547
);
4648
}
4749

Diff for: tests/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRuleTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ public function testRule(): void
1616
{
1717
$this->analyse([__DIR__ . '/data/matching-type.php'], [
1818
[
19-
'Switch condition type (int(1)) does not match case condition \'test\' (string).',
19+
'Switch condition type (1) does not match case condition \'test\' (string).',
2020
8,
2121
],
2222
[
23-
'Switch condition type (int(1)) does not match case condition 1 > 2 (bool).',
23+
'Switch condition type (1) does not match case condition 1 > 2 (bool).',
2424
8,
2525
],
2626
[
27-
'Switch condition type (string) does not match case condition 1 (int(1)).',
27+
'Switch condition type (\'1\') does not match case condition 1 (int).',
2828
19,
2929
],
3030
[
31-
'Switch condition type (string) does not match case condition \'test\' (string).',
31+
'Switch condition type (\'1\') does not match case condition \'test\' (string).',
3232
19,
3333
],
3434
[
35-
'Switch condition type (string) does not match case condition 1 > 2 (bool).',
35+
'Switch condition type (\'1\') does not match case condition 1 > 2 (bool).',
3636
19,
3737
],
3838
]);

0 commit comments

Comments
 (0)