]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/random_compat/cast_to_int.php
WordPress 4.7.2-scripts
[autoinstalls/wordpress.git] / wp-includes / random_compat / cast_to_int.php
index 474ce64008f2b863daffd93736efe984cd00f244..f441c5d98616fafe02ece6acb68699f2cfb3bc3d 100644 (file)
@@ -37,26 +37,33 @@ if (!function_exists('RandomCompat_intval')) {
      * lose precision, so the <= and => 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
+     * @param int|float $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)
+     *
+     * @throws TypeError
      */
     function RandomCompat_intval($number, $fail_open = false)
     {
         if (is_numeric($number)) {
             $number += 0;
         }
+
         if (
-            is_float($number) &&
-            $number > ~PHP_INT_MAX &&
+            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.'
         );