8000 [Serializer] Fix passing null to str_contains() · jderusse/symfony@da7d8c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit da7d8c0

Browse files
Erwin Dirksnicolas-grekas
authored andcommitted
[Serializer] Fix passing null to str_contains()
1 parent 75bf7fa commit da7d8c0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ private function validateAndDenormalize(string $currentClass, string $attribute,
472472
// PHP's json_decode automatically converts Numbers without a decimal part to integers.
473473
// To circumvent this behavior, integers are converted to floats when denormalizing JSON based formats and when
474474
// a float is expected.
475-
if (Type::BUILTIN_TYPE_FLOAT === $builtinType && \is_int($data) && str_contains($format, JsonEncoder::FORMAT)) {
475+
if (Type::BUILTIN_TYPE_FLOAT === $builtinType && \is_int($data) && null !== $format && str_contains($format, JsonEncoder::FORMAT)) {
476476
return (float) $data;
477477
}
478478

0 commit comments

Comments
 (0)
0