Skip to content

Commit f8092f9

Browse files
committed
Update build-cs
1 parent f647999 commit f8092f9

File tree

47 files changed

+112
-155
lines changed

Some content is hidden

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

47 files changed

+112
-155
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
with:
5757
repository: "phpstan/build-cs"
5858
path: "build-cs"
59-
ref: "1.x"
59+
ref: "2.x"
6060

6161
- name: "Install PHP"
6262
uses: "shivammathur/setup-php@v2"

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ lint:
1313
.PHONY: cs-install
1414
cs-install:
1515
git clone https://github.com/phpstan/build-cs.git || true
16-
git -C build-cs fetch origin && git -C build-cs reset --hard origin/1.x
16+
git -C build-cs fetch origin && git -C build-cs reset --hard origin/2.x
1717
composer install --working-dir build-cs
1818

1919
.PHONY: cs

src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
class BooleanInBooleanAndRule implements Rule
1717
{
1818

19-
/** @var BooleanRuleHelper */
20-
private $helper;
19+
private BooleanRuleHelper $helper;
2120

22-
/** @var bool */
23-
private $bleedingEdge;
21+
private bool $bleedingEdge;
2422

2523
public function __construct(BooleanRuleHelper $helper, bool $bleedingEdge)
2624
{
@@ -44,7 +42,7 @@ public function processNode(Node $node, Scope $scope): array
4442
$messages[] = RuleErrorBuilder::message(sprintf(
4543
'Only booleans are allowed in %s, %s given on the left side.',
4644
$nodeText,
47-
$leftType->describe(VerbosityLevel::typeOnly())
45+
$leftType->describe(VerbosityLevel::typeOnly()),
4846
))->identifier(sprintf('%s.leftNotBoolean', $identifierType))->build();
4947
}
5048

@@ -54,7 +52,7 @@ public function processNode(Node $node, Scope $scope): array
5452
$messages[] = RuleErrorBuilder::message(sprintf(
5553
'Only booleans are allowed in %s, %s given on the right side.',
5654
$nodeText,
57-
$rightType->describe(VerbosityLevel::typeOnly())
55+
$rightType->describe(VerbosityLevel::typeOnly()),
5856
))->identifier(sprintf('%s.rightNotBoolean', $identifierType))->build();
5957
}
6058

