From 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Jan 2020 13:06:14 +0100 Subject: Added wordpress --- .../wp-includes/random_compat/cast_to_int.php | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 srcs/wordpress/wp-includes/random_compat/cast_to_int.php (limited to 'srcs/wordpress/wp-includes/random_compat/cast_to_int.php') diff --git a/srcs/wordpress/wp-includes/random_compat/cast_to_int.php b/srcs/wordpress/wp-includes/random_compat/cast_to_int.php new file mode 100644 index 0000000..9a4fab9 --- /dev/null +++ b/srcs/wordpress/wp-includes/random_compat/cast_to_int.php @@ -0,0 +1,75 @@ + operators might accidentally let a float + * through. + * + * @param int|float $number The number we want to convert to an int + * @param bool $fail_open Set to true to not throw an exception + * + * @return float|int + * @psalm-suppress InvalidReturnType + * + * @throws TypeError + */ + function RandomCompat_intval($number, $fail_open = false) + { + if (is_int($number) || is_float($number)) { + $number += 0; + } elseif (is_numeric($number)) { + $number += 0; + } + + if ( + is_float($number) + && + $number > ~PHP_INT_MAX + && + $number < PHP_INT_MAX + ) { + $number = (int) $number; + } + + if (is_int($number)) { + return (int) $number; + } elseif (!$fail_open) { + throw new TypeError( + 'Expected an integer.' + ); + } + return $number; + } +} -- cgit