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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy