Skip to content

Commit ec4e0cb

Browse files
teohhanhuidunglas
authored andcommitted
Update PHP-CS-Fixer rules (#2005)
* Update PHP-CS-Fixer rules * Fix files with PHP-CS-Fixer (array_indentation)
1 parent 9a64d15 commit ec4e0cb

File tree

14 files changed

+128
-119
lines changed

14 files changed

+128
-119
lines changed

.php_cs.dist

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ return PhpCsFixer\Config::create()
2323
'@PHPUnit60Migration:risky' => true,
2424
'@Symfony' => true,
2525
'@Symfony:risky' => true,
26+
'align_multiline_comment' => [
27+
'comment_type' => 'phpdocs_only',
28+
],
29+
'array_indentation' => true,
2630
'array_syntax' => [
2731
'syntax' => 'short',
2832
],
@@ -41,7 +45,6 @@ return PhpCsFixer\Config::create()
4145
'header' => $header,
4246
'location' => 'after_open',
4347
],
44-
'modernize_types_casting' => true,
4548
'native_function_invocation' => [
4649
'include' => [
4750
'@compiler_optimized',
@@ -62,10 +65,16 @@ return PhpCsFixer\Config::create()
6265
],
6366
'no_useless_else' => true,
6467
'no_useless_return' => true,
65-
'ordered_imports' => true,
68+
'ordered_imports' => [
69+
'importsOrder' => [
70+
'class',
71+
'function',
72+
'const',
73+
],
74+
'sortAlgorithm' => 'alpha',
75+
],
6676
'phpdoc_order' => true,
67-
'psr4' => true,
68-
'semicolon_after_instruction' => true,
77+
// 'simplified_null_return' => true,
6978
'strict_comparison' => true,
7079
'strict_param' => true,
7180
'ternary_to_null_coalescing' => true,

src/Bridge/Doctrine/Orm/Filter/SearchFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
216216

217217
if (!$this->hasValidValues($values, $this->getDoctrineFieldType($property, $resourceClass))) {
218218
$this->logger->notice('Invalid filter ignored', [
219-
'exception' => new InvalidArgumentException(sprintf('Values for field "%s" are not valid according to the doctrine type.', $field)),
219+
'exception' => new InvalidArgumentException(sprintf('Values for field "%s" are not valid according to the doctrine type.', $field)),
220220
]);
221221

222222
return;
@@ -261,7 +261,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
261261

262262
if (!$this->hasValidValues($values, $this->getDoctrineFieldType($property, $resourceClass))) {
263263
$this->logger->notice('Invalid filter ignored', [
264-
'exception' => new InvalidArgumentException(sprintf('Values for field "%s" are not valid according to the doctrine type.', $field)),
264+
'exception' => new InvalidArgumentException(sprintf('Values for field "%s" are not valid according to the doctrine type.', $field)),
265265
]);
266266

267267
return;

tests/Bridge/Doctrine/Orm/Filter/BooleanFilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function provideApplyTestData(): array
131131
'dummyBoolean' => null,
132132
],
133133
[
134-
'name' => '1',
134+
'name' => '1',
135135
],
136136
sprintf('SELECT o FROM %s o', Dummy::class),
137137
],

tests/Bridge/Doctrine/Orm/Filter/NumericFilterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public function provideApplyTestData(): array
128128
'dummyPrice' => null,
129129
],
130130
[
131-
'dummyPrice' => 10,
132-
'name' => '15toto',
131+
'dummyPrice' => 10,
132+
'name' => '15toto',
133133
],
134134
sprintf('SELECT o FROM %s o WHERE o.dummyPrice = :dummyPrice_p1', Dummy::class),
135135
],

