Skip to content

Commit 4590cf6

Browse files
committed
Update build-cs
1 parent 681b2db commit 4590cf6

File tree

38 files changed

+121
-166
lines changed

38 files changed

+121
-166
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/main
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/DependencyInjection/LazyDeprecatedScopeResolverProvider.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ final class LazyDeprecatedScopeResolverProvider
99

1010
public const EXTENSION_TAG = 'phpstan.deprecations.deprecatedScopeResolver';
1111

12-
/** @var Container */
13-
private $container;
12+
private Container $container;
1413

15-
/** @var DeprecatedScopeHelper */
16-
private $scopeHelper;
14+
private ?DeprecatedScopeHelper $scopeHelper = null;
1715

1816
public function __construct(Container $container)
1917
{
@@ -24,7 +22,7 @@ public function get(): DeprecatedScopeHelper
2422
{
2523
if ($this->scopeHelper === null) {
2624
$this->scopeHelper = new DeprecatedScopeHelper(
27-
$this->container->getServicesByTag(self::EXTENSION_TAG)
25+
$this->container->getServicesByTag(self::EXTENSION_TAG),
2826
);
2927
}
3028
return $this->scopeHelper;

src/Rules/Deprecations/AccessDeprecatedPropertyRule.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
class AccessDeprecatedPropertyRule implements Rule
2121
{
2222

23-
/** @var ReflectionProvider */
24-
private $reflectionProvider;
23+
private ReflectionProvider $reflectionProvider;
2524

26-
/** @var DeprecatedScopeHelper */
27-
private $deprecatedScopeHelper;
25+
private DeprecatedScopeHelper $deprecatedScopeHelper;
2826

2927
public function __construct(ReflectionProvider $reflectionProvider, DeprecatedScopeHelper $deprecatedScopeHelper)
3028
{
@@ -64,7 +62,7 @@ public function processNode(Node $node, Scope $scope): array
6462
'Access to deprecated property $%s of %s %s.',
6563
$propertyName,
6664
strtolower($propertyReflection->getDeclaringClass()->getClassTypeDescription()),
67-
$propertyReflection->getDeclaringClass()->getName()
65+
$propertyReflection->getDeclaringClass()->getName(),
6866
))->identifier('property.deprecated')->build(),
6967
];
7068
}
@@ -75,7 +73,7 @@ public function processNode(Node $node, Scope $scope): array
7573
$propertyName,
7674
strtolower($propertyReflection->getDeclaringClass()->getClassTypeDescription()),
7775
$propertyReflection->getDeclaringClass()->getName(),
78-
$description
76+
$description,
7977
))->identifier('property.deprecated')->build(),
8078
];
8179
}

src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@
2424
class AccessDeprecatedStaticPropertyRule implements Rule
2525
{
2626

27-
/** @var ReflectionProvider */
28-
private $reflectionProvider;
27+
private ReflectionProvider $reflectionProvider;
2928

30-
/** @var RuleLevelHelper */
31-
private $ruleLevelHelper;
29+
private RuleLevelHelper $ruleLevelHelper;
3230

33-
/** @var DeprecatedScopeHelper */
34-
private $deprecatedScopeHelper;
31+
private DeprecatedScopeHelper $deprecatedScopeHelper;
3532

3633
public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper, DeprecatedScopeHelper $deprecatedScopeHelper)
3734
{
@@ -65,9 +62,7 @@ public function processNode(Node $node, Scope $scope): array
6562
$scope,
6663
$node->class,
6764
'', // We don't care about the error message
68-
static function (Type $type) use ($propertyName): bool {
69-
return $type->canAccessProperties()->yes() && $type->hasProperty($propertyName)->yes();
70-
}
65+
static fn (Type $type): bool => $type->canAccessProperties()->yes() && $type->hasProperty($propertyName)->yes(),
7166
);
7267

7368
if ($classTypeResult->getType() instanceof ErrorType) {
@@ -95,7 +90,7 @@ static function (Type $type) use ($propertyName): bool {
9590
'Access to deprecated static property $%s of %s %s.',
9691
$propertyName,
9792
strtolower($property->getDeclaringClass()->getClassTypeDescription()),
98-
$property->getDeclaringClass()->getName()
93+
$property->getDeclaringClass()->getName(),
9994
))->identifier('staticProperty.deprecated')->build(),
10095
];
10196
}
@@ -106,7 +101,7 @@ static function (Type $type) use ($propertyName): bool {
106101
$propertyName,
107102
strtolower($property->getDeclaringClass()->getClassTypeDescription()),
108103
$property->getDeclaringClass()->getName(),
109-
$description
104+
$description,
110105
))->identifier('staticProperty.deprecated')->build(),
111106
];
112107
}

src/Rules/Deprecations/CallToDeprecatedFunctionRule.php

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

21-
/** @var ReflectionProvider */
22-
private $reflectionProvider;
21+
private ReflectionProvider $reflectionProvider;
2322

