Skip to content

Commit

Permalink
[Serializer] Fix passing null to str_contains()
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwin Dirks authored and nicolas-grekas committed Feb 24, 2022
1 parent 75bf7fa commit da7d8c0
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ private function validateAndDenormalize(string $currentClass, string $attribute,
// PHP's json_decode automatically converts Numbers without a decimal part to integers.
// To circumvent this behavior, integers are converted to floats when denormalizing JSON based formats and when
// a float is expected.
if (Type::BUILTIN_TYPE_FLOAT === $builtinType && \is_int($data) && str_contains($format, JsonEncoder::FORMAT)) {
if (Type::BUILTIN_TYPE_FLOAT === $builtinType && \is_int($data) && null !== $format && str_contains($format, JsonEncoder::FORMAT)) {
return (float) $data;
}

Expand Down

0 comments on commit da7d8c0

Please sign in to comment.