Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For 9.x, alternative to: #45580
For 10.x, Supersedes: #45457
This implementation handles both rounding and arbitrary sized floats, restoring the rounding functionality while addressing the large float issue.
It supports systems with
bcmath
orgmp
, and delegates to pure PHP implementations when these are not found, meaning that it does not introduce any hard extension requirements to the framework.This PR introduces
brick/math
in order to handle the rounding.Some points to consider on introducing a new framework dependency...
Adding to the dependency tree
brick/math
is already a sub-dependency oflaravel/framework
viaramsey/uuid
.brick/math
only requires the JSON extension and has no sub-dependencies.Package is pre-1.0
From the readme:
This package is already used in
brick/money
, which is an extremely popular money handing library, second tomoneyphp/money
.Used for only one method
Introducing an entire dependency for a single method feels like a lot, however this library could be used to improve other parts of the framework.
multiple_of
rule could potentially drop it's dependency on thebcmath
extension.Nice to have
I believe it is nice to have a strong math library in the framework anyway. Requiring it directly may lead others to the package and learn to improve their own handling of large numbers within their own applications.