Skip to content

Commit 00af99e

Browse files
committed
revert code style & improve ApiPlatformExtensionTest
1 parent f5929a5 commit 00af99e

File tree

226 files changed

+10124
-3688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+10124
-3688
lines changed

src/Action/ExceptionAction.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ public function __invoke($exception, Request $request): Response
7272
$exceptionClass = $exception->getClass();
7373
$statusCode = $exception->getStatusCode();
7474

75-
$exceptionToStatus = array_merge($this->exceptionToStatus, $operation ? $operation->getExceptionToStatus() ?? [] : $this->getOperationExceptionToStatus($request));
75+
$exceptionToStatus = array_merge(
76+
$this->exceptionToStatus,
77+
$operation ? $operation->getExceptionToStatus() ?? [] : $this->getOperationExceptionToStatus($request)
78+
);
7679

7780
foreach ($exceptionToStatus as $class => $status) {
7881
if (is_a($exceptionClass, $class, true)) {
@@ -107,6 +110,9 @@ private function getOperationExceptionToStatus(Request $request): array
107110
throw new \LogicException('"exception_to_status" attribute should be an array.');
108111
}
109112

110-
return array_merge($resourceExceptionToStatus, $operationExceptionToStatus);
113+
return array_merge(
114+
$resourceExceptionToStatus,
115+
$operationExceptionToStatus
116+
);
111117
}
112118
}

