go to bug id or search bugs for
Revision: 184.108.40.206 of filter extension with PHP 5.2.0:
Using filter_var() etc. with FILTER_VALIDATE_INT returns wrong value instead of false.
Add a Patch
Add a Pull Request
Both are valid numeric values, where is the problem?
Sure, but it does not tell me whether the specified numeric value is a valid INTEGER. I thought that is what FILTER_VALIDATE_INT is supposed to do!?!
Returning -2147483648 when validating 2147483648 does not seem correct to me.
How can I safely check that a value is theoretically a valid integer so that I can safely cast it to int?
It is the visual representation of the number or suffering 32bit signed interger limits.
We may clamp it to the max/min integer but it will be equally wrong (but this time both internally than visually). (int)"2147483648" or (int)"-2147483649" both returns: 2147483647 using php directly.
I'm unsure about the best choice, make large numbers invalid may be another solution (and safer). Ilia, what's your preference?
What about adding FILTER_VALIDATE_NUM for "unlimited" numbers and make FILTER_VALIDATE_INT return false if the int boundaries are exceeded?
Documentation problem, I will add the overflow behaviors to the filter extension, it is documented elsewhere as well but having in the filter doc will minimize the wtf factor.
This bug has been fixed already since PHP 5.2.14 and PHP 5.3.3;
values that overflow return false now.