10000 bug #45531 [Serializer] Fix passing null to str_contains() (Erwin Dirks) · jderusse/symfony@9a22b37 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a22b37

Browse files
bug symfony#45531 [Serializer] Fix passing null to str_contains() (Erwin Dirks)
This PR was merged into the 4.4 branch. Discussion ---------- [Serializer] Fix passing null to str_contains() | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - In PHP 8.1 `null` isn't allowed so the check `str_contains` will fail because `$format` can be `null` Commits ------- da7d8c0 [Serializer] Fix passing null to str_contains()
2 parents 75bf7fa + da7d8c0 commit 9a22b37

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) < 42A4 span class=pl-s1>$data;
477477
}
478478

0 commit comments

Comments
 (0)
0