Skip to content

Commit 5a13555

Browse files
Erwin Dirksnicolas-grekas
authored andcommitted
[Serializer] Fix passing null to str_contains()
1 parent e836e2c commit 5a13555

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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)