src/Bridge/Doctrine/Common/Filter/ExistsFilterTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ abstract protected function normalizePropertyName($property);
7373
private function normalizeValue($value, string $property): ?bool
7474
{
7575
if (\is_array($value) && isset($value[self::QUERY_PARAMETER_KEY])) {
76-
@trigger_error(sprintf('The ExistsFilter syntax "%s[exists]=true/false" is deprecated since 2.5. Use the syntax "%s[%s]=true/false" instead.', $property, $this->existsParameterName, $property), \E_USER_DEPRECATED);
76+
@trigger_error(
77+
sprintf('The ExistsFilter syntax "%s[exists]=true/false" is deprecated since 2.5. Use the syntax "%s[%s]=true/false" instead.', $property, $this->existsParameterName, $property),
78+
\E_USER_DEPRECATED
79+
);
7780
$value = $value[self::QUERY_PARAMETER_KEY];
7881
}
7982

src/Bridge/Doctrine/Orm/State/UriVariablesHandlerTrait.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,35 @@ private function handleUriVariables(QueryBuilder $queryBuilder, array $identifie
3838
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
3939
$joinAlias = $queryNameGenerator->generateJoinAlias($inverseProperty);
4040

41-
$queryBuilder->join($uriVariable->getTargetClass(), $joinAlias, 'with', "$alias.$propertyIdentifier = $joinAlias.$inverseProperty");
41+
$queryBuilder->join(
42+
$uriVariable->getTargetClass(),
43+
$joinAlias,
44+
'with',
45+
"$alias.$propertyIdentifier = $joinAlias.$inverseProperty"
46+
);
4247

43-
$expression = $queryBuilder->expr()->eq("{$joinAlias}.{$propertyIdentifier}", $placeholder);
48+
$expression = $queryBuilder->expr()->eq(
49+
"{$joinAlias}.{$propertyIdentifier}",
50+
$placeholder
51+
);
4452
} elseif ($property = $uriVariable->getProperty()) {
4553
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
4654
$joinAlias = $queryNameGenerator->generateJoinAlias($property);
4755

48-
$queryBuilder->join("$alias.$property", $joinAlias, );
56+
$queryBuilder->join(
57+
"$alias.$property",
58+
$joinAlias,
59+
);
4960

50-
$expression = $queryBuilder->expr()->eq("{$joinAlias}.{$propertyIdentifier}", $placeholder);
61+
$expression = $queryBuilder->expr()->eq(
62+
"{$joinAlias}.{$propertyIdentifier}",
63+
$placeholder
64+
);
5165
} else {
5266
$propertyIdentifier = $uriVariable->getIdentifiers()[0];
53-
$expression = $queryBuilder->expr()->eq("{$alias}.{$propertyIdentifier}", $placeholder);
67+
$expression = $queryBuilder->expr()->eq(
68+
"{$alias}.{$propertyIdentifier}", $placeholder
69+
);
5470
}
5571
$queryBuilder->andWhere($expression);
5672
$queryBuilder->setParameter($placeholder, $value, $doctrineClassMetadata->getTypeOfField($identifier));

src/Core/Annotation/ApiFilter.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ final class ApiFilter
5757
* @param string $id
5858
* @param string $strategy
5959
*/
60-
public function __construct($filterClass, ?string $id = null, ?string $strategy = null, array $properties = [], array $arguments = [])
61-
{
60+
public function __construct(
61+
$filterClass,
62+
?string $id = null,
63+
?string $strategy = null,
64+
array $properties = [],
65+
array $arguments = []
66+
) {
6267
if (\is_array($filterClass)) { /** @phpstan-ignore-line Doctrine annotations */
6368
$options = $filterClass;
6469
$this->filterClass = $options['value'] ?? null;

src/Core/Annotation/ApiProperty.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,33 @@ final class ApiProperty
120120
*
121121
* @throws InvalidArgumentException
122122
*/
123-
public function __construct($description = null, ?bool $readable = null, ?bool $writable = null, ?bool $readableLink = null, ?bool $writableLink = null, ?bool $required = null, ?string $iri = null, ?bool $identifier = null, $default = null, $example = null, // attributes
124-
?array $attributes = null, ?string $deprecationReason = null, ?bool $fetchable = null, ?bool $fetchEager = null, ?array $jsonldContext = null, ?array $openapiContext = null, ?bool $push = null, ?string $security = null, ?array $swaggerContext = null, ?string $securityPostDenormalize = null, ?array $types = [], ?array $builtinTypes = [])
125-
{
123+
public function __construct(
124+
$description = null,
125+
?bool $readable = null,
126+
?bool $writable = null,
127+
?bool $readableLink = null,
128+
?bool $writableLink = null,
129+
?bool $required = null,
130+
?string $iri = null,
131+
?bool $identifier = null,
132+
$default = null,
133+
$example = null,
134+
135+
// attributes
136+
?array $attributes = null,
137+
?string $deprecationReason = null,
138+
?bool $fetchable = null,
139+
?bool $fetchEager = null,
140+
?array $jsonldContext = null,
141+
?array $openapiContext = null,
142+
?bool $push = null,
143+
?string $security = null,
144+
?array $swaggerContext = null,
145+
?string $securityPostDenormalize = null,
146+
147+
?array $types = [],
148+
?array $builtinTypes = []
149+
) {
126150
if (!\is_array($description)) { // @phpstan-ignore-line Doctrine annotations support
127151
[$publicProperties, $configurableAttributes] = self::getConfigMetadata();
128152

src/Core/Annotation/ApiResource.php

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,58 @@ final class ApiResource
181181
*
182182
* @throws InvalidArgumentException
183183
*/
184-
public function __construct($description = null, ?array $collectionOperations = null, ?array $graphql = null, ?string $iri = null, ?array $itemOperations = null, ?string $shortName = null, ?array $subresourceOperations = null, // attributes
185-
?array $attributes = null, ?array $cacheHeaders = null, ?array $denormalizationContext = null, ?string $deprecationReason = null, ?bool $elasticsearch = null, ?bool $fetchPartial = null, ?bool $forceEager = null, ?array $formats = null, ?array $filters = null, ?array $hydraContext = null, $input = null, $mercure = null, $messenger = null, ?array $normalizationContext = null, ?array $openapiContext = null, ?array $order = null, $output = null, ?bool $paginationClientEnabled = null, ?bool $paginationClientItemsPerPage = null, ?bool $paginationClientPartial = null, ?array $paginationViaCursor = null, ?bool $paginationEnabled = null, ?bool $paginationFetchJoinCollection = null, ?int $paginationItemsPerPage = null, ?int $paginationMaximumItemsPerPage = null, ?bool $paginationPartial = null, ?string $routePrefix = null, ?string $security = null, ?string $securityMessage = null, ?string $securityPostDenormalize = null, ?string $securityPostDenormalizeMessage = null, ?string $securityPostValidation = null, ?string $securityPostValidationMessage = null, ?bool $stateless = null, ?string $sunset = null, ?array $swaggerContext = null, ?array $validationGroups = null, ?int $urlGenerationStrategy = null, ?bool $compositeIdentifier = null, ?array $exceptionToStatus = null, ?bool $queryParameterValidationEnabled = null)
186-
{
184+
public function __construct(
185+
$description = null,
186+
?array $collectionOperations = null,
187+
?array $graphql = null,
188+
?string $iri = null,
189+
?array $itemOperations = null,
190+
?string $shortName = null,
191+
?array $subresourceOperations = null,
192+
193+
// attributes
194+
?array $attributes = null,
195+
?array $cacheHeaders = null,
196+
?array $denormalizationContext = null,
197+
?string $deprecationReason = null,
198+
?bool $elasticsearch = null,
199+
?bool $fetchPartial = null,
200+
?bool $forceEager = null,
201+
?array $formats = null,
202+
?array $filters = null,
203+
?array $hydraContext = null,
204+
$input = null,
205+
$mercure = null,
206+
$messenger = null,
207+
?array $normalizationContext = null,
208+
?array $openapiContext = null,
209+
?array $order = null,
210+
$output = null,
211+
?bool $paginationClientEnabled = null,
212+
?bool $paginationClientItemsPerPage = null,
213+
?bool $paginationClientPartial = null,
214+
?array $paginationViaCursor = null,
215+
?bool $paginationEnabled = null,
216+
?bool $paginationFetchJoinCollection = null,
217+
?int $paginationItemsPerPage = null,
218+
?int $paginationMaximumItemsPerPage = null,
219+
?bool $paginationPartial = null,
220+
?string $routePrefix = null,
221+
?string $security = null,
222+
?string $securityMessage = null,
223+
?string $securityPostDenormalize = null,
224+
?string $securityPostDenormalizeMessage = null,
225+
?string $securityPostValidation = null,
226+
?string $securityPostValidationMessage = null,
227+
?bool $stateless = null,
228+
?string $sunset = null,
229+
?array $swaggerContext = null,
230+
?array $validationGroups = null,
231+
?int $urlGenerationStrategy = null,
232+
?bool $compositeIdentifier = null,
233+
?array $exceptionToStatus = null,
234+
?bool $queryParameterValidationEnabled = null
235+
) {
187236
if (!\is_array($description)) { // @phpstan-ignore-line Doctrine annotations support
188237
[$publicProperties, $configurableAttributes] = self::getConfigMetadata();
189238

src/Core/Bridge/Doctrine/EventListener/PublishMercureUpdatesListener.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ public function __construct(ResourceClassResolverInterface $resourceClassResolve
9696
$rawurlencode = ExpressionFunction::fromPhp('rawurlencode', 'escape');
9797
$this->expressionLanguage->addFunction($rawurlencode);
9898

99-
$this->expressionLanguage->addFunction(new ExpressionFunction('iri', static function (string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL): string {
100-
return sprintf('iri(%s, %d)', $apiResource, $referenceType);
101-
}, static function (array $arguments, $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL) use ($iriConverter): string {
102-
return $iriConverter->getIriFromItem($apiResource, null, $referenceType);
103-
}));
99+
$this->expressionLanguage->addFunction(
100+
new ExpressionFunction('iri', static function (string $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL): string {
101+
return sprintf('iri(%s, %d)', $apiResource, $referenceType);
102+
}, static function (array $arguments, $apiResource, int $referenceType = UrlGeneratorInterface::ABS_URL) use ($iriConverter): string {
103+
return $iriConverter->getIriFromItem($apiResource, null, $referenceType);
104+
})
105+
);
104106
}
105107
}
106108

@@ -300,7 +302,11 @@ private function getGraphQlSubscriptionUpdates($object, array $options, string $
300302

301303
$updates = [];
302304
foreach ($payloads as [$subscriptionId, $data]) {
303-
$updates[] = $this->buildUpdate($this->graphQlMercureSubscriptionIriGenerator->generateTopicIri($subscriptionId), (string) (new JsonResponse($data))->getContent(), $options);
305+
$updates[] = $this->buildUpdate(
306+
$this->graphQlMercureSubscriptionIriGenerator->generateTopicIri($subscriptionId),
307+
(string) (new JsonResponse($data))->getContent(),
308+
$options
309+
);
304310
}
305311

306312
return $updates;

src/Core/Bridge/Doctrine/MongoDbOdm/Extension/OrderExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ public function applyToCollection(Builder $aggregationBuilder, string $resourceC
9292
if ($this->isPropertyNested($field, $resourceClass)) {
9393
[$field] = $this->addLookupsForNestedProperty($field, $aggregationBuilder, $resourceClass);
9494
}
95-
$aggregationBuilder->sort($context['mongodb_odm_sort_fields'] = ($context['mongodb_odm_sort_fields'] ?? []) + [$field => $order]);
95+
$aggregationBuilder->sort(
96+
$context['mongodb_odm_sort_fields'] = ($context['mongodb_odm_sort_fields'] ?? []) + [$field => $order]
97+
);
9698
}
9799

98100
return;
@@ -101,7 +103,9 @@ public function applyToCollection(Builder $aggregationBuilder, string $resourceC
101103

102104
if (null !== $this->order) {
103105
foreach ($identifiers as $identifier) {
104-
$aggregationBuilder->sort($context['mongodb_odm_sort_fields'] = ($context['mongodb_odm_sort_fields'] ?? []) + [$identifier => $this->order]);
106+
$aggregationBuilder->sort(
107+
$context['mongodb_odm_sort_fields'] = ($context['mongodb_odm_sort_fields'] ?? []) + [$identifier => $this->order]
108+
);
105109
}
106110
}
107111
}

src/Core/Bridge/Doctrine/MongoDbOdm/Extension/PaginationExtension.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,13 @@ public function applyToCollection(Builder $aggregationBuilder, string $resourceC
9090

9191
$aggregationBuilder
9292
->facet()
93-
->field('results')->pipeline($resultsAggregationBuilder)
94-
->field('count')->pipeline($repository->createAggregationBuilder()
95-
->count('count'));
93+
->field('results')->pipeline(
94+
$resultsAggregationBuilder
95+
)
96+
->field('count')->pipeline(
97+
$repository->createAggregationBuilder()
98+
->count('count')
99+
);
96100
}
97101

98102
/**

src/Core/Bridge/Doctrine/MongoDbOdm/Filter/DateFilter.php

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,43 @@ protected function filterProperty(string $property, $values, Builder $aggregatio
6565
}
6666

6767
if (isset($values[self::PARAMETER_BEFORE])) {
68-
$this->addMatch($aggregationBuilder, $matchField, self::PARAMETER_BEFORE, $values[self::PARAMETER_BEFORE], $nullManagement);
68+
$this->addMatch(
69+
$aggregationBuilder,
70+
$matchField,
71+
self::PARAMETER_BEFORE,
72+
$values[self::PARAMETER_BEFORE],
73+
$nullManagement
74+
);
6975
}
7076

7177
if (isset($values[self::PARAMETER_STRICTLY_BEFORE])) {
72-
$this->addMatch($aggregationBuilder, $matchField, self::PARAMETER_STRICTLY_BEFORE, $values[self::PARAMETER_STRICTLY_BEFORE], $nullManagement);
78+
$this->addMatch(
79+
$aggregationBuilder,
80+
$matchField,
81+
self::PARAMETER_STRICTLY_BEFORE,
82+
$values[self::PARAMETER_STRICTLY_BEFORE],
83+
$nullManagement
84+
);
7385
}
7486

7587
if (isset($values[self::PARAMETER_AFTER])) {
76-
$this->addMatch($aggregationBuilder, $matchField, self::PARAMETER_AFTER, $values[self::PARAMETER_AFTER], $nullManagement);
88+
$this->addMatch(
89+
$aggregationBuilder,
90+
$matchField,
91+
self::PARAMETER_AFTER,
92+
$values[self::PARAMETER_AFTER],
93+
$nullManagement
94+
);
7795
}
7896

7997
if (isset($values[self::PARAMETER_STRICTLY_AFTER])) {
80-
$this->addMatch($aggregationBuilder, $matchField, self::PARAMETER_STRICTLY_AFTER, $values[self::PARAMETER_STRICTLY_AFTER], $nullManagement);
98+
$this->addMatch(
99+
$aggregationBuilder,
100+
$matchField,
101+
self::PARAMETER_STRICTLY_AFTER,
102+
$values[self::PARAMETER_STRICTLY_AFTER],
103+
$nullManagement
104+
);
81105
}
82106
}
83107

@@ -116,7 +140,10 @@ private function addMatch(Builder $aggregationBuilder, string $field, string $op
116140
(self::INCLUDE_NULL_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true)) ||
117141
(self::INCLUDE_NULL_BEFORE_AND_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER, self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true))
118142
) {
119-
$aggregationBuilder->match()->addOr($aggregationBuilder->matchExpr()->field($field)->operator($operatorValue[$operator], $value), $aggregationBuilder->matchExpr()->field($field)->equals(null));
143+
$aggregationBuilder->match()->addOr(
144+
$aggregationBuilder->matchExpr()->field($field)->operator($operatorValue[$operator], $value),
145+
$aggregationBuilder->matchExpr()->field($field)->equals(null)
146+
);
120147

121148
return;
122149
}

0 commit comments

Comments
 (0)