Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a22b37

Browse filesBrowse files
bug #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
Copy full SHA for 9a22b37

File tree

1 file changed

+1
-1
lines changed
Filter options

1 file changed

+1
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+1-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.