Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3faa605

Browse files
Update build-cs
1 parent 953195d commit 3faa605

23 files changed

+153
-228
lines changed

‎.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/PhpDoc/PHPUnit/MockObjectTypeNodeResolverExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
class MockObjectTypeNodeResolverExtension implements TypeNodeResolverExtension, TypeNodeResolverAwareExtension
1818
{
1919

20-
/** @var TypeNodeResolver */
21-
private $typeNodeResolver;
20+
private TypeNodeResolver $typeNodeResolver;
2221

2322
public function setTypeNodeResolver(TypeNodeResolver $typeNodeResolver): void
2423
{

‎src/Rules/PHPUnit/AnnotationHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function processDocComment(Doc $docComment): array
5656
}
5757

5858
$errors[] = RuleErrorBuilder::message(
59-
'Annotation "' . $matches['annotation'] . '" is invalid, "@' . $matches['property'] . '" should be followed by a space and a value.'
59+
'Annotation "' . $matches['annotation'] . '" is invalid, "@' . $matches['property'] . '" should be followed by a space and a value.',
6060
)->identifier('phpunit.invalidPhpDoc')->build();
6161
}
6262

‎src/Rules/PHPUnit/AssertRuleHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function isMethodOrStaticCallOnAssert(Node $node, Scope $scope): b
3030
'static',
3131
'parent',
3232
],
33-
true
33+
true,
3434
)
3535
) {
3636
$calledOnType = new ObjectType($scope->getClassReflection()->getName());

‎src/Rules/PHPUnit/ClassCoversExistsRule.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ class ClassCoversExistsRule implements Rule
2323
/**
2424
* Covers helper.
2525
*
26-
* @var CoversHelper
2726
*/
28-
private $coversHelper;
27+
private CoversHelper$coversHelper;
2928

3029
/**
3130
* Reflection provider.
3231
*
33-
* @var ReflectionProvider
3432
*/
35-
private $reflectionProvider;
33+
private ReflectionProvider$reflectionProvider;
3634

3735
public function __construct(
3836
CoversHelper $coversHelper,
@@ -62,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array
6260
if (count($classCoversDefaultClasses) >= 2) {
6361
return [
6462
RuleErrorBuilder::message(sprintf(
65-
'@coversDefaultClass is defined multiple times.'
63+
'@coversDefaultClass is defined multiple times.',
6664
))->identifier('phpunit.coversDuplicate')->build(),
6765
];
6866
}
@@ -75,15 +73,15 @@ public function processNode(Node $node, Scope $scope): array
7573
if (!$this->reflectionProvider->hasClass($className)) {
7674
$errors[] = RuleErrorBuilder::message(sprintf(
7775
'@coversDefaultClass references an invalid class %s.',
78-
$className
76+
$className,
7977
))->identifier('phpunit.coversClass')->build();
8078
}
8179
}
8280

8381
foreach ($classCovers as $covers) {
8482
$errors = array_merge(
8583
$errors,
86-
$this->coversHelper->processCovers($node, $covers, null)
84+
$this->coversHelper->processCovers($node, $covers, null),
8785
);
8886
}
8987

‎src/Rules/PHPUnit/ClassMethodCoversExistsRule.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ class ClassMethodCoversExistsRule implements Rule
2525
/**
2626
* Covers helper.
2727
*
28-
* @var CoversHelper
2928
*/
30-
private $coversHelper;
29+
private CoversHelper$coversHelper;
3130

3231
/**
3332
* The file type mapper.
3433
*
35-
* @var FileTypeMapper
3634
*/
37-
private $fileTypeMapper;
35+
private FileTypeMapper$fileTypeMapper;
3836

3937
public function __construct(
4038
CoversHelper $coversHelper,
@@ -65,9 +63,7 @@ public function processNode(Node $node, Scope $scope): array
6563
$classPhpDoc = $classReflection->getResolvedPhpDoc();
6664
[$classCovers, $classCoversDefaultClasses] = $this->coversHelper->getCoverAnnotations($classPhpDoc);
6765

68-
$classCoversStrings = array_map(static function (PhpDocTagNode $covers): string {
69-
return (string) $covers->value;
70-
}, $classCovers);
66+
$classCoversStrings = array_map(static fn (PhpDocTagNode $covers): string => (string) $covers->value, $classCovers);
7167

7268
$docComment = $node->getDocComment();
7369
if ($docComment === null) {
@@ -83,7 +79,7 @@ public function processNode(Node $node, Scope $scope): array
8379
$classReflection->getName(),
8480
$scope->isInTrait() ? $scope->getTraitReflection()->getName() : null,
8581
$node->name->toString(),
86-
$docComment->getText()
82+
$docComment->getText(),
8783
);
8884

8985
[$methodCovers, $methodCoversDefaultClasses] = $this->coversHelper->getCoverAnnotations($methodPhpDoc);
@@ -93,21 +89,21 @@ public function processNode(Node $node, Scope $scope): array
9389
if (count($methodCoversDefaultClasses) > 0) {
9490
$errors[] = RuleErrorBuilder::message(sprintf(
9591
'@coversDefaultClass defined on class method %s.',
96-
$node->name
92+
$node->name,
9793
))->identifier('phpunit.covers')->build();
9894
}
9995

10096
foreach ($methodCovers as $covers) {
10197
if (in_array((string) $covers->value, $classCoversStrings, true)) {
10298
$errors[] = RuleErrorBuilder::message(sprintf(
10399
'Class already @covers %s so the method @covers is redundant.',
104-
$covers->value
100+
$covers->value,
105101
))->identifier('phpunit.coversDuplicate')->build();
106102
}
107103

108104
$errors = array_merge(
109105
$errors,
110-
$this->coversHelper->processCovers($node, $covers, $coversDefaultClass)
106+
$this->coversHelper->processCovers($node, $covers, $coversDefaultClass),
111107
);
112108
}
113109

‎src/Rules/PHPUnit/CoversHelper.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ class CoversHelper
2020
/**
2121
* Reflection provider.
2222
*
23-
* @var ReflectionProvider
2423
*/
25-
private $reflectionProvider;
24+
private ReflectionProvider$reflectionProvider;
2625

2726
public function __construct(ReflectionProvider $reflectionProvider)
2827
{
@@ -48,12 +47,12 @@ public function getCoverAnnotations(?ResolvedPhpDocBlock $phpDoc): array
4847
foreach ($phpDocNodes as $docNode) {
4948
$covers = array_merge(
5049
$covers,
51-
$docNode->getTagsByName('@covers')
50+
$docNode->getTagsByName('@covers'),
5251
);
5352

5453
$coversDefaultClasses = array_merge(
5554
$coversDefaultClasses,
56-
$docNode->getTagsByName('@coversDefaultClass')
55+
$docNode->getTagsByName('@coversDefaultClass'),
5756
);
5857
}
5958

@@ -100,14 +99,14 @@ public function processCovers(
10099
if ($class->isInterface()) {
101100
$errors[] = RuleErrorBuilder::message(sprintf(
102101
'@covers value %s references an interface.',
103-
$fullName
102+
$fullName,
104103
))->identifier('phpunit.coversInterface')->build();
105104
}
106105

107106
if (isset($method) && $method !== '' && !$class->hasMethod($method)) {
108107
$errors[] = RuleErrorBuilder::message(sprintf(
109108
'@covers value %s references an invalid method.',
110-
$fullName
109+
$fullName,
111110
))->identifier('phpunit.coversMethod')->build();
112111
}
113112
} elseif (isset($method) && $this->reflectionProvider->hasFunction(new Name($method, []), null)) {
@@ -118,7 +117,7 @@ public function processCovers(
118117
$error = RuleErrorBuilder::message(sprintf(
119118
'@covers value %s references an invalid %s.',
120119
$fullName,
121-
$isMethod ? 'method' : 'class or function'
120+
$isMethod ? 'method' : 'class or function',
122121
))->identifier(sprintf('phpunit.covers%s', $isMethod ? 'Method' : ''));
123122

124123
if (strpos($className, '\\') === false) {

‎src/Rules/PHPUnit/DataProviderDeclarationRule.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@ class DataProviderDeclarationRule implements Rule
1717
/**
1818
* Data provider helper.
1919
*
20-
* @var DataProviderHelper
2120
*/
22-
private $dataProviderHelper;
21+
private DataProviderHelper$dataProviderHelper;
2322

2423
/**
2524
* When set to true, it reports data provider method with incorrect name case.
2625
*
27-
* @var bool
2826
*/
29-
private $checkFunctionNameCase;
27+
private bool$checkFunctionNameCase;
3028

3129
/**
3230
* When phpstan-deprecation-rules is installed, it reports deprecated usages.
3331
*
34-
* @var bool
3532
*/
36-
private $deprecationRulesInstalled;
33+
private bool$deprecationRulesInstalled;
3734

3835
public function __construct(
3936
DataProviderHelper $dataProviderHelper,
@@ -70,8 +67,8 @@ public function processNode(Node $node, Scope $scope): array
7067
$dataProviderMethodName,
7168
$lineNumber,
7269
$this->checkFunctionNameCase,
73-
$this->deprecationRulesInstalled
74-
)
70+
$this->deprecationRulesInstalled,
71+
),
7572
);
7673
}
7774

‎src/Rules/PHPUnit/DataProviderHelper.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,16 @@ class DataProviderHelper
2828
/**
2929
* Reflection provider.
3030
*
31-
* @var ReflectionProvider
3231
*/
33-
private $reflectionProvider;
32+
private ReflectionProvider$reflectionProvider;
3433

3534
/**
3635
* The file type mapper.
3736
*
38-
* @var FileTypeMapper
3937
*/
40-
private $fileTypeMapper;
38+
private FileTypeMapper$fileTypeMapper;
4139

42-
/** @var bool */
43-
private $phpunit10OrNewer;
40+
private bool $phpunit10OrNewer;
4441

4542
public function __construct(
4643
ReflectionProvider $reflectionProvider,
@@ -69,7 +66,7 @@ public function getDataProviderMethods(
6966
$classReflection->getName(),
7067
$scope->isInTrait() ? $scope->getTraitReflection()->getName() : null,
7168
$node->name->toString(),
72-
$docComment->getText()
69+
$docComment->getText(),
7370
);
7471
foreach ($this->getDataProviderAnnotations($methodPhpDoc) as $annotation) {
7572
$dataProviderValue = $this->getDataProviderAnnotationValue($annotation);
@@ -122,7 +119,7 @@ private function getDataProviderAnnotations(?ResolvedPhpDocBlock $phpDoc): array
122119
foreach ($phpDocNodes as $docNode) {
123120
$annotations = array_merge(
124121
$annotations,
125-
$docNode->getTagsByName('@dataProvider')
122+
$docNode->getTagsByName('@dataProvider'),
126123
);
127124
}
128125

@@ -145,7 +142,7 @@ public function processDataProvider(
145142
return [
146143
RuleErrorBuilder::message(sprintf(
147144
'@dataProvider %s related class not found.',
148-
$dataProviderValue
145+
$dataProviderValue,
149146
))
150147
->line($lineNumber)
151148
->identifier('phpunit.dataProviderClass')
@@ -159,7 +156,7 @@ public function processDataProvider(
159156
return [
160157
RuleErrorBuilder::message(sprintf(
161158
'@dataProvider %s related method not found.',
162-
$dataProviderValue
159+
$dataProviderValue,
163160
))
164161
->line($lineNumber)
165162
->identifier('phpunit.dataProviderMethod')
@@ -173,7 +170,7 @@ public function processDataProvider(
173170
$errors[] = RuleErrorBuilder::message(sprintf(
174171
'@dataProvider %s related method is used with incorrect case: %s.',
175172
$dataProviderValue,
176-
$dataProviderMethodReflection->getName()
173+
$dataProviderMethodReflection->getName(),
177174
))
178175
->line($lineNumber)
179176
->identifier('method.nameCase')
@@ -183,7 +180,7 @@ public function processDataProvider(
183180
if (!$dataProviderMethodReflection->isPublic()) {
184181
$errors[] = RuleErrorBuilder::message(sprintf(
185182
'@dataProvider %s related method must be public.',
186-
$dataProviderValue
183+
$dataProviderValue,
187184
))
188185
->line($lineNumber)
189186
->identifier('phpunit.dataProviderPublic')
@@ -193,7 +190,7 @@ public function processDataProvider(
193190
if ($deprecationRulesInstalled && $this->phpunit10OrNewer && !$dataProviderMethodReflection->isStatic()) {
194191
$errors[] = RuleErrorBuilder::message(sprintf(
195192
'@dataProvider %s related method must be static in PHPUnit 10 and newer.',
196-
$dataProviderValue
193+
$dataProviderValue,
197194
))
198195
->line($lineNumber)
199196
->identifier('phpunit.dataProviderStatic')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /