update2
This commit is contained in:
parent
98419bd18d
commit
8a69e45efa
4919 changed files with 28311 additions and 224136 deletions
0
pfosten/vendor/paragonie/random_compat/LICENSE
vendored
Executable file → Normal file
0
pfosten/vendor/paragonie/random_compat/LICENSE
vendored
Executable file → Normal file
1
pfosten/vendor/paragonie/random_compat/composer.json
vendored
Executable file → Normal file
1
pfosten/vendor/paragonie/random_compat/composer.json
vendored
Executable file → Normal file
|
|
@ -4,6 +4,7 @@
|
|||
"keywords": [
|
||||
"csprng",
|
||||
"random",
|
||||
"polyfill",
|
||||
"pseudorandom"
|
||||
],
|
||||
"license": "MIT",
|
||||
|
|
|
|||
0
pfosten/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey
vendored
Executable file → Normal file
0
pfosten/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey
vendored
Executable file → Normal file
0
pfosten/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc
vendored
Executable file → Normal file
0
pfosten/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc
vendored
Executable file → Normal file
34
pfosten/vendor/paragonie/random_compat/lib/byte_safe_strings.php
vendored
Executable file → Normal file
34
pfosten/vendor/paragonie/random_compat/lib/byte_safe_strings.php
vendored
Executable file → Normal file
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -28,8 +28,9 @@
|
|||
|
||||
if (!is_callable('RandomCompat_strlen')) {
|
||||
if (
|
||||
defined('MB_OVERLOAD_STRING') &&
|
||||
ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
|
||||
defined('MB_OVERLOAD_STRING')
|
||||
&&
|
||||
((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING
|
||||
) {
|
||||
/**
|
||||
* strlen() implementation that isn't brittle to mbstring.func_overload
|
||||
|
|
@ -82,8 +83,8 @@ if (!is_callable('RandomCompat_substr')) {
|
|||
|
||||
if (
|
||||
defined('MB_OVERLOAD_STRING')
|
||||
&&
|
||||
ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
|
||||
&&
|
||||
((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING
|
||||
) {
|
||||
/**
|
||||
* substr() implementation that isn't brittle to mbstring.func_overload
|
||||
|
|
@ -93,7 +94,7 @@ if (!is_callable('RandomCompat_substr')) {
|
|||
*
|
||||
* @param string $binary_string
|
||||
* @param int $start
|
||||
* @param int $length (optional)
|
||||
* @param int|null $length (optional)
|
||||
*
|
||||
* @throws TypeError
|
||||
*
|
||||
|
|
@ -118,6 +119,7 @@ if (!is_callable('RandomCompat_substr')) {
|
|||
* mb_substr($str, 0, NULL, '8bit') returns an empty string on
|
||||
* PHP 5.3, so we have to find the length ourselves.
|
||||
*/
|
||||
/** @var int $length */
|
||||
$length = RandomCompat_strlen($binary_string) - $start;
|
||||
} elseif (!is_int($length)) {
|
||||
throw new TypeError(
|
||||
|
|
@ -133,7 +135,12 @@ if (!is_callable('RandomCompat_substr')) {
|
|||
return '';
|
||||
}
|
||||
|
||||
return (string) mb_substr($binary_string, $start, $length, '8bit');
|
||||
return (string) mb_substr(
|
||||
(string) $binary_string,
|
||||
(int) $start,
|
||||
(int) $length,
|
||||
'8bit'
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -145,7 +152,7 @@ if (!is_callable('RandomCompat_substr')) {
|
|||
*
|
||||
* @param string $binary_string
|
||||
* @param int $start
|
||||
* @param int $length (optional)
|
||||
* @param int|null $length (optional)
|
||||
*
|
||||
* @throws TypeError
|
||||
*
|
||||
|
|
@ -172,10 +179,17 @@ if (!is_callable('RandomCompat_substr')) {
|
|||
);
|
||||
}
|
||||
|
||||
return (string) substr($binary_string, $start, $length);
|
||||
return (string) substr(
|
||||
(string )$binary_string,
|
||||
(int) $start,
|
||||
(int) $length
|
||||
);
|
||||
}
|
||||
|
||||
return (string) substr($binary_string, $start);
|
||||
return (string) substr(
|
||||
(string) $binary_string,
|
||||
(int) $start
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
pfosten/vendor/paragonie/random_compat/lib/cast_to_int.php
vendored
Executable file → Normal file
11
pfosten/vendor/paragonie/random_compat/lib/cast_to_int.php
vendored
Executable file → Normal file
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -38,9 +38,10 @@ if (!is_callable('RandomCompat_intval')) {
|
|||
* through.
|
||||
*
|
||||
* @param int|float $number The number we want to convert to an int
|
||||
* @param boolean $fail_open Set to true to not throw an exception
|
||||
* @param bool $fail_open Set to true to not throw an exception
|
||||
*
|
||||
* @return float|int
|
||||
* @psalm-suppress InvalidReturnType
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
|
|
@ -49,14 +50,16 @@ if (!is_callable('RandomCompat_intval')) {
|
|||
if (is_int($number) || is_float($number)) {
|
||||
$number += 0;
|
||||
} elseif (is_numeric($number)) {
|
||||
/** @psalm-suppress InvalidOperand */
|
||||
$number += 0;
|
||||
}
|
||||
/** @var int|float $number */
|
||||
|
||||
if (
|
||||
is_float($number)
|
||||
&&
|
||||
&&
|
||||
$number > ~PHP_INT_MAX
|
||||
&&
|
||||
&&
|
||||
$number < PHP_INT_MAX
|
||||
) {
|
||||
$number = (int) $number;
|
||||
|
|
|
|||
2
pfosten/vendor/paragonie/random_compat/lib/error_polyfill.php
vendored
Executable file → Normal file
2
pfosten/vendor/paragonie/random_compat/lib/error_polyfill.php
vendored
Executable file → Normal file
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
28
pfosten/vendor/paragonie/random_compat/lib/random.php
vendored
Executable file → Normal file
28
pfosten/vendor/paragonie/random_compat/lib/random.php
vendored
Executable file → Normal file
|
|
@ -3,12 +3,12 @@
|
|||
* Random_* Compatibility Library
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* @version 2.0.10
|
||||
* @released 2017-03-13
|
||||
* @version 2.0.17
|
||||
* @released 2018-07-04
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -54,9 +54,9 @@ if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
|
|||
|
||||
$RandomCompatDIR = dirname(__FILE__);
|
||||
|
||||
require_once $RandomCompatDIR . '/byte_safe_strings.php';
|
||||
require_once $RandomCompatDIR . '/cast_to_int.php';
|
||||
require_once $RandomCompatDIR . '/error_polyfill.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'byte_safe_strings.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'cast_to_int.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'error_polyfill.php';
|
||||
|
||||
if (!is_callable('random_bytes')) {
|
||||
/**
|
||||
|
|
@ -76,9 +76,9 @@ if (!is_callable('random_bytes')) {
|
|||
if (extension_loaded('libsodium')) {
|
||||
// See random_bytes_libsodium.php
|
||||
if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) {
|
||||
require_once $RandomCompatDIR . '/random_bytes_libsodium.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium.php';
|
||||
} elseif (method_exists('Sodium', 'randombytes_buf')) {
|
||||
require_once $RandomCompatDIR . '/random_bytes_libsodium_legacy.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium_legacy.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ if (!is_callable('random_bytes')) {
|
|||
// place, that is not helpful to us here.
|
||||
|
||||
// See random_bytes_dev_urandom.php
|
||||
require_once $RandomCompatDIR . '/random_bytes_dev_urandom.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_dev_urandom.php';
|
||||
}
|
||||
// Unset variables after use
|
||||
$RandomCompat_basedir = null;
|
||||
|
|
@ -159,7 +159,7 @@ if (!is_callable('random_bytes')) {
|
|||
extension_loaded('mcrypt')
|
||||
) {
|
||||
// See random_bytes_mcrypt.php
|
||||
require_once $RandomCompatDIR . '/random_bytes_mcrypt.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_mcrypt.php';
|
||||
}
|
||||
$RandomCompatUrandom = null;
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ if (!is_callable('random_bytes')) {
|
|||
$RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
|
||||
if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
|
||||
// See random_bytes_com_dotnet.php
|
||||
require_once $RandomCompatDIR . '/random_bytes_com_dotnet.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_com_dotnet.php';
|
||||
}
|
||||
} catch (com_exception $e) {
|
||||
// Don't try to use it.
|
||||
|
|
@ -203,8 +203,9 @@ if (!is_callable('random_bytes')) {
|
|||
* and hope the developer won't let it fail silently.
|
||||
*
|
||||
* @param mixed $length
|
||||
* @return void
|
||||
* @psalm-suppress InvalidReturnType
|
||||
* @throws Exception
|
||||
* @return string
|
||||
*/
|
||||
function random_bytes($length)
|
||||
{
|
||||
|
|
@ -212,12 +213,13 @@ if (!is_callable('random_bytes')) {
|
|||
throw new Exception(
|
||||
'There is no suitable CSPRNG installed on your system'
|
||||
);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_callable('random_int')) {
|
||||
require_once $RandomCompatDIR . '/random_int.php';
|
||||
require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_int.php';
|
||||
}
|
||||
|
||||
$RandomCompatDIR = null;
|
||||
|
|
|
|||
9
pfosten/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php
vendored
Executable file → Normal file
9
pfosten/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php
vendored
Executable file → Normal file
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -41,6 +41,7 @@ if (!is_callable('random_bytes')) {
|
|||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
/** @var int $bytes */
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
|
|
@ -54,12 +55,14 @@ if (!is_callable('random_bytes')) {
|
|||
);
|
||||
}
|
||||
|
||||
/** @var string $buf */
|
||||
$buf = '';
|
||||
if (!class_exists('COM')) {
|
||||
throw new Error(
|
||||
'COM does not exist'
|
||||
);
|
||||
}
|
||||
/** @var COM $util */
|
||||
$util = new COM('CAPICOM.Utilities.1');
|
||||
$execCount = 0;
|
||||
|
||||
|
|
@ -68,12 +71,12 @@ if (!is_callable('random_bytes')) {
|
|||
* get N bytes of random data, then CAPICOM has failed us.
|
||||
*/
|
||||
do {
|
||||
$buf .= base64_decode($util->GetRandom($bytes, 0));
|
||||
$buf .= base64_decode((string) $util->GetRandom($bytes, 0));
|
||||
if (RandomCompat_strlen($buf) >= $bytes) {
|
||||
/**
|
||||
* Return our random entropy buffer here:
|
||||
*/
|
||||
return RandomCompat_substr($buf, 0, $bytes);
|
||||
return (string) RandomCompat_substr($buf, 0, $bytes);
|
||||
}
|
||||
++$execCount;
|
||||
} while ($execCount < $bytes);
|
||||
|
|
|
|||
13
pfosten/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php
vendored
Executable file → Normal file
13
pfosten/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php
vendored
Executable file → Normal file
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -46,7 +46,9 @@ if (!is_callable('random_bytes')) {
|
|||
*/
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
/** @var resource $fp */
|
||||
static $fp = null;
|
||||
|
||||
/**
|
||||
* This block should only be run once
|
||||
*/
|
||||
|
|
@ -55,8 +57,10 @@ if (!is_callable('random_bytes')) {
|
|||
* We use /dev/urandom if it is a char device.
|
||||
* We never fall back to /dev/random
|
||||
*/
|
||||
/** @var resource|bool $fp */
|
||||
$fp = fopen('/dev/urandom', 'rb');
|
||||
if (!empty($fp)) {
|
||||
if (is_resource($fp)) {
|
||||
/** @var array<string, int> $st */
|
||||
$st = fstat($fp);
|
||||
if (($st['mode'] & 0170000) !== 020000) {
|
||||
fclose($fp);
|
||||
|
|
@ -64,7 +68,7 @@ if (!is_callable('random_bytes')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($fp)) {
|
||||
if (is_resource($fp)) {
|
||||
/**
|
||||
* stream_set_read_buffer() does not exist in HHVM
|
||||
*
|
||||
|
|
@ -83,6 +87,7 @@ if (!is_callable('random_bytes')) {
|
|||
}
|
||||
|
||||
try {
|
||||
/** @var int $bytes */
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
|
|
@ -103,7 +108,7 @@ if (!is_callable('random_bytes')) {
|
|||
* if (empty($fp)) line is logic that should only be run once per
|
||||
* page load.
|
||||
*/
|
||||
if (!empty($fp)) {
|
||||
if (is_resource($fp)) {
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
|||
7
pfosten/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php
vendored
Executable file → Normal file
7
pfosten/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php
vendored
Executable file → Normal file
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -43,6 +43,7 @@ if (!is_callable('random_bytes')) {
|
|||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
/** @var int $bytes */
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
|
|
@ -60,6 +61,7 @@ if (!is_callable('random_bytes')) {
|
|||
* \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
|
||||
* generated in one invocation.
|
||||
*/
|
||||
/** @var string|bool $buf */
|
||||
if ($bytes > 2147483647) {
|
||||
$buf = '';
|
||||
for ($i = 0; $i < $bytes; $i += 1073741824) {
|
||||
|
|
@ -69,10 +71,11 @@ if (!is_callable('random_bytes')) {
|
|||
$buf .= \Sodium\randombytes_buf($n);
|
||||
}
|
||||
} else {
|
||||
/** @var string|bool $buf */
|
||||
$buf = \Sodium\randombytes_buf($bytes);
|
||||
}
|
||||
|
||||
if ($buf !== false) {
|
||||
if (is_string($buf)) {
|
||||
if (RandomCompat_strlen($buf) === $bytes) {
|
||||
return $buf;
|
||||
}
|
||||
|
|
|
|||
7
pfosten/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php
vendored
Executable file → Normal file
7
pfosten/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php
vendored
Executable file → Normal file
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -43,6 +43,7 @@ if (!is_callable('random_bytes')) {
|
|||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
/** @var int $bytes */
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
|
|
@ -70,10 +71,10 @@ if (!is_callable('random_bytes')) {
|
|||
$n = ($bytes - $i) > 1073741824
|
||||
? 1073741824
|
||||
: $bytes - $i;
|
||||
$buf .= Sodium::randombytes_buf($n);
|
||||
$buf .= Sodium::randombytes_buf((int) $n);
|
||||
}
|
||||
} else {
|
||||
$buf .= Sodium::randombytes_buf($bytes);
|
||||
$buf .= Sodium::randombytes_buf((int) $bytes);
|
||||
}
|
||||
|
||||
if (is_string($buf)) {
|
||||
|
|
|
|||
10
pfosten/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php
vendored
Executable file → Normal file
10
pfosten/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php
vendored
Executable file → Normal file
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -42,6 +42,7 @@ if (!is_callable('random_bytes')) {
|
|||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
/** @var int $bytes */
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
|
|
@ -55,10 +56,11 @@ if (!is_callable('random_bytes')) {
|
|||
);
|
||||
}
|
||||
|
||||
$buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
|
||||
/** @var string|bool $buf */
|
||||
$buf = @mcrypt_create_iv((int) $bytes, (int) MCRYPT_DEV_URANDOM);
|
||||
if (
|
||||
$buf !== false
|
||||
&&
|
||||
is_string($buf)
|
||||
&&
|
||||
RandomCompat_strlen($buf) === $bytes
|
||||
) {
|
||||
/**
|
||||
|
|
|
|||
20
pfosten/vendor/paragonie/random_compat/lib/random_int.php
vendored
Executable file → Normal file
20
pfosten/vendor/paragonie/random_compat/lib/random_int.php
vendored
Executable file → Normal file
|
|
@ -7,7 +7,7 @@ if (!is_callable('random_int')) {
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -51,6 +51,7 @@ if (!is_callable('random_int')) {
|
|||
*/
|
||||
|
||||
try {
|
||||
/** @var int $min */
|
||||
$min = RandomCompat_intval($min);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
|
|
@ -59,6 +60,7 @@ if (!is_callable('random_int')) {
|
|||
}
|
||||
|
||||
try {
|
||||
/** @var int $max */
|
||||
$max = RandomCompat_intval($max);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
|
|
@ -78,7 +80,7 @@ if (!is_callable('random_int')) {
|
|||
}
|
||||
|
||||
if ($max === $min) {
|
||||
return $min;
|
||||
return (int) $min;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,11 +92,18 @@ if (!is_callable('random_int')) {
|
|||
* so we can minimize the number of discards
|
||||
*/
|
||||
$attempts = $bits = $bytes = $mask = $valueShift = 0;
|
||||
/** @var int $attempts */
|
||||
/** @var int $bits */
|
||||
/** @var int $bytes */
|
||||
/** @var int $mask */
|
||||
/** @var int $valueShift */
|
||||
|
||||
/**
|
||||
* At this point, $range is a positive number greater than 0. It might
|
||||
* overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to
|
||||
* a float and we will lose some precision.
|
||||
*
|
||||
* @var int|float $range
|
||||
*/
|
||||
$range = $max - $min;
|
||||
|
||||
|
|
@ -115,6 +124,7 @@ if (!is_callable('random_int')) {
|
|||
* @ref http://3v4l.org/XX9r5 (64-bit)
|
||||
*/
|
||||
$bytes = PHP_INT_SIZE;
|
||||
/** @var int $mask */
|
||||
$mask = ~0;
|
||||
|
||||
} else {
|
||||
|
|
@ -129,16 +139,19 @@ if (!is_callable('random_int')) {
|
|||
}
|
||||
++$bits;
|
||||
$range >>= 1;
|
||||
/** @var int $mask */
|
||||
$mask = $mask << 1 | 1;
|
||||
}
|
||||
$valueShift = $min;
|
||||
}
|
||||
|
||||
/** @var int $val */
|
||||
$val = 0;
|
||||
/**
|
||||
* Now that we have our parameters set up, let's begin generating
|
||||
* random integers until one falls between $min and $max
|
||||
*/
|
||||
/** @psalm-suppress RedundantCondition */
|
||||
do {
|
||||
/**
|
||||
* The rejection probability is at most 0.5, so this corresponds
|
||||
|
|
@ -169,6 +182,7 @@ if (!is_callable('random_int')) {
|
|||
for ($i = 0; $i < $bytes; ++$i) {
|
||||
$val |= ord($randomByteString[$i]) << ($i * 8);
|
||||
}
|
||||
/** @var int $val */
|
||||
|
||||
/**
|
||||
* Apply mask
|
||||
|
|
@ -185,6 +199,6 @@ if (!is_callable('random_int')) {
|
|||
*/
|
||||
} while (!is_int($val) || $val > $max || $val < $min);
|
||||
|
||||
return (int)$val;
|
||||
return (int) $val;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/paragonie/random_compat/other/build_phar.php
vendored
Executable file → Normal file
0
pfosten/vendor/paragonie/random_compat/other/build_phar.php
vendored
Executable file → Normal file
0
pfosten/vendor/paragonie/random_compat/psalm-autoload.php
vendored
Executable file → Normal file
0
pfosten/vendor/paragonie/random_compat/psalm-autoload.php
vendored
Executable file → Normal file
17
pfosten/vendor/paragonie/random_compat/psalm.xml
vendored
Executable file → Normal file
17
pfosten/vendor/paragonie/random_compat/psalm.xml
vendored
Executable file → Normal file
|
|
@ -1,15 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
autoloader="psalm-autoload.php"
|
||||
stopOnFirstError="false"
|
||||
useDocblockTypes="true"
|
||||
totallyTyped="true"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="lib" />
|
||||
</projectFiles>
|
||||
<issueHandlers>
|
||||
<InvalidOperand errorLevel="info" />
|
||||
<RedundantConditionGivenDocblockType errorLevel="info" />
|
||||
<!-- We have to be explicit because PHP 5 lacks scalar types -->
|
||||
<UnresolvableInclude errorLevel="info" />
|
||||
<!-- Because we put the variants into their own subdirectory -->
|
||||
<DuplicateClass errorLevel="info" />
|
||||
<!-- Later versions of Psalm are only PHP 7 compatible, which
|
||||
sees our redefinition of Error and TypeError as duplicate
|
||||
class errors. -->
|
||||
<UndefinedConstant errorLevel="info" />
|
||||
<!-- The Mcrypt constants aren't defined in PHP 7.2 -->
|
||||
<MissingReturnType errorLevel="info" />
|
||||
<!-- False positive with some versions of (Psalm, PHP) -->
|
||||
<InvalidReturnType errorLevel="info" />
|
||||
<!-- The "last resort" function in lib/random.php -->
|
||||
<MixedInferredReturnType errorLevel="suppress" />
|
||||
<!-- Only used in totallyTyped mode -->
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue