Make WordPress Core


Ignore:
Timestamp:
02/16/2022 09:17:04 PM (3 years ago)
Author:
SergeyBiryukov
Message:

External Libraries: Update random_compat to version 2.0.21.

The latest release includes improved compatibility with PHP 8.1, as well as some bug fixes for Windows platforms.

Release notes:
https://github.com/paragonie/random_compat/releases/tag/v2.0.21

For a full list of changes in this update, see the random_compat GitHub:
https://github.com/paragonie/random_compat/compare/v2.0.11...v2.0.21

Follow-up to [42130].

Props jrf, paragoninitiativeenterprises.
Fixes #55181.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/random_compat/cast_to_int.php

    r46586 r52742  
    66 * The MIT License (MIT)
    77 *
    8  * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
     8 * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
    99 *
    1010 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    2828
    2929if (!is_callable('RandomCompat_intval')) {
    30    
     30
    3131    /**
    3232     * Cast to an integer if we can, safely.
    33      * 
     33     *
    3434     * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
    3535     * (non-inclusive), it will sanely cast it to an int. If you it's equal to
     
    3737     * lose precision, so the <= and => operators might accidentally let a float
    3838     * through.
    39      * 
     39     *
    4040     * @param int|float $number    The number we want to convert to an int
    4141     * @param bool      $fail_open Set to true to not throw an exception
    42      * 
     42     *
    4343     * @return float|int
    4444     * @psalm-suppress InvalidReturnType
     
    5151            $number += 0;
    5252        } elseif (is_numeric($number)) {
     53            /** @psalm-suppress InvalidOperand */
    5354            $number += 0;
    5455        }
     56        /** @var int|float $number */
    5557
    5658        if (
    5759            is_float($number)
    58             &&
     60                &&
    5961            $number > ~PHP_INT_MAX
    60             &&
     62                &&
    6163            $number < PHP_INT_MAX
    6264        ) {
Note: See TracChangeset for help on using the changeset viewer.