tests/Bridge/Symfony/Bundle/DependencyInjection/ConfigurationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,15 @@ public function testExceptionToStatusConfigWithInvalidHttpStatusCodeValue($inval
239239
public function testApiKeysConfig()
240240
{
241241
$exampleConfig = [
242-
'name' => 'Authorization',
243-
'type' => 'query',
242+
'name' => 'Authorization',
243+
'type' => 'query',
244244
];
245245

246246
$config = $this->processor->processConfiguration($this->configuration, [
247247
'api_platform' => [
248248
'swagger' => [
249249
'api_keys' => [$exampleConfig],
250-
],
250+
],
251251
],
252252
]);
253253

tests/Hal/Serializer/CollectionNormalizerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ public function testNormalizePaginator()
6161
'prev' => ['href' => '/?page=2'],
6262
'next' => ['href' => '/?page=4'],
6363
'item' => [
64-
'/me',
65-
],
64+
'/me',
65+
],
6666
],
6767
'_embedded' => [
68-
'item' => [
69-
[
70-
'_links' => [
71-
'self' => '/me',
72-
],
73-
'name' => 'Kévin',
68+
'item' => [
69+
[
70+
'_links' => [
71+
'self' => '/me',
7472
],
73+
'name' => 'Kévin',
7574
],
75+
],
7676
],
7777
'totalItems' => 1312,
7878
'itemsPerPage' => 12,

tests/Hydra/Serializer/ConstraintViolationNormalizerTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ public function testNormalize()
6666
'hydra:description' => '_d: a
6767
_4: 1',
6868
'violations' => [
69-
[
70-
'propertyPath' => '_d',
71-
'message' => 'a',
72-
'payload' => [
73-
'severity' => 'warning',
74-
],
75-
],
76-
[
77-
'propertyPath' => '_4',
78-
'message' => '1',
69+
[
70+
'propertyPath' => '_d',
71+
'message' => 'a',
72+
'payload' => [
73+
'severity' => 'warning',
7974
],
8075
],
76+
[
77+
'propertyPath' => '_4',
78+
'message' => '1',
79+
],
80+
],
8181
];
8282
$this->assertEquals($expected, $normalizer->normalize($list));
8383
}

tests/Hydra/Serializer/ItemNormalizerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ public function testNormalize()
119119
$normalizer->setSerializer($serializerProphecy->reveal());
120120

121121
$expected = ['@context' => '/contexts/Dummy',
122-
'@id' => '/dummies/1988',
123-
'@type' => 'Dummy',
124-
'name' => 'hello',
122+
'@id' => '/dummies/1988',
123+
'@type' => 'Dummy',
124+
'name' => 'hello',
125125
];
126126
$this->assertEquals($expected, $normalizer->normalize($dummy));
127127
}

