← All changes
|
vendor_prefixed/sentry/sentry/src/Serializer/RepresentationSerializer.php
+17
-2
1.10.20
→
1.10.22
View file →
| @@ -40,13 +40,28 @@ | ||
| 40 | 40 | } |
| 41 | 41 | if ($value === \true) { |
| 42 | 42 | return 'true'; |
| 43 | 43 | } |
| 44 | - if (\is_float($value) && (int) $value == $value) { | |
| 45 | - return $value . '.0'; | |
| 44 | + if (\is_float($value)) { | |
| 45 | + if (\is_nan($value)) { | |
| 46 | + return 'NAN'; | |
| 47 | + } | |
| 48 | + if ($this->isCastableToInt($value) && (int) $value == $value) { | |
| 49 | + return $value . '.0'; | |
| 50 | + } | |
| 46 | 51 | } |
| 47 | 52 | if (\is_numeric($value)) { |
| 48 | 53 | return (string) $value; |
| 49 | 54 | } |
| 50 | 55 | return (string) parent::serializeValue($value); |
| 56 | + } | |
| 57 | + /** | |
| 58 | + * Casting a non-finite float, or one that falls outside of the integer | |
| 59 | + * range, raises a warning as of PHP 8.5. | |
| 60 | + * | |
| 61 | + * @param float $value The value to check | |
| 62 | + */ | |
| 63 | + private function isCastableToInt(float $value) : bool | |
| 64 | + { | |
| 65 | + return $value >= (float) \PHP_INT_MIN && $value < (float) \PHP_INT_MAX; | |
| 51 | 66 | } |
| 52 | 67 | } |