Skip to content

Commit ba61b94

Browse files
Merge pull request #91 from oliverklee/cleanup/autoformat-php
[CLEANUP] Autoformat the PHP files with PhpStorm
2 parents cd62414 + cff1390 commit ba61b94

21 files changed

+79
-32
lines changed

src/Helpers/Typo3ClassNamingUtilityTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ trait Typo3ClassNamingUtilityTrait
1515

1616
/**
1717
* @param class-string $repositoryClassName
18+
*
1819
* @return class-string
1920
*/
2021
protected function translateRepositoryNameToModelName(string $repositoryClassName): string

src/Reflection/RepositoryFindMethodsClassReflectionExtension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ public function hasMethod(ClassReflection $classReflection, string $methodName):
5959
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
6060
{
6161
if (strpos($methodName, 'findOneBy') === 0) {
62-
$methodReflection = new RepositoryFindOneByMethodReflection($classReflection, $methodName, $this->reflectionProvider);
62+
$methodReflection
63+
= new RepositoryFindOneByMethodReflection($classReflection, $methodName, $this->reflectionProvider);
6364
} else {
64-
$methodReflection = new RepositoryFindByMethodReflection($classReflection, $methodName, $this->reflectionProvider);
65+
$methodReflection
66+
= new RepositoryFindByMethodReflection($classReflection, $methodName, $this->reflectionProvider);
6567
}
6668

6769
return $methodReflection;

src/Rule/RequestAttributeValidationRule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public function processNode(Node $node, Scope $scope): array
4242

4343
$declaringClass = $methodReflection->getDeclaringClass();
4444

45-
if (!$declaringClass->implementsInterface(ServerRequestInterface::class) && $declaringClass->getName() !== ServerRequestInterface::class) {
45+
if (!$declaringClass->implementsInterface(ServerRequestInterface::class)
46+
&& $declaringClass->getName() !== ServerRequestInterface::class) {
4647
return [];
4748
}
4849

src/Rule/ValidatorResolverOptionsRule.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ final class ValidatorResolverOptionsRule implements Rule
3737
/** @var ValidatorClassNameResolver */
3838
private $validatorClassNameResolver;
3939

40-
public function __construct(InitializerExprTypeResolver $initializerExprTypeResolver, ValidatorClassNameResolver $validatorClassNameResolver)
40+
public function __construct(
41+
InitializerExprTypeResolver $initializerExprTypeResolver,
42+
ValidatorClassNameResolver $validatorClassNameResolver
43+
)
4144
{
4245
$this->initializerExprTypeResolver = $initializerExprTypeResolver;
4346
$this->validatorClassNameResolver = $validatorClassNameResolver;
@@ -88,7 +91,7 @@ public function processNode(Node $node, Scope $scope): array
8891
$validatorObjectType = new ObjectType($validatorClassName);
8992
$validatorClassReflection = $validatorObjectType->getClassReflection();
9093

91-
if ( ! $validatorClassReflection instanceof ClassReflection) {
94+
if (!$validatorClassReflection instanceof ClassReflection) {
9295
return [];
9396
}
9497

@@ -106,7 +109,8 @@ public function processNode(Node $node, Scope $scope): array
106109
$providedOptionsArray = $this->extractProvidedOptions($validatorOptionsArgument, $scope);
107110

108111
$unsupportedOptions = array_diff($providedOptionsArray, $validatorOptionsConfiguration->getSupportedOptions());
109-
$neededRequiredOptions = array_diff($validatorOptionsConfiguration->getRequiredOptions(), $providedOptionsArray);
112+
$neededRequiredOptions
113+
= array_diff($validatorOptionsConfiguration->getRequiredOptions(), $providedOptionsArray);
110114

111115
$errors = [];
112116

@@ -134,7 +138,7 @@ private function shouldSkip(MethodCall $methodCall, Scope $scope): bool
134138
return true;
135139
}
136140

137-
if ( ! $methodCall->name instanceof Node\Identifier) {
141+
if (!$methodCall->name instanceof Node\Identifier) {
138142
return true;
139143
}
140144

@@ -146,22 +150,22 @@ private function shouldSkip(MethodCall $methodCall, Scope $scope): bool
146150
*/
147151
private function extractProvidedOptions(?Arg $validatorOptionsArgument, Scope $scope): array
148152
{
149-
if ( ! $validatorOptionsArgument instanceof Arg) {
153+
if (!$validatorOptionsArgument instanceof Arg) {
150154
return [];
151155
}
152156

153157
$providedOptionsArray = [];
154158

155159
$validatorOptionsArgumentType = $scope->getType($validatorOptionsArgument->value);
156160

157-
if ( ! $validatorOptionsArgumentType instanceof ConstantArrayType) {
161+
if (!$validatorOptionsArgumentType instanceof ConstantArrayType) {
158162
return [];
159163
}
160164

161165
$keysArray = $validatorOptionsArgumentType->getKeysArray();
162166

163167
foreach ($keysArray->getValueTypes() as $valueType) {
164-
if ( ! ($valueType instanceof ConstantStringType)) {
168+
if (!($valueType instanceof ConstantStringType)) {
165169
continue;
166170
}
167171

@@ -171,24 +175,27 @@ private function extractProvidedOptions(?Arg $validatorOptionsArgument, Scope $s
171175
return $providedOptionsArray;
172176
}
173177

174-
private function extractValidatorOptionsConfiguration(PropertyReflection $supportedOptions, Scope $scope): ValidatorOptionsConfiguration
178+
private function extractValidatorOptionsConfiguration(
179+
PropertyReflection $supportedOptions,
180+
Scope $scope
181+
): ValidatorOptionsConfiguration
175182
{
176183
$collectedSupportedOptions = [];
177184
$collectedRequiredOptions = [];
178185

179-
if ( ! $supportedOptions instanceof PhpPropertyReflection) {
186+
if (!$supportedOptions instanceof PhpPropertyReflection) {
180187
return ValidatorOptionsConfiguration::empty();
181188
}
182189

183190
$defaultValues = $supportedOptions->getNativeReflection()->getDefaultValueExpr();
184191

185-
if ( ! $defaultValues instanceof Array_) {
192+
if (!$defaultValues instanceof Array_) {
186193
return ValidatorOptionsConfiguration::empty();
187194
}
188195

189196
foreach ($defaultValues->items as $defaultValue) {
190197

191-
if ( ! $defaultValue instanceof ArrayItem) {
198+
if (!$defaultValue instanceof ArrayItem) {
192199
continue;
193200
}
194201

@@ -205,11 +212,11 @@ private function extractValidatorOptionsConfiguration(PropertyReflection $suppor
205212
$collectedSupportedOptions[] = $supportedOptionKey;
206213

207214
$optionDefinition = $defaultValue->value;
208-
if ( ! $optionDefinition instanceof Array_) {
215+
if (!$optionDefinition instanceof Array_) {
209216
continue;
210217
}
211218

212-
if ( ! isset($optionDefinition->items[3])) {
219+
if (!isset($optionDefinition->items[3])) {
213220
continue;
214221
}
215222

@@ -229,7 +236,11 @@ private function extractValidatorOptionsConfiguration(PropertyReflection $suppor
229236
return new ValidatorOptionsConfiguration($collectedSupportedOptions, $collectedRequiredOptions);
230237
}
231238

232-
private function resolveOptionKeyValue(ArrayItem $defaultValue, PhpPropertyReflection $supportedOptions, Scope $scope): ?string
239+
private function resolveOptionKeyValue(
240+
ArrayItem $defaultValue,
241+
PhpPropertyReflection $supportedOptions,
242+
Scope $scope
243+
): ?string
233244
{
234245
if ($defaultValue->key === null) {
235246
return null;

src/Service/ValidatorClassNameResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class ValidatorClassNameResolver
1010

1111
public function resolve(Type $type): ?string
1212
{
13-
if ( ! $type instanceof ConstantStringType) {
13+
if (!$type instanceof ConstantStringType) {
1414
return null;
1515
}
1616

src/Type/PropertyMapperReturnTypeExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
4141
return $methodReflection->getName() === 'convert';
4242
}
4343

44-
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type
44+
public function getTypeFromMethodCall(
45+
MethodReflection $methodReflection,
46+
MethodCall $methodCall,
47+
Scope $scope
48+
): ?Type
4549
{
4650
$targetTypeArgument = $methodCall->getArgs()[1] ?? null;
4751

@@ -95,7 +99,7 @@ private function createTypeFromClassNameString(String_ $node): ?Type
9599
return null;
96100
}
97101

98-
if (! $this->reflectionProvider->hasClass($classLikeName)) {
102+
if (!$this->reflectionProvider->hasClass($classLikeName)) {
99103
return null;
100104
}
101105

src/Type/RepositoryDynamicReturnTypeExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public function getTypeFromMethodCall(
3737
{
3838
$variableType = $scope->getType($methodCall->var);
3939

40-
if (!($variableType instanceof ObjectType) || !is_subclass_of($variableType->getClassName(), $this->getClass())) {
40+
if (!($variableType instanceof ObjectType)
41+
|| !is_subclass_of($variableType->getClassName(), $this->getClass())) {
4142
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
4243
}
4344

src/Type/RepositoryFindAllDynamicReturnTypeExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public function getTypeFromMethodCall(
4040
{
4141
$variableType = $scope->getType($methodCall->var);
4242

43-
if ($methodReflection->getDeclaringClass()->getName() !== Repository::class || !$variableType instanceof TypeWithClassName) {
43+
if ($methodReflection->getDeclaringClass()->getName() !== Repository::class
44+
|| !$variableType instanceof TypeWithClassName) {
4445
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
4546
}
4647

stubs/DomainObjectInterface.stub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace TYPO3\CMS\Extbase\DomainObject;
34

45
interface DomainObjectInterface

tests/Unit/Rule/ValidatorResolverOptionsRule/ValidatorResolverOptionsRuleTest.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ final class ValidatorResolverOptionsRuleTest extends RuleTestCase
1414

1515
/**
1616
* @dataProvider provideDataWithErrors()
17+
*
1718
* @param list<array{0: string, 1: int, 2?: string}> $expectedErrorMessagesWithLines
1819
*/
1920
public function testRuleWithErrors(string $filePath, array $expectedErrorMessagesWithLines): void
@@ -32,7 +33,8 @@ public function provideDataWithErrors(): \Iterator
3233
__DIR__ . '/Fixture/CreateValidatorWithUnresolvableType.php',
3334
[
3435
[
35-
'Could not create validator for "Foo"', 13,
36+
'Could not create validator for "Foo"',
37+
13,
3638
],
3739
],
3840
];
@@ -41,10 +43,12 @@ public function provideDataWithErrors(): \Iterator
4143
__DIR__ . '/Fixture/CreateValidatorWithMissingRequiredOption.php',
4244
[
4345
[
44-
'Required validation option not set: regularExpression', 14,
46+
'Required validation option not set: regularExpression',
47+
14,
4548
],
4649
[
47-
'Required validation option not set: regularExpression', 19,
50+
'Required validation option not set: regularExpression',
51+
19,
4852
],
4953
],
5054
];
@@ -53,13 +57,16 @@ public function provideDataWithErrors(): \Iterator
5357
__DIR__ . '/Fixture/CreateValidatorWithNonExistingOption.php',
5458
[
5559
[
56-
'Unsupported validation option(s) found: non-existing-option', 16,
60+
'Unsupported validation option(s) found: non-existing-option',
61+
16,
5762
],
5863
[
59-
'Unsupported validation option(s) found: foo', 24,
64+
'Unsupported validation option(s) found: foo',
65+
24,
6066
],
6167
[
62-
'Unsupported validation option(s) found: minmum', 29,
68+
'Unsupported validation option(s) found: minmum',
69+
29,
6370
],
6471
],
6572
];

0 commit comments

Comments
 (0)