Skip to content

PHP math bug & integer coercion #588

Closed
@StratilJakub

Description

@StratilJakub

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions