framework
framework copied to clipboard
[10.x] Improve decimal cast precision
This is a draft as we will need to:
- Merge #45454
- Merge 9.x into 10.x
- Update the failing test to use
ValueExceptioninstead ofTypeException
Fixes https://github.com/laravel/framework/issues/45454 Improves on https://github.com/laravel/framework/pull/45456
On hold until https://github.com/laravel/framework/pull/45492 is merged.
@timacdonald I guess this can be continued to work on now that PR is merged?
@timacdonald I moved the bc-math requirement to "suggest" which is what you wanted to do I think.
If it's in the suggest, then it crashes? This is different then https://github.com/laravel/framework/pull/45457 which checks if the extension is loaded. In this version for 10.x it always used bcmath
@barryvdh it's in "suggest" because you don't have to use the decimal cast per se. It's suppose to crash if you don't have it installed. That's why it's a "suggest" and not a hard dependency.
Also, I think you wanted to link to a different PR?
If you don't want to require it, maybe better to keep the fallback? Maybe add an exception if the float precision is to low? Something like https://github.com/laravel/framework/pull/45580/commits/f66db469ba740d1957a288b443a88f48c882a16c (Removed the exception in https://github.com/laravel/framework/pull/45580/ for 9.x now)