Changeset 52742 for trunk/src/wp-includes/random_compat/cast_to_int.php
- Timestamp:
- 02/16/2022 09:17:04 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/random_compat/cast_to_int.php
r46586 r52742 6 6 * The MIT License (MIT) 7 7 * 8 * Copyright (c) 2015 - 201 7Paragon Initiative Enterprises8 * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises 9 9 * 10 10 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 28 28 29 29 if (!is_callable('RandomCompat_intval')) { 30 30 31 31 /** 32 32 * Cast to an integer if we can, safely. 33 * 33 * 34 34 * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) 35 35 * (non-inclusive), it will sanely cast it to an int. If you it's equal to … … 37 37 * lose precision, so the <= and => operators might accidentally let a float 38 38 * through. 39 * 39 * 40 40 * @param int|float $number The number we want to convert to an int 41 41 * @param bool $fail_open Set to true to not throw an exception 42 * 42 * 43 43 * @return float|int 44 44 * @psalm-suppress InvalidReturnType … … 51 51 $number += 0; 52 52 } elseif (is_numeric($number)) { 53 /** @psalm-suppress InvalidOperand */ 53 54 $number += 0; 54 55 } 56 /** @var int|float $number */ 55 57 56 58 if ( 57 59 is_float($number) 58 &&60 && 59 61 $number > ~PHP_INT_MAX 60 &&62 && 61 63 $number < PHP_INT_MAX 62 64 ) {
Note: See TracChangeset
for help on using the changeset viewer.