operators might accidentally let a float * through. * * @param numeric $number The number we want to convert to an int * @param boolean $fail_open Set to true to not throw an exception * * @return int (or float if $fail_open) */ function RandomCompat_intval($number, $fail_open = false) { if (is_numeric($number)) { $number += 0; } if ( is_float($number) && $number > ~PHP_INT_MAX && $number < PHP_INT_MAX ) { $number = (int) $number; } if (is_int($number) || $fail_open) { return $number; } throw new TypeError( 'Expected an integer.' ); } }