tests/Metadata/Resource/Factory/FileConfigurationMetadataFactoryProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public function legacyOperationsResourceMetadataProvider()
101101
{
102102
$resourceMetadata = new ResourceMetadata();
103103
$resourceMetadata = $resourceMetadata->withItemOperations([
104-
'my_op_name' => ['method' => 'POST'],
105-
'my_other_op_name' => ['method' => 'GET'],
104+
'my_op_name' => ['method' => 'POST'],
105+
'my_other_op_name' => ['method' => 'GET'],
106106
]);
107107
$resourceMetadata = $resourceMetadata->withCollectionOperations([
108108
'my_op_name' => ['method' => 'POST'],

tests/Operation/Factory/SubresourceOperationFactoryTest.php

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,17 @@ public function testCreateWithMaxDepth()
291291

292292
$this->assertEquals([
293293
'api_dummy_entities_subresource_get_subresource' => [
294-
'property' => 'subresource',
295-
'collection' => false,
296-
'resource_class' => RelatedDummyEntity::class,
297-
'shortNames' => ['relatedDummyEntity', 'dummyEntity'],
298-
'identifiers' => [
299-
['id', DummyEntity::class, true],
300-
],
301-
'route_name' => 'api_dummy_entities_subresource_get_subresource',
302-
'path' => '/dummy_entities/{id}/subresource.{_format}',
303-
'operation_name' => 'subresource_get_subresource',
304-
] + SubresourceOperationFactory::ROUTE_OPTIONS,
294+
'property' => 'subresource',
295+
'collection' => false,
296+
'resource_class' => RelatedDummyEntity::class,
297+
'shortNames' => ['relatedDummyEntity', 'dummyEntity'],
298+
'identifiers' => [
299+
['id', DummyEntity::class, true],
300+
],
301+
'route_name' => 'api_dummy_entities_subresource_get_subresource',
302+
'path' => '/dummy_entities/{id}/subresource.{_format}',
303+
'operation_name' => 'subresource_get_subresource',
304+
] + SubresourceOperationFactory::ROUTE_OPTIONS,
305305
], $subresourceOperationFactory->create(DummyEntity::class));
306306
}
307307

@@ -336,30 +336,30 @@ public function testCreateWithEnd()
336336
$result = $subresourceOperationFactory->create(DummyEntity::class);
337337
$this->assertEquals([
338338
'api_dummy_entities_subresources_get_subresource' => [
339-
'property' => 'subresource',
340-
'collection' => true,
341-
'resource_class' => RelatedDummyEntity::class,
342-
'shortNames' => ['relatedDummyEntity', 'dummyEntity'],
343-
'identifiers' => [
344-
['id', DummyEntity::class, true],
345-
],
346-
'route_name' => 'api_dummy_entities_subresources_get_subresource',
347-
'path' => '/dummy_entities/{id}/subresource.{_format}',
348-
'operation_name' => 'subresources_get_subresource',
349-
] + SubresourceOperationFactory::ROUTE_OPTIONS,
350-
'api_dummy_entities_subresources_item_get_subresource' => [
351-
'property' => 'id',
352-
'collection' => false,
353-
'resource_class' => DummyEntity::class,
354-
'shortNames' => ['dummyEntity', 'relatedDummyEntity'],
355-
'identifiers' => [
356-
['id', DummyEntity::class, true],
357-
['subresource', RelatedDummyEntity::class, true],
358-
],
359-
'route_name' => 'api_dummy_entities_subresources_item_get_subresource',
360-
'path' => '/dummy_entities/{id}/subresource/{subresource}.{_format}',
361-
'operation_name' => 'subresources_item_get_subresource',
362-
] + SubresourceOperationFactory::ROUTE_OPTIONS,
339+
'property' => 'subresource',
340+
'collection' => true,
341+
'resource_class' => RelatedDummyEntity::class,
342+
'shortNames' => ['relatedDummyEntity', 'dummyEntity'],
343+
'identifiers' => [
344+
['id', DummyEntity::class, true],
345+
],
346+
'route_name' => 'api_dummy_entities_subresources_get_subresource',
347+
'path' => '/dummy_entities/{id}/subresource.{_format}',
348+
'operation_name' => 'subresources_get_subresource',
349+
] + SubresourceOperationFactory::ROUTE_OPTIONS,
350+
'api_dummy_entities_subresources_item_get_subresource' => [
351+
'property' => 'id',
352+
'collection' => false,
353+
'resource_class' => DummyEntity::class,
354+
'shortNames' => ['dummyEntity', 'relatedDummyEntity'],
355+
'identifiers' => [
356+
['id', DummyEntity::class, true],
357+
['subresource', RelatedDummyEntity::class, true],
358+
],
359+
'route_name' => 'api_dummy_entities_subresources_item_get_subresource',
360+
'path' => '/dummy_entities/{id}/subresource/{subresource}.{_format}',
361+
'operation_name' => 'subresources_item_get_subresource',
362+
] + SubresourceOperationFactory::ROUTE_OPTIONS,
363363
], $result);
364364
}
365365

@@ -394,17 +394,17 @@ public function testCreateWithEndButNoCollection()
394394
$result = $subresourceOperationFactory->create(DummyEntity::class);
395395
$this->assertEquals([
396396
'api_dummy_entities_subresource_get_subresource' => [
397-
'property' => 'subresource',
398-
'collection' => false,
399-
'resource_class' => RelatedDummyEntity::class,
400-
'shortNames' => ['relatedDummyEntity', 'dummyEntity'],
401-
'identifiers' => [
402-
['id', DummyEntity::class, true],
403-
],
404-
'route_name' => 'api_dummy_entities_subresource_get_subresource',
405-
'path' => '/dummy_entities/{id}/subresource.{_format}',
406-
'operation_name' => 'subresource_get_subresource',
407-
] + SubresourceOperationFactory::ROUTE_OPTIONS,
397+
'property' => 'subresource',
398+
'collection' => false,
399+
'resource_class' => RelatedDummyEntity::class,
400+
'shortNames' => ['relatedDummyEntity', 'dummyEntity'],
401+
'identifiers' => [
402+
['id', DummyEntity::class, true],
403+
],
404+
'route_name' => 'api_dummy_entities_subresource_get_subresource',
405+
'path' => '/dummy_entities/{id}/subresource.{_format}',
406+
'operation_name' => 'subresource_get_subresource',
407+
] + SubresourceOperationFactory::ROUTE_OPTIONS,
408408
], $result);
409409
}
410410
}

0 commit comments

Comments
 (0)