@@ -28,50 +28,50 @@ |
||
| 28 | 28 | |
| 29 | 29 | if (!is_callable('RandomCompat_intval')) { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Cast to an integer if we can, safely. |
|
| 33 | - * |
|
| 34 | - * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) |
|
| 35 | - * (non-inclusive), it will sanely cast it to an int. If you it's equal to |
|
| 36 | - * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats |
|
| 37 | - * lose precision, so the <= and => operators might accidentally let a float |
|
| 38 | - * through. |
|
| 39 | - * |
|
| 40 | - * @param int|float $number The number we want to convert to an int |
|
| 41 | - * @param bool $fail_open Set to true to not throw an exception |
|
| 42 | - * |
|
| 43 | - * @return float|int |
|
| 44 | - * @psalm-suppress InvalidReturnType |
|
| 45 | - * |
|
| 46 | - * @throws TypeError |
|
| 47 | - */ |
|
| 48 | - function RandomCompat_intval($number, $fail_open = false) |
|
| 49 | - { |
|
| 50 | - if (is_int($number) || is_float($number)) { |
|
| 51 | - $number += 0; |
|
| 52 | - } elseif (is_numeric($number)) { |
|
| 53 | - /** @psalm-suppress InvalidOperand */ |
|
| 54 | - $number += 0; |
|
| 55 | - } |
|
| 56 | - /** @var int|float $number */ |
|
| 31 | + /** |
|
| 32 | + * Cast to an integer if we can, safely. |
|
| 33 | + * |
|
| 34 | + * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) |
|
| 35 | + * (non-inclusive), it will sanely cast it to an int. If you it's equal to |
|
| 36 | + * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats |
|
| 37 | + * lose precision, so the <= and => operators might accidentally let a float |
|
| 38 | + * through. |
|
| 39 | + * |
|
| 40 | + * @param int|float $number The number we want to convert to an int |
|
| 41 | + * @param bool $fail_open Set to true to not throw an exception |
|
| 42 | + * |
|
| 43 | + * @return float|int |
|
| 44 | + * @psalm-suppress InvalidReturnType |
|
| 45 | + * |
|
| 46 | + * @throws TypeError |
|
| 47 | + */ |
|
| 48 | + function RandomCompat_intval($number, $fail_open = false) |
|
| 49 | + { |
|
| 50 | + if (is_int($number) || is_float($number)) { |
|
| 51 | + $number += 0; |
|
| 52 | + } elseif (is_numeric($number)) { |
|
| 53 | + /** @psalm-suppress InvalidOperand */ |
|
| 54 | + $number += 0; |
|
| 55 | + } |
|
| 56 | + /** @var int|float $number */ |
|
| 57 | 57 | |
| 58 | - if ( |
|
| 59 | - is_float($number) |
|
| 60 | - && |
|
| 61 | - $number > ~PHP_INT_MAX |
|
| 62 | - && |
|
| 63 | - $number < PHP_INT_MAX |
|
| 64 | - ) { |
|
| 65 | - $number = (int) $number; |
|
| 66 | - } |
|
| 58 | + if ( |
|
| 59 | + is_float($number) |
|
| 60 | + && |
|
| 61 | + $number > ~PHP_INT_MAX |
|
| 62 | + && |
|
| 63 | + $number < PHP_INT_MAX |
|
| 64 | + ) { |
|
| 65 | + $number = (int) $number; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - if (is_int($number)) { |
|
| 69 | - return (int) $number; |
|
| 70 | - } elseif (!$fail_open) { |
|
| 71 | - throw new TypeError( |
|
| 72 | - 'Expected an integer.' |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - return $number; |
|
| 76 | - } |
|
| 68 | + if (is_int($number)) { |
|
| 69 | + return (int) $number; |
|
| 70 | + } elseif (!$fail_open) { |
|
| 71 | + throw new TypeError( |
|
| 72 | + 'Expected an integer.' |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + return $number; |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -2263,7 +2263,7 @@ |
||
| 2263 | 2263 | { |
| 2264 | 2264 | uasort($loaded_attachments, function($a, $b) { |
| 2265 | 2265 | if ($a['filesize'] == $b['filesize']) |
| 2266 | - return 0; |
|
| 2266 | + return 0; |
|
| 2267 | 2267 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
| 2268 | 2268 | }); |
| 2269 | 2269 | } |
@@ -310,7 +310,7 @@ |
||
| 310 | 310 | { |
| 311 | 311 | /** |
| 312 | 312 | * Constants for notification types. |
| 313 | - */ |
|
| 313 | + */ |
|
| 314 | 314 | const RECEIVE_NOTIFY_EMAIL = 0x02; |
| 315 | 315 | const RECEIVE_NOTIFY_ALERT = 0x01; |
| 316 | 316 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | /** |
| 21 | 21 | * Constants for reply types. |
| 22 | - */ |
|
| 22 | + */ |
|
| 23 | 23 | const NOTIFY_TYPE_REPLY_AND_MODIFY = 1; |
| 24 | 24 | const NOTIFY_TYPE_REPLY_AND_TOPIC_START_FOLLOWING = 2; |
| 25 | 25 | const NOTIFY_TYPE_ONLY_REPLIES = 3; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Constants for frequencies. |
| 30 | - */ |
|
| 30 | + */ |
|
| 31 | 31 | const FREQUENCY_NOTHING = 0; |
| 32 | 32 | const FREQUENCY_EVERYTHING = 1; |
| 33 | 33 | const FREQUENCY_FIRST_UNREAD_MSG = 2; |
@@ -7239,32 +7239,32 @@ discard block |
||
| 7239 | 7239 | */ |
| 7240 | 7240 | function truncate_array($array, $max_length = 1900, $deep = 3) |
| 7241 | 7241 | { |
| 7242 | - $array = (array) $array; |
|
| 7242 | + $array = (array) $array; |
|
| 7243 | 7243 | |
| 7244 | - $curr_length = array_length($array, $deep); |
|
| 7244 | + $curr_length = array_length($array, $deep); |
|
| 7245 | 7245 | |
| 7246 | - if ($curr_length <= $max_length) |
|
| 7247 | - return $array; |
|
| 7246 | + if ($curr_length <= $max_length) |
|
| 7247 | + return $array; |
|
| 7248 | 7248 | |
| 7249 | - else |
|
| 7250 | - { |
|
| 7251 | - // Truncate each element's value to a reasonable length |
|
| 7252 | - $param_max = floor($max_length / count($array)); |
|
| 7249 | + else |
|
| 7250 | + { |
|
| 7251 | + // Truncate each element's value to a reasonable length |
|
| 7252 | + $param_max = floor($max_length / count($array)); |
|
| 7253 | 7253 | |
| 7254 | - $current_deep = $deep - 1; |
|
| 7254 | + $current_deep = $deep - 1; |
|
| 7255 | 7255 | |
| 7256 | - foreach ($array as $key => &$value) |
|
| 7257 | - { |
|
| 7258 | - if (is_array($value)) |
|
| 7259 | - if ($current_deep > 0) |
|
| 7260 | - $value = truncate_array($value, $current_deep); |
|
| 7256 | + foreach ($array as $key => &$value) |
|
| 7257 | + { |
|
| 7258 | + if (is_array($value)) |
|
| 7259 | + if ($current_deep > 0) |
|
| 7260 | + $value = truncate_array($value, $current_deep); |
|
| 7261 | 7261 | |
| 7262 | - else |
|
| 7263 | - $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 7264 | - } |
|
| 7262 | + else |
|
| 7263 | + $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 7264 | + } |
|
| 7265 | 7265 | |
| 7266 | - return $array; |
|
| 7267 | - } |
|
| 7266 | + return $array; |
|
| 7267 | + } |
|
| 7268 | 7268 | } |
| 7269 | 7269 | |
| 7270 | 7270 | /** |
@@ -7275,29 +7275,29 @@ discard block |
||
| 7275 | 7275 | */ |
| 7276 | 7276 | function array_length($array, $deep = 3) |
| 7277 | 7277 | { |
| 7278 | - // Work with arrays |
|
| 7279 | - $array = (array) $array; |
|
| 7280 | - $length = 0; |
|
| 7278 | + // Work with arrays |
|
| 7279 | + $array = (array) $array; |
|
| 7280 | + $length = 0; |
|
| 7281 | 7281 | |
| 7282 | - $deep_count = $deep - 1; |
|
| 7282 | + $deep_count = $deep - 1; |
|
| 7283 | 7283 | |
| 7284 | - foreach ($array as $value) |
|
| 7285 | - { |
|
| 7286 | - // Recursive? |
|
| 7287 | - if (is_array($value)) |
|
| 7288 | - { |
|
| 7289 | - // No can't do |
|
| 7290 | - if ($deep_count <= 0) |
|
| 7291 | - continue; |
|
| 7284 | + foreach ($array as $value) |
|
| 7285 | + { |
|
| 7286 | + // Recursive? |
|
| 7287 | + if (is_array($value)) |
|
| 7288 | + { |
|
| 7289 | + // No can't do |
|
| 7290 | + if ($deep_count <= 0) |
|
| 7291 | + continue; |
|
| 7292 | 7292 | |
| 7293 | - $length += array_length($value, $deep_count); |
|
| 7294 | - } |
|
| 7293 | + $length += array_length($value, $deep_count); |
|
| 7294 | + } |
|
| 7295 | 7295 | |
| 7296 | - else |
|
| 7297 | - $length += strlen($value); |
|
| 7298 | - } |
|
| 7296 | + else |
|
| 7297 | + $length += strlen($value); |
|
| 7298 | + } |
|
| 7299 | 7299 | |
| 7300 | - return $length; |
|
| 7300 | + return $length; |
|
| 7301 | 7301 | } |
| 7302 | 7302 | |
| 7303 | 7303 | /** |