24-
/** @var DeprecatedScopeHelper */
25-
private $deprecatedScopeHelper;
23+
private DeprecatedScopeHelper $deprecatedScopeHelper;
2624

2725
public function __construct(ReflectionProvider $reflectionProvider, DeprecatedScopeHelper $deprecatedScopeHelper)
2826
{
@@ -58,7 +56,7 @@ public function processNode(Node $node, Scope $scope): array
5856
return [
5957
RuleErrorBuilder::message(sprintf(
6058
'Call to deprecated function %s().',
61-
$function->getName()
59+
$function->getName(),
6260
))->identifier('function.deprecated')->build(),
6361
];
6462
}
@@ -67,7 +65,7 @@ public function processNode(Node $node, Scope $scope): array
6765
RuleErrorBuilder::message(sprintf(
6866
"Call to deprecated function %s():\n%s",
6967
$function->getName(),
70-
$description
68+
$description,
7169
))->identifier('function.deprecated')->build(),
7270
];
7371
}

src/Rules/Deprecations/CallToDeprecatedMethodRule.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
class CallToDeprecatedMethodRule implements Rule
2121
{
2222

23-
/** @var ReflectionProvider */
24-
private $reflectionProvider;
23+
private ReflectionProvider $reflectionProvider;
2524

26-
/** @var DeprecatedScopeHelper */
27-
private $deprecatedScopeHelper;
25+
private DeprecatedScopeHelper $deprecatedScopeHelper;
2826

2927
public function __construct(ReflectionProvider $reflectionProvider, DeprecatedScopeHelper $deprecatedScopeHelper)
3028
{
@@ -67,7 +65,7 @@ public function processNode(Node $node, Scope $scope): array
6765
'Call to deprecated method %s() of %s %s.',
6866
$methodReflection->getName(),
6967
strtolower($methodReflection->getDeclaringClass()->getClassTypeDescription()),
70-
$methodReflection->getDeclaringClass()->getName()
68+
$methodReflection->getDeclaringClass()->getName(),
7169
))->identifier('method.deprecated')->build(),
7270
];
7371
}
@@ -78,7 +76,7 @@ public function processNode(Node $node, Scope $scope): array
7876
$methodReflection->getName(),
7977
strtolower($methodReflection->getDeclaringClass()->getClassTypeDescription()),
8078
$methodReflection->getDeclaringClass()->getName(),
81-
$description
79+
$description,
8280
))->identifier('method.deprecated')->build(),
8381
];
8482
} catch (ClassNotFoundException $e) {

src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php

+8-13
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@
2424
class CallToDeprecatedStaticMethodRule implements Rule
2525
{
2626

27-
/** @var ReflectionProvider */
28-
private $reflectionProvider;
27+
private ReflectionProvider $reflectionProvider;
2928

30-
/** @var RuleLevelHelper */
31-
private $ruleLevelHelper;
29+
private RuleLevelHelper $ruleLevelHelper;
3230

33-
/** @var DeprecatedScopeHelper */
34-
private $deprecatedScopeHelper;
31+
private DeprecatedScopeHelper $deprecatedScopeHelper;
3532

3633
public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper, DeprecatedScopeHelper $deprecatedScopeHelper)
3734
{
@@ -65,9 +62,7 @@ public function processNode(Node $node, Scope $scope): array
6562
$scope,
6663
$node->class,
6764
'', // We don't care about the error message
68-
static function (Type $type) use ($methodName): bool {
69-
return $type->canCallMethods()->yes() && $type->hasMethod($methodName)->yes();
70-
}
65+
static fn (Type $type): bool => $type->canCallMethods()->yes() && $type->hasMethod($methodName)->yes(),
7166
);
7267

7368
if ($classTypeResult->getType() instanceof ErrorType) {
@@ -96,15 +91,15 @@ static function (Type $type) use ($methodName): bool {
9691
'Call to method %s() of deprecated %s %s.',
9792
$methodReflection->getName(),
9893
strtolower($methodReflection->getDeclaringClass()->getClassTypeDescription()),
99-
$methodReflection->getDeclaringClass()->getName()
94+
$methodReflection->getDeclaringClass()->getName(),
10095
))->identifier(sprintf('staticMethod.deprecated%s', $methodReflection->getDeclaringClass()->getClassTypeDescription()))->build();
10196
} else {
10297
$errors[] = RuleErrorBuilder::message(sprintf(
10398
"Call to method %s() of deprecated %s %s:\n%s",
10499
$methodReflection->getName(),
105100
strtolower($methodReflection->getDeclaringClass()->getClassTypeDescription()),
106101
$methodReflection->getDeclaringClass()->getName(),
107-
$classDescription
102+
$classDescription,
108103
))->identifier(sprintf('staticMethod.deprecated%s', $methodReflection->getDeclaringClass()->getClassTypeDescription()))->build();
109104
}
110105
}
@@ -119,15 +114,15 @@ static function (Type $type) use ($methodName): bool {
119114
'Call to deprecated method %s() of %s %s.',
120115
$methodReflection->getName(),
121116
strtolower($methodReflection->getDeclaringClass()->getClassTypeDescription()),
122-
$methodReflection->getDeclaringClass()->getName()
117+
$methodReflection->getDeclaringClass()->getName(),
123118
))->identifier('staticMethod.deprecated')->build();
124119
} else {
125120
$errors[] = RuleErrorBuilder::message(sprintf(
126121
"Call to deprecated method %s() of %s %s:\n%s",
127122
$methodReflection->getName(),
128123
strtolower($methodReflection->getDeclaringClass()->getClassTypeDescription()),
129124
$methodReflection->getDeclaringClass()->getName(),
130-
$description
125+
$description,
131126
))->identifier('staticMethod.deprecated')->build();
132127
}
133128
}