src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
class BooleanInBooleanNotRule implements Rule
1717
{
1818

19-
/** @var BooleanRuleHelper */
20-
private $helper;
19+
private BooleanRuleHelper $helper;
2120

2221
public function __construct(BooleanRuleHelper $helper)
2322
{
@@ -40,7 +39,7 @@ public function processNode(Node $node, Scope $scope): array
4039
return [
4140
RuleErrorBuilder::message(sprintf(
4241
'Only booleans are allowed in a negated boolean, %s given.',
43-
$expressionType->describe(VerbosityLevel::typeOnly())
42+
$expressionType->describe(VerbosityLevel::typeOnly()),
4443
))->identifier('booleanNot.exprNotBoolean')->build(),
4544
];
4645
}

src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
class BooleanInBooleanOrRule implements Rule
1717
{
1818

19-
/** @var BooleanRuleHelper */
20-
private $helper;
19+
private BooleanRuleHelper $helper;
2120

22-
/** @var bool */
23-
private $bleedingEdge;
21+
private bool $bleedingEdge;
2422

2523
public function __construct(BooleanRuleHelper $helper, bool $bleedingEdge)
2624
{
@@ -44,7 +42,7 @@ public function processNode(Node $node, Scope $scope): array
4442
$messages[] = RuleErrorBuilder::message(sprintf(
4543
'Only booleans are allowed in %s, %s given on the left side.',
4644
$nodeText,
47-
$leftType->describe(VerbosityLevel::typeOnly())
45+
$leftType->describe(VerbosityLevel::typeOnly()),
4846
))->identifier(sprintf('%s.leftNotBoolean', $identifierType))->build();
4947
}
5048

@@ -54,7 +52,7 @@ public function processNode(Node $node, Scope $scope): array
5452
$messages[] = RuleErrorBuilder::message(sprintf(
5553
'Only booleans are allowed in %s, %s given on the right side.',
5654
$nodeText,
57-
$rightType->describe(VerbosityLevel::typeOnly())
55+
$rightType->describe(VerbosityLevel::typeOnly()),
5856
))->identifier(sprintf('%s.rightNotBoolean', $identifierType))->build();
5957
}
6058

src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
class BooleanInElseIfConditionRule implements Rule
1717
{
1818

19-
/** @var BooleanRuleHelper */
20-
private $helper;
19+
private BooleanRuleHelper $helper;
2120

2221
public function __construct(BooleanRuleHelper $helper)
2322
{
@@ -40,7 +39,7 @@ public function processNode(Node $node, Scope $scope): array
4039
return [
4140
RuleErrorBuilder::message(sprintf(
4241
'Only booleans are allowed in an elseif condition, %s given.',
43-
$conditionExpressionType->describe(VerbosityLevel::typeOnly())
42+
$conditionExpressionType->describe(VerbosityLevel::typeOnly()),
4443
))->identifier('elseif.condNotBoolean')->build(),
4544
];
4645
}

src/Rules/BooleansInConditions/BooleanInIfConditionRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
class BooleanInIfConditionRule implements Rule
1717
{
1818

19-
/** @var BooleanRuleHelper */
20-
private $helper;
19+
private BooleanRuleHelper $helper;
2120

2221
public function __construct(BooleanRuleHelper $helper)
2322
{
@@ -40,7 +39,7 @@ public function processNode(Node $node, Scope $scope): array
4039
return [
4140
RuleErrorBuilder::message(sprintf(
4241
'Only booleans are allowed in an if condition, %s given.',
43-
$conditionExpressionType->describe(VerbosityLevel::typeOnly())
42+
$conditionExpressionType->describe(VerbosityLevel::typeOnly()),
4443
))->identifier('if.condNotBoolean')->build(),
4544
];
4645
}

src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
class BooleanInTernaryOperatorRule implements Rule
1717
{
1818

19-
/** @var BooleanRuleHelper */
20-
private $helper;
19+
private BooleanRuleHelper $helper;
2120

2221
public function __construct(BooleanRuleHelper $helper)
2322
{
@@ -44,7 +43,7 @@ public function processNode(Node $node, Scope $scope): array
4443
return [
4544
RuleErrorBuilder::message(sprintf(
4645
'Only booleans are allowed in a ternary operator condition, %s given.',
47-
$conditionExpressionType->describe(VerbosityLevel::typeOnly())
46+
$conditionExpressionType->describe(VerbosityLevel::typeOnly()),
4847
))->identifier('ternary.condNotBoolean')->build(),
4948
];
5049
}

src/Rules/BooleansInConditions/BooleanRuleHelper.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
class BooleanRuleHelper
1313
{
1414

15-
/** @var RuleLevelHelper */
16-
private $ruleLevelHelper;
15+
private RuleLevelHelper $ruleLevelHelper;
1716

1817
public function __construct(RuleLevelHelper $ruleLevelHelper)
1918
{
@@ -30,9 +29,7 @@ public function passesAsBoolean(Scope $scope, Expr $expr): bool
3029
$scope,
3130
$expr,
3231
'',
33-
static function (Type $type): bool {
34-
return $type->isBoolean()->yes();
35-
}
32+
static fn (Type $type): bool => $type->isBoolean()->yes(),
3633
);
3734
$foundType = $typeToCheck->getType();
3835
if ($foundType instanceof ErrorType) {

src/Rules/Cast/UselessCastRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
class UselessCastRule implements Rule
1919
{
2020

21-
/** @var bool */
22-
private $treatPhpDocTypesAsCertain;
21+
private bool $treatPhpDocTypesAsCertain;
2322

2423
public function __construct(bool $treatPhpDocTypesAsCertain)
2524
{
@@ -61,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array
6160
$addTip(RuleErrorBuilder::message(sprintf(
6261
'Casting to %s something that\'s already %s.',
6362
$castType->describe(VerbosityLevel::typeOnly()),
64-
$expressionType->describe(VerbosityLevel::typeOnly())
63+
$expressionType->describe(VerbosityLevel::typeOnly()),
6564
)))->identifier('cast.useless')->build(),
6665
];
6766
}

src/Rules/Classes/RequireParentConstructCallRule.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function processNode(Node $node, Scope $scope): array
5959
RuleErrorBuilder::message(sprintf(
6060
'%s::__construct() does not call parent constructor from %s.',
6161
$classReflection->getName(),
62-
$parentClass->getName()
62+
$parentClass->getName(),
6363
))->identifier('constructor.missingParentCall')->build(),
6464
];
6565
}

src/Rules/DisallowedConstructs/DisallowedLooseComparisonRule.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function processNode(Node $node, Scope $scope): array
2626
if ($node instanceof Equal) {
2727
return [
2828
RuleErrorBuilder::message(
29-
'Loose comparison via "==" is not allowed.'
29+
'Loose comparison via "==" is not allowed.',
3030
)->tip('Use strict comparison via "===" instead.')
3131
->identifier('equal.notAllowed')
3232
->build(),
@@ -35,7 +35,7 @@ public function processNode(Node $node, Scope $scope): array
3535
if ($node instanceof NotEqual) {
3636
return [
3737
RuleErrorBuilder::message(
38-
'Loose comparison via "!=" is not allowed.'
38+
'Loose comparison via "!=" is not allowed.',
3939
)->tip('Use strict comparison via "!==" instead.')
4040
->identifier('notEqual.notAllowed')
4141
->build(),

src/Rules/Functions/ArrayFilterStrictRule.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323
class ArrayFilterStrictRule implements Rule
2424
{
2525

26-
/** @var ReflectionProvider */
27-
private $reflectionProvider;
26+
private ReflectionProvider $reflectionProvider;
2827

29-
/** @var bool */
30-
private $treatPhpDocTypesAsCertain;
28+
private bool $treatPhpDocTypesAsCertain;
3129

32-
/** @var bool */
33-
private $checkNullables;
30+
private bool $checkNullables;
3431

3532
public function __construct(
3633
ReflectionProvider $reflectionProvider,
@@ -68,7 +65,7 @@ public function processNode(Node $node, Scope $scope): array
6865
$scope,
6966
$node->getArgs(),
7067
$functionReflection->getVariants(),
71-
$functionReflection->getNamedArgumentsVariants()
68+
$functionReflection->getNamedArgumentsVariants(),
7269
);
7370

7471
$normalizedFuncCall = ArgumentsNormalizer::reorderFuncArguments($parametersAcceptor, $node);
@@ -132,7 +129,7 @@ public function processNode(Node $node, Scope $scope): array
132129
$message = 'Parameter #2 of array_filter() cannot be null to avoid loose comparison semantics (%s given).';
133130
$errorBuilder = RuleErrorBuilder::message(sprintf(
134131
$message,
135-
$callbackType->describe(VerbosityLevel::typeOnly())
132+
$callbackType->describe(VerbosityLevel::typeOnly()),
136133
))->identifier('arrayFilter.strict');
137134

138135
if (!$this->isCallbackTypeNull($nativeCallbackType) && $this->treatPhpDocTypesAsCertain) {

src/Rules/Methods/WrongCaseOfInheritedMethodRule.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function processNode(
3535
$parentMessage = $this->findMethod(
3636
$declaringClass,
3737
$declaringClass->getParentClass(),
38-
$methodReflection->getName()
38+
$methodReflection->getName(),
3939
);
4040
if ($parentMessage !== null) {
4141
$messages[] = $parentMessage;
@@ -46,7 +46,7 @@ public function processNode(
4646
$interfaceMessage = $this->findMethod(
4747
$declaringClass,
4848
$interface,
49-
$methodReflection->getName()
49+
$methodReflection->getName(),
5050
);
5151
if ($interfaceMessage === null) {
5252
continue;
@@ -79,7 +79,7 @@ private function findMethod(
7979
$methodName,
8080
$classReflection->isInterface() ? 'interface' : 'parent',
8181
$classReflection->getDisplayName(),
82-
$parentMethod->getName()
82+
$parentMethod->getName(),
8383
))->identifier('method.nameCase')->build();
8484
}
8585

src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
abstract class OperandInArithmeticIncrementOrDecrementRule implements Rule
2121
{
2222

23-
/** @var OperatorRuleHelper */
24-
private $helper;
23+
private OperatorRuleHelper $helper;
2524

2625
public function __construct(OperatorRuleHelper $helper)
2726
{
@@ -45,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array
4544
$messages[] = RuleErrorBuilder::message(sprintf(
4645
'Only numeric types are allowed in %s, %s given.',
4746
$this->describeOperation(),
48-
$varType->describe(VerbosityLevel::typeOnly())
47+
$varType->describe(VerbosityLevel::typeOnly()),
4948
))->identifier(sprintf('%s.nonNumeric', $this->getIdentifier()))->build();
5049
}
5150

src/Rules/Operators/OperandsInArithmeticAdditionRule.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
class OperandsInArithmeticAdditionRule implements Rule
2020
{
2121

22-
/** @var OperatorRuleHelper */
23-
private $helper;
22+
private OperatorRuleHelper $helper;
2423

25-
/** @var bool */
26-
private $bleedingEdge;
24+
private bool $bleedingEdge;
2725

2826
public function __construct(OperatorRuleHelper $helper, bool $bleedingEdge)
2927
{
@@ -58,13 +56,13 @@ public function processNode(Node $node, Scope $scope): array
5856
if (!$this->helper->isValidForArithmeticOperation($scope, $left)) {
5957
$messages[] = RuleErrorBuilder::message(sprintf(
6058
'Only numeric types are allowed in +, %s given on the left side.',
61-
$leftType->describe(VerbosityLevel::typeOnly())
59+
$leftType->describe(VerbosityLevel::typeOnly()),
6260
))->identifier('plus.leftNonNumeric')->build();
6361
}
6462
if (!$this->helper->isValidForArithmeticOperation($scope, $right)) {
6563
$messages[] = RuleErrorBuilder::message(sprintf(
6664
'Only numeric types are allowed in +, %s given on the right side.',
67-
$rightType->describe(VerbosityLevel::typeOnly())
65+
$rightType->describe(VerbosityLevel::typeOnly()),
6866
))->identifier('plus.rightNonNumeric')->build();
6967
}
7068

src/Rules/Operators/OperandsInArithmeticDivisionRule.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
class OperandsInArithmeticDivisionRule implements Rule
1919
{
2020

21-
/** @var OperatorRuleHelper */
22-
private $helper;
21+
private OperatorRuleHelper $helper;
2322

24-
/** @var bool */
25-
private $bleedingEdge;
23+
private bool $bleedingEdge;
2624

2725
public function __construct(OperatorRuleHelper $helper, bool $bleedingEdge)
2826
{
@@ -52,15 +50,15 @@ public function processNode(Node $node, Scope $scope): array
5250
if (!$this->helper->isValidForArithmeticOperation($scope, $left)) {
5351
$messages[] = RuleErrorBuilder::message(sprintf(
5452
'Only numeric types are allowed in /, %s given on the left side.',
55-
$leftType->describe(VerbosityLevel::typeOnly())
53+
$leftType->describe(VerbosityLevel::typeOnly()),
5654
))->identifier('div.leftNonNumeric')->build();
5755
}
5856

5957
$rightType = $scope->getType($right);
6058
if (!$this->helper->isValidForArithmeticOperation($scope, $right)) {
6159
$messages[] = RuleErrorBuilder::message(sprintf(
6260
'Only numeric types are allowed in /, %s given on the right side.',
63-
$rightType->describe(VerbosityLevel::typeOnly())
61+
$rightType->describe(VerbosityLevel::typeOnly()),
6462
))->identifier('div.rightNonNumeric')->build();
6563
}
6664

0 commit comments

Comments
 (0)