Skip to content

Commit cafac2c

Browse files
committed
ObjectNormalizer: allow null and scalar
1 parent c001b30 commit cafac2c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,11 @@ public function normalize(mixed $data, ?string $format = null, array $context =
213213
foreach ($stack as $attribute => $attributeValue) {
214214
$attributeContext = $this->getAttributeNormalizationContext($data, $attribute, $context);
215215

216-
if (null === $attributeValue || \is_scalar($attributeValue)) {
217-
$normalizedData = $this->updateData($normalizedData, $attribute, $attributeValue, $class, $format, $attributeContext, $attributesMetadata, $classMetadata);
218-
continue;
219-
}
220-
221216
if (!$this->serializer instanceof NormalizerInterface) {
217+
if (null === $attributeValue || \is_scalar($attributeValue)) {
218+
$normalizedData = $this->updateData($normalizedData, $attribute, $attributeValue, $class, $format, $attributeContext, $attributesMetadata, $classMetadata);
219+
continue;
220+
}
222221
throw new LogicException(\sprintf('Cannot normalize attribute "%s" because the injected serializer is not a normalizer.', $attribute));
223222
}
224223

0 commit comments

Comments
 (0)