Skip to content

Commit bbd64b4

Browse files
committed
CS for build/PHPStan/
1 parent 4ef5cca commit bbd64b4

11 files changed

Lines changed: 40 additions & 31 deletions

‎build/PHPStan/Build/ContainerDynamicReturnTypeExtension.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\DependencyInjection\Container;
88
use PHPStan\Reflection\MethodReflection;
9-
use PHPStan\Reflection\ParametersAcceptorSelector;
109
use PHPStan\Type\Constant\ConstantStringType;
1110
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1211
use PHPStan\Type\ObjectType;

‎build/PHPStan/Build/FinalClassRule.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
use PHPStan\Analyser\Scope;
1010
use PHPStan\File\FileHelper;
1111
use PHPStan\Node\InClassNode;
12-
use PHPStan\Reflection\FunctionVariant;
1312
use PHPStan\Reflection\ExtendedFunctionVariant;
13+
use PHPStan\Reflection\FunctionVariant;
1414
use PHPStan\Reflection\Php\DummyParameter;
1515
use PHPStan\Reflection\Php\PhpFunctionFromParserNodeReflection;
1616
use PHPStan\Rules\Rule;
1717
use PHPStan\Rules\RuleErrorBuilder;
1818
use PHPStan\Type\Type;
19+
use function dirname;
1920
use function in_array;
2021
use function sprintf;
2122
use function str_starts_with;

‎build/PHPStan/Build/MemoizationPropertyRule.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use PhpParser\Node\VarLikeIdentifier;
1919
use PHPStan\Analyser\Scope;
2020
use PHPStan\File\FileHelper;
21-
use PHPStan\Node\InClassMethodNode;
2221
use PHPStan\Rules\Rule;
2322
use PHPStan\Rules\RuleErrorBuilder;
2423
use function count;

‎build/PHPStan/Build/NamedArgumentsRule.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PHPStan\Rules\RuleErrorBuilder;
1414
use PHPStan\ShouldNotHappenException;
1515
use PHPStan\Type\VerbosityLevel;
16+
use function array_map;
1617
use function count;
1718
use function implode;
1819
use function sprintf;

‎build/PHPStan/Build/OrChainIdenticalComparisonToInArrayRule.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use PhpParser\Node\Scalar;
1717
use PhpParser\Node\Stmt\If_;
1818
use PHPStan\Analyser\Scope;
19-
use PHPStan\DependencyInjection\AutowiredParameter;
2019
use PHPStan\File\FileHelper;
2120
use PHPStan\Node\Printer\ExprPrinter;
2221
use PHPStan\Rules\IdentifierRuleError;

‎build/PHPStan/Build/OverrideAttributeThirdPartyMethodRule.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPStan\Rules\Methods\MethodPrototypeFinder;
1111
use PHPStan\Rules\Rule;
1212
use PHPStan\Rules\RuleErrorBuilder;
13+
use function sprintf;
1314
use function str_starts_with;
1415

1516
/**

‎build/PHPStan/Build/RequiredPhpVersionVisitor.php‎

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpParser\NodeVisitorAbstract;
99
use PHPStan\Php\PhpMinorVersionIterator;
1010
use PHPStan\Php\PhpVersion;
11+
use PHPStan\ShouldNotHappenException;
1112
use function in_array;
1213
use function strtolower;
1314

@@ -19,6 +20,7 @@
1920
*/
2021
final class RequiredPhpVersionVisitor extends NodeVisitorAbstract
2122
{
23+
2224
private ?int $requiredVersionId = null;
2325

2426
private ?string $reason = null;
@@ -44,64 +46,64 @@ public function getReasonLine(): ?int
4446
public function enterNode(Node $node): ?Node
4547
{
4648
if ($node instanceof Node\Stmt\Enum_) {
47-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsEnums(), 'enums', $node);
49+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsEnums(), 'enums', $node);
4850
}
4951

