Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 628be3c

Browse files
committed
[Serializer] fix denormalization of basic property-types in XML and CSV #33849
1 parent 130c0be commit 628be3c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,10 @@ private function validateAndDenormalize($currentClass, $attribute, $data, $forma
260260
//
261261
// This is special to xml and csv format
262262
if (
263-
\is_string($data) &&
264-
(XmlEncoder::FORMAT === $format || CsvEncoder::FORMAT === $format)
263+
\is_string($data) && (XmlEncoder::FORMAT === $format || CsvEncoder::FORMAT === $format)
265264
) {
266265
if (
267-
'' === $data &&
268-
$type->isNullable() &&
269-
\in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_BOOL, Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true)
266+
'' === $data && $type->isNullable() && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_BOOL, Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true)
270267
) {
271268
return null;
272269
}
@@ -285,7 +282,7 @@ private function validateAndDenormalize($currentClass, $attribute, $data, $forma
285282
case Type::BUILTIN_TYPE_INT:
286283
if (
287284
ctype_digit($data) ||
288-
'-' == $data[0] && ctype_digit(substr($data, 1))
285+
'-' === $data[0] && ctype_digit(substr($data, 1))
289286
) {
290287
$data = (int) $data;
291288
} else {
@@ -462,10 +459,10 @@ private function getCacheKey($format, array $context)
462459
unset($context['cache_key']); // avoid artificially different keys
463460
try {
464461
return md5($format.serialize([
465-
'context' => $context,
466-
'ignored' => $this->ignoredAttributes,
467-
'camelized' => $this->camelizedAttributes,
468-
]));
462+
'context' => $context,
463+
'ignored' => $this->ignoredAttributes,
464+
'camelized' => $this->camelizedAttributes,
465+
]));
469466
} catch (\Exception $exception) {
470467
// The context cannot be serialized, skip the cache
471468
return false;

0 commit comments

Comments
 (0)