Skip to content
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

PHP math bug & integer coercion #588

Closed
StratilJakub opened this issue Sep 17, 2019 · 1 comment
Closed

PHP math bug & integer coercion #588

StratilJakub opened this issue Sep 17, 2019 · 1 comment

Comments

@StratilJakub
Copy link

StratilJakub commented Sep 17, 2019

Hello,

I encountered weird behavior of PHP (in all versions) when base math operations are involved:
PHP Sandbox example

If result of this kind of math operation goes through integer validation, it fails, even if the Constraint::CHECK_MODE_COERCE_TYPES flag is passed. It's because of how the toInteger($value) conversion function works.

Second part of this condition is, in the mentioned case, evaluated as false:
if (is_numeric($value) && (int) $value == $value)

I will try to come up with PR, in the meantime I will use bcmath functions.

Thank you for all the time and energy, which go to this project.

@DannyvdSluijs
Copy link
Collaborator

@StratilJakub in an attempt to cleanup this repo we are trying to filter the issues and see which ones might be closed. Is it safe to assume this is a rather old issue, which sadly was left unanswered, and can be closed? Feel free to close it yourself with some comments if helpful.

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

No branches or pull requests

2 participants