Fixed failed integer test (only fails on some OSs and PHP versions)

This commit is contained in:
Vladimir Razuvaev 2017-09-20 16:18:38 +07:00
parent c97438cd7d
commit 2023b427ae

View File

@ -74,7 +74,10 @@ values. Int can represent values between -(2^31) and 2^31 - 1. ';
*/
public function parseValue($value)
{
return (is_int($value) && $value <= self::MAX_INT && $value >= self::MIN_INT) ? $value : null;
// Below is a fix against PHP bug where (in some combinations of OSs and versions)
// boundary values are treated as "double" vs "integer" and failing is_int() check
$isInt = is_int($value) || $value === self::MIN_INT || $value === self::MAX_INT;
return $isInt && $value <= self::MAX_INT && $value >= self::MIN_INT ? $value : null;
}
/**