Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Validator] Type constraint considers NAN and INF as floats #50782

Closed
@aprat84

Description

@aprat84

Symfony version(s) affected

6.3

Description

If a number is outside of 2.2250738585072014E-308 to 1.7976931348623158E+308 range, PHP converts it to -INF or INF.

Values INF, -INF and NAN are considered float in PHP as for the is_float function.

The Type constraint relies in this function to check for a valid float.

Now, are this valid float numbers? IMHO no.

FTR: this doesn't happen with integers, as PHP converts them to float once they go outside the PHP_INT_MIN and PHP_INT_MAX range...

How to reproduce

var_dump(is_float(INF));
var_dump(is_float(NAN));

Possible Solution

Add an extra check for is_finite, when dealing with floats?

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions