to_int should ensure the value isn't less than PHP_INT_MIN

Also fixed non-64-bit PHP_INT_MAX check