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

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/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

Lines changed: 3 additions & 5 deletions
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

Lines changed: 4 additions & 6 deletions
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

Lines changed: 6 additions & 11 deletions
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

Lines changed: 4 additions & 6 deletions
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

Lines changed: 4 additions & 6 deletions
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

Lines changed: 8 additions & 13 deletions
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

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

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

0 commit comments

Comments
 (0)