Skip to content

Commit 6231236

Browse files
committed
cs
1 parent 1d0c17a commit 6231236

12 files changed

Lines changed: 57 additions & 55 deletions

File tree

ecs.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
use Symplify\EasyCodingStandard\Config\ECSConfig;
66

77
return ECSConfig::configure()
8-
->withPaths([
9-
__DIR__ . '/config',
10-
__DIR__ . '/src',
11-
__DIR__ . '/tests',
12-
])
8+
->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests'])
139
->withRootFiles()
14-
->withPreparedSets(psr12: true, common: true)
15-
->withSkip([
16-
'*/Source/*',
17-
'*/Fixture/*',
18-
]);
10+
->withPreparedSets(psr12: true, common: true, symplify: true)
11+
->withSkip(['*/Source/*', '*/Fixture/*']);

rector.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
naming: true,
1717
earlyReturn: true
1818
)
19-
->withPaths([
20-
__DIR__ . '/config',
21-
__DIR__ . '/src',
22-
__DIR__ . '/tests',
23-
])
19+
->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests'])
2420
->withImportNames(removeUnusedImports: true)
25-
->withSkip([
26-
'*/Source/*',
27-
'*/Fixture/*',
28-
]);
21+
->withSkip(['*/Source/*', '*/Fixture/*']);

src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public function processNode(Node $node, Scope $scope): ?array
7171
return null;
7272
}
7373

74-
$printedParamTypesString = $this->collectorMetadataPrinter->printParamTypesToString($node, $classReflection->getName());
74+
$printedParamTypesString = $this->collectorMetadataPrinter->printParamTypesToString(
75+
$node,
76+
$classReflection->getName()
77+
);
7578
return [$classReflection->getName(), $methodName, $printedParamTypesString, $node->getLine()];
7679
}
7780
}

src/Collector/MethodCall/MethodCallArgTypesCollector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public function processNode(Node $node, Scope $scope): ?array
5959

6060
$classMethodReference = $this->createClassMethodReference($classMethodCallReference);
6161

62-
$stringArgTypesString = $this->collectorMetadataPrinter->printArgTypesAsString($node, $methodReflection, $scope);
62+
$stringArgTypesString = $this->collectorMetadataPrinter->printArgTypesAsString(
63+
$node,
64+
$methodReflection,
65+
$scope
66+
);
6367
return [$classMethodReference, $stringArgTypesString];
6468
}
6569

src/Matcher/ClassMethodCallReferenceResolver.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414