5052
if ($node instanceof Node\Expr\BinaryOp\Pipe) {
51-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsPipeOperator(), 'the pipe operator', $node);
53+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsPipeOperator(), 'the pipe operator', $node);
5254
}
5355

5456
if ($node instanceof Node\PropertyHook) {
55-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsPropertyHooks(), 'property hooks', $node);
57+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsPropertyHooks(), 'property hooks', $node);
5658
}
5759

5860
if ($node instanceof Node\IntersectionType) {
59-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsPureIntersectionTypes(), 'pure intersection types', $node);
61+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsPureIntersectionTypes(), 'pure intersection types', $node);
6062
}
6163

6264
if ($node instanceof Node\UnionType) {
63-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsNativeUnionTypes(), 'union types', $node);
65+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsNativeUnionTypes(), 'union types', $node);
6466
foreach ($node->types as $innerType) {
6567
if ($innerType instanceof Node\IntersectionType) {
66-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsDisjunctiveNormalForm(), 'disjunctive normal form types', $innerType);
68+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsDisjunctiveNormalForm(), 'disjunctive normal form types', $innerType);
6769
}
6870
if (!($innerType instanceof Node\Identifier) || strtolower($innerType->name) !== 'true') {
6971
continue;
7072
}
7173

72-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsTrueFalseNullStandaloneType(), 'the standalone "true" type', $innerType);
74+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsTrueFalseNullStandaloneType(), 'the standalone "true" type', $innerType);
7375
}
7476
}
7577

7678
if ($node instanceof Node\Stmt\Class_ && ($node->flags & Modifiers::READONLY) !== 0) {
77-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsReadOnlyClasses(), 'readonly classes', $node);
79+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsReadOnlyClasses(), 'readonly classes', $node);
7880
}
7981

8082
if ($node instanceof Node\Stmt\Property && ($node->flags & Modifiers::READONLY) !== 0) {
81-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsReadOnlyProperties(), 'readonly properties', $node);
83+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsReadOnlyProperties(), 'readonly properties', $node);
8284
}
8385

8486
if ($node instanceof Node\Param && $node->flags !== 0) {
85-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsPromotedProperties(), 'promoted properties', $node);
87+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsPromotedProperties(), 'promoted properties', $node);
8688
}
8789

8890
if ($node instanceof Node\Param && ($node->flags & Modifiers::READONLY) !== 0) {
89-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsReadOnlyProperties(), 'readonly promoted properties', $node);
91+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsReadOnlyProperties(), 'readonly promoted properties', $node);
9092
}
9193

9294
if (
9395
($node instanceof Node\Param || $node instanceof Node\Stmt\Property)
9496
&& ($node->flags & Modifiers::VISIBILITY_SET_MASK) !== 0
9597
) {
96-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsAsymmetricVisibility(), 'asymmetric visibility', $node);
98+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsAsymmetricVisibility(), 'asymmetric visibility', $node);
9799
}
98100

99101
if ($node instanceof Node\Stmt\ClassConst && $node->type !== null) {
100-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsNativeTypesInClassConstants(), 'typed class constants', $node);
102+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsNativeTypesInClassConstants(), 'typed class constants', $node);
101103
}
102104

103105
if ($node instanceof Node\Expr\ClassConstFetch && $node->name instanceof Node\Expr) {
104-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsDynamicClassConstantFetch(), 'dynamic class constant fetch', $node);
106+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsDynamicClassConstantFetch(), 'dynamic class constant fetch', $node);
105107
}
106108

107109
if (
@@ -112,14 +114,14 @@ public function enterNode(Node $node): ?Node
112114
) {
113115
foreach ($node->args as $arg) {
114116
if ($arg instanceof Node\VariadicPlaceholder) {
115-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsFirstClassCallables(), 'first-class callable syntax', $arg);
117+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsFirstClassCallables(), 'first-class callable syntax', $arg);
116118
break;
117119
}
118120
}
119121
}
120122

