-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6.x] Fix originalIsEquivalent
with floats
#33259
[6.x] Fix originalIsEquivalent
with floats
#33259
Conversation
originalIsEquivalent
with for floats
originalIsEquivalent
with for floatsoriginalIsEquivalent
with floats
@@ -1178,6 +1178,11 @@ public function originalIsEquivalent($key, $current) | |||
} elseif ($this->hasCast($key, ['object', 'collection'])) { | |||
return $this->castAttribute($key, $current) == | |||
$this->castAttribute($key, $original); | |||
} elseif ($this->hasCast($key, 'float')) { | |||
return bccomp( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think by using bccomp
function, we need to require ext-bcmath
into the composer.json
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This project has a depency on: moontoast/math
.
So therefore the existence of ext-bcmath
is already checked: https://github.com/moontoast/math/blob/master/composer.json#L14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BassemN is correct though; that another dependency depends on something which is now ultimately a shared dependency is not enough.
This project has a depency on: moontoast/math.
It's only a suggested dependency of illuminate/support.
However you can use illuminate/database independent of Laravel (which I'm doing).
Therefore I believe that the dependency belongs into:
src/Illuminate/Database/composer.json
as well as intocomposer.json
Because it's now a hard requirement for Laravel 6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot add that dependency. I'd suggest we change this code to avoid using that function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol 😄
According to the PHP Docs:
https://www.php.net/manual/en/language.types.float.php
You shouldn't compare two floats directly for equality.
This only manifests when you cast to a float, otherwise you'll fall into the:
Which works for floats fine.