Changeset 36886 for trunk/src/wp-includes/random_compat/cast_to_int.php
- Timestamp:
- 03/08/2016 05:14:52 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/random_compat/cast_to_int.php
r35365 r36886 38 38 * through. 39 39 * 40 * @param numeric $numberThe number we want to convert to an int41 * @param boolean $fail_open Set to true to not throw an exception40 * @param int|float $number The number we want to convert to an int 41 * @param boolean $fail_open Set to true to not throw an exception 42 42 * 43 43 * @return int (or float if $fail_open) 44 * 45 * @throws TypeError 44 46 */ 45 47 function RandomCompat_intval($number, $fail_open = false) … … 48 50 $number += 0; 49 51 } 52 50 53 if ( 51 is_float($number) && 52 $number > ~PHP_INT_MAX && 54 is_float($number) 55 && 56 $number > ~PHP_INT_MAX 57 && 53 58 $number < PHP_INT_MAX 54 59 ) { 55 60 $number = (int) $number; 56 61 } 62 57 63 if (is_int($number) || $fail_open) { 58 64 return $number; 59 65 } 66 60 67 throw new TypeError( 61 68 'Expected an integer.'
Note: See TracChangeset
for help on using the changeset viewer.