121123
if ($node instanceof Node\Arg && $node->name !== null) {
122-
$this->require(fn(PhpVersion $phpVersion) => $phpVersion->supportsNamedArguments(), 'named arguments', $node);
124+
$this->require(static fn (PhpVersion $phpVersion) => $phpVersion->supportsNamedArguments(), 'named arguments', $node);
123125
}
124126

125127
$this->checkStandaloneType($node);
@@ -140,9 +142,9 @@ private function checkStandaloneType(Node $node): void
140142
}
141143

142144
$this->require(
143-
fn(PhpVersion $phpVersion) => $phpVersion->supportsTrueFalseNullStandaloneType(),
145+
static fn (PhpVersion $phpVersion) => $phpVersion->supportsTrueFalseNullStandaloneType(),
144146
'standalone "null", "false" or "true" types',
145-
$type
147+
$type,
146148
);
147149
}
148150

@@ -158,9 +160,9 @@ private function checkMixedType(Node $node): void
158160
}
159161

160162
$this->require(
161-
fn(PhpVersion $phpVersion) => $phpVersion->supportsNativeMixed(),
163+
static fn (PhpVersion $phpVersion) => $phpVersion->supportsNativeMixed(),
162164
'the mixed type',
163-
$type
165+
$type,
164166
);
165167
}
166168

@@ -209,16 +211,16 @@ private function findPhpVersion(callable $callable): int
209211
{
210212
$minorVersionIterator = new PhpMinorVersionIterator(
211213
new PhpVersion(70400),
212-
new PhpVersion(80500)
214+
new PhpVersion(80500),
213215
);
214216

215-
foreach($minorVersionIterator as $phpVersion) {
217+
foreach ($minorVersionIterator as $phpVersion) {
216218
if ($callable($phpVersion)) {
217219
return $phpVersion->getVersionId();
218220
}
219221
}
220222

221-
throw new \PHPStan\ShouldNotHappenException();
223+
throw new ShouldNotHappenException();
222224
}
223225

224226
}

‎build/PHPStan/Build/ServiceLocatorDynamicReturnTypeExtension.php‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22

33
namespace PHPStan\Build;
44

5+
use Nette\DI\Container;
56
use PhpParser\Node\Expr\MethodCall;
67
use PHPStan\Analyser\Scope;
78
use PHPStan\Reflection\MethodReflection;
89
use PHPStan\Reflection\ParametersAcceptorSelector;
10+
use PHPStan\Type\DynamicMethodReturnTypeExtension;
911
use PHPStan\Type\Type;
1012
use PHPStan\Type\TypeCombinator;
13+
use function count;
14+
use function in_array;
1115

12-
final class ServiceLocatorDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension
16+
final class ServiceLocatorDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
1317
{
1418

1519
public function getClass(): string
1620
{
17-
return \Nette\DI\Container::class;
21+
return Container::class;
1822
}
1923

2024
public function isMethodSupported(MethodReflection $methodReflection): bool

‎build/PHPStan/Build/SkipTestsWithRequiresPhpAttributeRule.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,4 @@ public function processNode(Node $node, Scope $scope): array
126126
];
127127
}
128128

129-
130129
}

‎build/generate-turbo-stubs.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php declare(strict_types = 1);
22

3+
use PHPStan\Build\TurboAttributeCollector;
4+
35
/**
46
* Generates three files from the ShadowedByTurboExtension and
57
* ReferencedByTurboExtension attributes on every autoloader dump
@@ -41,7 +43,7 @@
4143
require_once $root . '/vendor/autoload.php';
4244
require_once __DIR__ . '/PHPStan/Build/TurboAttributeCollector.php';
4345

44-
$collector = new PHPStan\Build\TurboAttributeCollector($root);
46+
$collector = new TurboAttributeCollector($root);
4547
$collected = $collector->collect();
4648

4749
file_put_contents($root . '/vendor/turbo-stubs.php', $collector->renderStubs($collected['pairs']));

0 commit comments

Comments
 (0)