Skip to content

Commit 5b5e6b7

Browse files
committed
Merge branch '2.3'
2 parents f5f77d5 + 9686720 commit 5b5e6b7

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/Bridge/NelmioApiDoc/Parser/ApiPlatformParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private function getGroupsContext(ResourceMetadata $resourceMetadata, string $op
136136

137137
return [
138138
$groupsContext => [
139-
AbstractNormalizer::GROUPS => array_merge($itemOperationAttribute ?? [], $collectionOperationAttribute ?? []),
139+
AbstractNormalizer::GROUPS => array_merge((array) ($itemOperationAttribute ?? []), (array) ($collectionOperationAttribute ?? [])),
140140
],
141141
];
142142
}

src/Hydra/Serializer/DocumentationNormalizer.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,23 @@ private function getPropertyNameCollectionFactoryContext(ResourceMetadata $resou
156156
$context = [];
157157

158158
if (isset($attributes['normalization_context'][AbstractNormalizer::GROUPS])) {
159-
$context['serializer_groups'] = $attributes['normalization_context'][AbstractNormalizer::GROUPS];
159+
$context['serializer_groups'] = (array) $attributes['normalization_context'][AbstractNormalizer::GROUPS];
160160
}
161161

162-
if (isset($attributes['denormalization_context'][AbstractNormalizer::GROUPS])) {
163-
if (isset($context['serializer_groups'])) {
164-
foreach ($attributes['denormalization_context'][AbstractNormalizer::GROUPS] as $groupName) {
165-
$context['serializer_groups'][] = $groupName;
166-
}
167-
} else {
168-
$context['serializer_groups'] = $attributes['denormalization_context'][AbstractNormalizer::GROUPS];
162+
if (!isset($attributes['denormalization_context'][AbstractNormalizer::GROUPS])) {
163+
return $context;
164+
}
165+
166+
if (isset($context['serializer_groups'])) {
167+
foreach ((array) $attributes['denormalization_context'][AbstractNormalizer::GROUPS] as $groupName) {
168+
$context['serializer_groups'][] = $groupName;
169169
}
170+
171+
return $context;
170172
}
171173

174+
$context['serializer_groups'] = (array) $attributes['denormalization_context'][AbstractNormalizer::GROUPS];
175+
172176
return $context;
173177
}
174178

tests/Fixtures/TestBundle/Entity/DummyCar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
* @ApiResource(
2929
* itemOperations={"get"={"swagger_context"={"tags"={}}, "openapi_context"={"tags"={}}}, "put", "delete"},
3030
* attributes={
31-
* "normalization_context"={"groups"={"colors"}},
32-
* "sunset"="2050-01-01"
31+
* "sunset"="2050-01-01",
32+
* "normalization_context"={"groups"="colors"}
3333
* }
3434
* )
3535
* @ORM\Entity

0 commit comments

Comments
 (0)