Make WordPress Core


Ignore:
Timestamp:
11/08/2017 11:47:04 AM (7 years ago)
Author:
dd32
Message:

External Libraries: Update Random_Compat from 1.2.1 to 2.0.11.

Notably this fixes PHP7 parse errors of the files and removes the OpenSSL functionality.
Full Changes: https://github.com/paragonie/random_compat/compare/v1.2.1...v2.0.11

Props jrdelarosa.
See #42439.

File:
1 edited

Legend:

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

    r36886 r42130  
    66 * The MIT License (MIT)
    77 *
    8  * Copyright (c) 2015 Paragon Initiative Enterprises
     8 * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
    99 *
    1010 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    2727 */
    2828
    29 if (!function_exists('RandomCompat_intval')) {
     29if (!is_callable('RandomCompat_intval')) {
    3030   
    3131    /**
     
    3939     *
    4040     * @param int|float $number    The number we want to convert to an int
    41      * @param boolean   $fail_open Set to true to not throw an exception
     41     * @param bool      $fail_open Set to true to not throw an exception
    4242     *
    43      * @return int (or float if $fail_open)
     43     * @return float|int
     44     * @psalm-suppress InvalidReturnType
    4445     *
    4546     * @throws TypeError
     
    4748    function RandomCompat_intval($number, $fail_open = false)
    4849    {
    49         if (is_numeric($number)) {
     50        if (is_int($number) || is_float($number)) {
     51            $number += 0;
     52        } elseif (is_numeric($number)) {
    5053            $number += 0;
    5154        }
     
    6164        }
    6265
    63         if (is_int($number) || $fail_open) {
    64             return $number;
     66        if (is_int($number)) {
     67            return (int) $number;
     68        } elseif (!$fail_open) {
     69            throw new TypeError(
     70                'Expected an integer.'
     71            );
    6572        }
    66 
    67         throw new TypeError(
    68             'Expected an integer.'
    69         );
     73        return $number;
    7074    }
    7175}
Note: See TracChangeset for help on using the changeset viewer.