Skip to content

[12.x] Fix Number::trim() returning null for INF and NAN values#60322

Merged
taylorotwell merged 1 commit into
laravel:12.xfrom
Amirhf1:fix/number-trim-inf-nan
May 29, 2026
Merged

[12.x] Fix Number::trim() returning null for INF and NAN values#60322
taylorotwell merged 1 commit into
laravel:12.xfrom
Amirhf1:fix/number-trim-inf-nan

Conversation

@Amirhf1

@Amirhf1 Amirhf1 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Number::trim() uses json_decode(json_encode($number)) to strip trailing zeros. However, json_encode(INF) and json_encode(NAN) return false (PHP raises JSON_ERROR_INF_OR_NAN), so json_decode(false) returns null — a silent data loss.

Number::trim(INF);  // returns null  ← bug
Number::trim(NAN);  // returns null  ← bug

@taylorotwell taylorotwell merged commit 55d9fb8 into laravel:12.x May 29, 2026
71 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants