Make WordPress Core


Ignore:
Timestamp:
02/16/2022 09:17:04 PM (2 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/random_int.php

    r46586 r52742  
    88     * The MIT License (MIT)
    99     *
    10      * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
     10     * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
    1111     *
    1212     * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    5252
    5353        try {
     54            /** @var int $min */
    5455            $min = RandomCompat_intval($min);
    5556        } catch (TypeError $ex) {
     
    6061
    6162        try {
     63            /** @var int $max */
    6264            $max = RandomCompat_intval($max);
    6365        } catch (TypeError $ex) {
     
    9193         */
    9294        $attempts = $bits = $bytes = $mask = $valueShift = 0;
     95        /** @var int $attempts */
     96        /** @var int $bits */
     97        /** @var int $bytes */
     98        /** @var int $mask */
     99        /** @var int $valueShift */
    93100
    94101        /**
     
    96103         * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to
    97104         * a float and we will lose some precision.
     105         *
     106         * @var int|float $range
    98107         */
    99108        $range = $max - $min;
     
    116125             */
    117126            $bytes = PHP_INT_SIZE;
     127            /** @var int $mask */
    118128            $mask = ~0;
    119129
     
    130140                ++$bits;
    131141                $range >>= 1;
     142                /** @var int $mask */
    132143                $mask = $mask << 1 | 1;
    133144            }
     
    135146        }
    136147
     148        /** @var int $val */
    137149        $val = 0;
    138150        /**
     
    140152         * random integers until one falls between $min and $max
    141153         */
     154        /** @psalm-suppress RedundantCondition */
    142155        do {
    143156            /**
     
    170183                $val |= ord($randomByteString[$i]) << ($i * 8);
    171184            }
     185            /** @var int $val */
    172186
    173187            /**
Note: See TracChangeset for help on using the changeset viewer.