1515
final class ClassMethodCallReferenceResolver
1616
{
17-
public function resolve(MethodCall|MethodCallableNode $methodCallOrMethodCallable, Scope $scope, bool $allowThisType): ?MethodCallReference
18-
{
17+
public function resolve(
18+
MethodCall|MethodCallableNode $methodCallOrMethodCallable,
19+
Scope $scope,
20+
bool $allowThisType
21+
): ?MethodCallReference {
1922
if ($methodCallOrMethodCallable instanceof MethodCallableNode) {
2023
$methodName = $methodCallOrMethodCallable->getName();
2124
$variable = $methodCallOrMethodCallable->getVar();

src/Matcher/Collector/PublicClassMethodMatcher.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ final class PublicClassMethodMatcher
1313
/**
1414
* @var string[]
1515
*/
16-
private const SKIPPED_TYPES = ['PHPUnit\Framework\TestCase', 'Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator'];
16+
private const SKIPPED_TYPES = [
17+
'PHPUnit\Framework\TestCase',
18+
'Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator',
19+
];
1720

1821
public function shouldSkipClassReflection(ClassReflection $classReflection): bool
1922
{

src/Printer/CollectorMetadataPrinter.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@ public function __construct(
3838
$this->standard = new Standard();
3939
}
4040

41-
public function printArgTypesAsString(MethodCall $methodCall, ExtendedMethodReflection $extendedMethodReflection, Scope $scope): string
42-
{
43-
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $extendedMethodReflection->getVariants(), $extendedMethodReflection->getNamedArgumentsVariants());
41+
public function printArgTypesAsString(
42+
MethodCall $methodCall,
43+
ExtendedMethodReflection $extendedMethodReflection,
44+
Scope $scope
45+
): string {
46+
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
47+
$scope,
48+
$methodCall->getArgs(),
49+
$extendedMethodReflection->getVariants(),
50+
$extendedMethodReflection->getNamedArgumentsVariants()
51+
);
4452
$parameters = $parametersAcceptor->getParameters();
4553

4654
$stringArgTypes = [];
@@ -126,8 +134,10 @@ private function transformSelfToClassName(Node $node, ?string $className): Node
126134
return new FullyQualified($className);
127135
}
128136

129-
private function resolveSortedTypes(UnionType|NodeIntersectionType $paramType, ?string $className): UnionType|NodeIntersectionType
130-
{
137+
private function resolveSortedTypes(
138+
UnionType|NodeIntersectionType $paramType,
139+
?string $className
140+
): UnionType|NodeIntersectionType {
131141
$typeNames = [];
132142

133143
foreach ($paramType->types as $type) {
@@ -183,7 +193,8 @@ private function printTypeToString(Type $type): string
183193
}
184194

185195
if (count($type->getEnumCases()) === 1) {
186-
return $type->getEnumCases()[0]->getClassName();
196+
return $type->getEnumCases()[0]
197+
->getClassName();
187198
}
188199

189200
return $type->describe(VerbosityLevel::typeOnly());

src/Rules/NarrowReturnObjectTypeRule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ private function shouldSkipReturnExprType(Type $type): bool
137137
return true;
138138
}
139139

140-
return $type->getObjectClassReflections()[0]->isAnonymous();
140+
return $type->getObjectClassReflections()[0]
141+
->isAnonymous();
141142
}
142143
}

src/Rules/NoArrayAccessOnObjectRule.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ final class NoArrayAccessOnObjectRule implements Rule
2626
/**
2727
* @var string[]
2828
*/
29-
private const ALLOWED_CLASSES = ['SplFixedArray', 'SimpleXMLElement', 'Iterator', 'Aws\ResultInterface', 'Symfony\Component\Form\FormInterface', 'Symfony\Component\OptionsResolver\Options'];
29+
private const ALLOWED_CLASSES = [
30+
'SplFixedArray',
31+
'SimpleXMLElement',
32+
'Iterator',
33+
'Aws\ResultInterface',
34+
'Symfony\Component\Form\FormInterface',
35+
'Symfony\Component\OptionsResolver\Options',
36+
];
3037

3138
/**
3239
* @return class-string<Node>

tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,26 +146,16 @@ public static function provideData(): Iterator
146146
__DIR__ . '/Source/ExpectedThisType/CallByThisFromInterface.php',
147147
], [[$argErrorMessage, 11]]];
148148

149-
yield [[
150-
__DIR__ . '/Fixture/SkipSelf.php',
151-
], []];
149+
yield [[__DIR__ . '/Fixture/SkipSelf.php'], []];
152150

153-
yield [[
154-
__DIR__ . '/Fixture/SkipClosure.php',
155-
], []];
151+
yield [[__DIR__ . '/Fixture/SkipClosure.php'], []];
156152

157-
yield [[
158-
__DIR__ . '/Fixture/SkipCallable.php',
159-
], []];
153+
yield [[__DIR__ . '/Fixture/SkipCallable.php'], []];
160154

161-
yield [[
162-
__DIR__ . '/Fixture/SkipEnum.php',
163-
], []];
155+
yield [[__DIR__ . '/Fixture/SkipEnum.php'], []];
164156

165157
$argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'int');
166-
yield [[
167-
__DIR__ . '/Fixture/HandleDefaultValue.php',
168-
], [[$argErrorMessage, 15]]];
158+
yield [[__DIR__ . '/Fixture/HandleDefaultValue.php'], [[$argErrorMessage, 15]]];
169159
}
170160

171161
/**

0 commit comments

Comments
 (0)