src/Rules/Deprecations/DeprecatedClassHelper.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
class DeprecatedClassHelper
1111
{
1212

13-
/** @var ReflectionProvider */
14-
private $reflectionProvider;
13+
private ReflectionProvider $reflectionProvider;
1514

1615
public function __construct(ReflectionProvider $reflectionProvider)
1716
{

src/Rules/Deprecations/DeprecatedScopeHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class DeprecatedScopeHelper
88
{
99

1010
/** @var DeprecatedScopeResolver[] */
11-
private $resolvers;
11+
private array $resolvers;
1212

1313
/**
1414
* @param DeprecatedScopeResolver[] $checkers

src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php

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

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

29-
/** @var RuleLevelHelper */
30-
private $ruleLevelHelper;
28+
private RuleLevelHelper $ruleLevelHelper;
3129

32-
/** @var DeprecatedScopeHelper */
33-
private $deprecatedScopeHelper;
30+
private DeprecatedScopeHelper $deprecatedScopeHelper;
3431

3532
public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper, DeprecatedScopeHelper $deprecatedScopeHelper)
3633
{
@@ -64,9 +61,7 @@ public function processNode(Node $node, Scope $scope): array
6461
$scope,
6562
$node->class,
6663
'', // We don't care about the error message
67-
static function (Type $type) use ($constantName): bool {
68-
return $type->canAccessConstants()->yes() && $type->hasConstant($constantName)->yes();
69-
}
64+
static fn (Type $type): bool => $type->canAccessConstants()->yes() && $type->hasConstant($constantName)->yes(),
7065
);
7166

7267
if ($classTypeResult->getType() instanceof ErrorType) {
@@ -92,15 +87,15 @@ static function (Type $type) use ($constantName): bool {
9287
'Fetching class constant %s of deprecated %s %s.',
9388
$constantName,
9489
strtolower($class->getClassTypeDescription()),
95-
$referencedClass
90+
$referencedClass,
9691
))->identifier(sprintf('classConstant.deprecated%s', $class->getClassTypeDescription()))->build();
9792
} else {
9893
$errors[] = RuleErrorBuilder::message(sprintf(
9994
"Fetching class constant %s of deprecated %s %s:\n%s",
10095
$constantName,
10196
strtolower($class->getClassTypeDescription()),
10297
$referencedClass,
103-
$classDescription
98+
$classDescription,
10499
))->identifier(sprintf('classConstant.deprecated%s', $class->getClassTypeDescription()))->build();
105100
}
106101
}
@@ -125,15 +120,15 @@ static function (Type $type) use ($constantName): bool {
125120
'Fetching deprecated class constant %s of %s %s.',
126121
$constantName,
127122
strtolower($class->getClassTypeDescription()),
128-
$referencedClass
123+
$referencedClass,
129124
))->identifier('classConstant.deprecated')->build();
130125
} else {
131126
$errors[] = RuleErrorBuilder::message(sprintf(
132127
"Fetching deprecated class constant %s of %s %s:\n%s",
133128
$constantName,
134129
strtolower($class->getClassTypeDescription()),
135130
$referencedClass,
136-
$description
131+
$description,
137132
))->identifier('classConstant.deprecated')->build();
138133
}
139134
}

src/Rules/Deprecations/FetchingDeprecatedConstRule.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
class FetchingDeprecatedConstRule implements Rule
1717
{
1818

19-
/** @var ReflectionProvider */
20-
private $reflectionProvider;
19+
private ReflectionProvider $reflectionProvider;
2120

22-
/** @var DeprecatedScopeHelper */
23-
private $deprecatedScopeHelper;
21+
private DeprecatedScopeHelper $deprecatedScopeHelper;
2422

2523
public function __construct(ReflectionProvider $reflectionProvider, DeprecatedScopeHelper $deprecatedScopeHelper)
2624
{
@@ -49,7 +47,7 @@ public function processNode(Node $node, Scope $scope): array
4947
return [
5048
RuleErrorBuilder::message(sprintf(
5149
$constantReflection->getDeprecatedDescription() ?? 'Use of constant %s is deprecated.',
52-
$constantReflection->getName()
50+
$constantReflection->getName(),
5351
))->identifier('constant.deprecated')->build(),
5452
];
5553
}

0 commit comments

Comments
 (0)