8000 bug #34490 [Serializer] Fix MetadataAwareNameConverter usage with str… · symfony/symfony@33731bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 33731bf

Browse files
bug #34490 [Serializer] Fix MetadataAwareNameConverter usage with string group (antograssiot)
This PR was merged into the 4.3 branch. Discussion ---------- [Serializer] Fix MetadataAwareNameConverter usage with string group | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34455 | License | MIT | Doc PR | Allow to use the short syntax for serialization context group like `['groups' => 'user']` Commits ------- d4f749a [Serializer] Fix MetadataAwareNameConverter usage with string group
2 parents 63e6f87 + d4f749a commit 33731bf

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function getCacheValueForAttributesMetadata(string $class, array $contex
123123
if (!$groups && ($context[AbstractNormalizer::GROUPS] ?? [])) {
124124
continue;
125125
}
126-
if ($groups && !array_intersect($groups, $context[AbstractNormalizer::GROUPS] ?? [])) {
126+
if ($groups && !array_intersect($groups, (array) ($context[AbstractNormalizer::GROUPS] ?? []))) {
127127
continue;
128128
}
129129

src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ public function attributeAndContextProvider()
146146
return [
147147
['buz', 'buz', ['groups' => ['a']]],
148148
['buzForExport', 'buz', ['groups' => ['b']]],
149+
['buz', 'buz', ['groups' => 'a']],
150+
['buzForExport', 'buz', ['groups' => 'b']],
149151
['buz', 'buz', ['groups' => ['c']]],
150152
['buz', 'buz', []],
151153
];

0 commit comments

Comments
 (0)
0