8000 [Serializer] fix denormalization of basic property-types in XML and C… · symfony/symfony@7e4fcc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e4fcc7

Browse files
committed
[Serializer] fix denormalization of basic property-types in XML and CSV #33849
1 parent 0cc66a8 commit 7e4fcc7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,15 @@ private function validateAndDenormalize($currentClass, $attribute, $data, $forma
294294
return (float) $data;
295295
}
296296

297-
if ('NaN' === $data) {
298-
return NAN;
299-
} elseif ('INF') {
300-
return INF;
301-
} elseif ('-INF') {
302-
return -INF;
303-
} else {
304-
throw new NotNormalizableValueException(sprintf('The type of the "%s" attribute for class "%s" must be float ("%s" given).', $attribute, $currentClass, $data));
297+
switch ($data) {
298+
case 'NaN':
299+
return NAN;
300+
case 'INF':
301+
return INF;
302+
case '-INF':
303+
return -INF;
304+
default:
305+
throw new NotNormalizableValueException(sprintf('The type of the "%s" attribute for class "%s" must be float ("%s" given).', $attribute, $currentClass, $data));
305306
}
306307

307308
break;

0 commit comments

Comments
 (0)
0