@@ -1997,7 +1997,9 @@ |
||
| 1997 | 1997 | // Remove anything that isn't actually new from our list of files |
| 1998 | 1998 | foreach ($to_unset as $key => $ids) |
| 1999 | 1999 | { |
| 2000 | - if (array_reduce($ids, function ($carry, $item) { return $carry * $item; }, true) == true) |
|
| 2000 | + if (array_reduce($ids, function ($carry, $item) |
|
| 2001 | + { |
|
| 2002 | +return $carry * $item; }, true) == true) |
|
| 2001 | 2003 | unset($smiley_files[$key]); |
| 2002 | 2004 | } |
| 2003 | 2005 | |
@@ -302,7 +302,6 @@ discard block |
||
| 302 | 302 | $condition = 'id_member IN ({array_int:members})'; |
| 303 | 303 | $parameters['members'] = $members; |
| 304 | 304 | } |
| 305 | - |
|
| 306 | 305 | elseif ($members === null) |
| 307 | 306 | $condition = '1=1'; |
| 308 | 307 | |
@@ -1970,7 +1969,7 @@ discard block |
||
| 1970 | 1969 | 'tag' => 'cowsay', |
| 1971 | 1970 | 'parameters' => array( |
| 1972 | 1971 | 'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function ($eyes) use ($smcFunc) |
| 1973 | - { |
|
| 1972 | + { |
|
| 1974 | 1973 | static $css_added; |
| 1975 | 1974 | |
| 1976 | 1975 | if (empty($css_added)) |
@@ -1987,7 +1986,7 @@ discard block |
||
| 1987 | 1986 | }, |
| 1988 | 1987 | ), |
| 1989 | 1988 | 't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => ' ', 'validate' => function ($tongue) use ($smcFunc) |
| 1990 | - { |
|
| 1989 | + { |
|
| 1991 | 1990 | return $smcFunc['substr']($tongue . ' ', 0, 2); |
| 1992 | 1991 | }, |
| 1993 | 1992 | ), |
@@ -3087,7 +3086,7 @@ discard block |
||
| 3087 | 3086 | |
| 3088 | 3087 | // Replace away! |
| 3089 | 3088 | $message = preg_replace_callback($smileyPregSearch, function($matches) use ($smileyPregReplacements) |
| 3090 | - { |
|
| 3089 | + { |
|
| 3091 | 3090 | return $smileyPregReplacements[$matches[1]]; |
| 3092 | 3091 | }, $message); |
| 3093 | 3092 | } |
@@ -3873,7 +3872,6 @@ discard block |
||
| 3873 | 3872 | if (!isset($minSeed) && isset($js_file['options']['seed'])) |
| 3874 | 3873 | $minSeed = $js_file['options']['seed']; |
| 3875 | 3874 | } |
| 3876 | - |
|
| 3877 | 3875 | else |
| 3878 | 3876 | echo ' |
| 3879 | 3877 | <script src="', $js_file['fileUrl'], isset($file['options']['seed']) ? $file['options']['seed'] : '', '"', !empty($js_file['options']['async']) ? ' async' : '', !empty($js_file['options']['defer']) ? ' defer' : '', '></script>'; |
@@ -6026,7 +6024,6 @@ discard block |
||
| 6026 | 6024 | $isWritable = true; |
| 6027 | 6025 | break; |
| 6028 | 6026 | } |
| 6029 | - |
|
| 6030 | 6027 | else |
| 6031 | 6028 | @chmod($file, $val); |
| 6032 | 6029 | } |
@@ -94,7 +94,8 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $input = mb_strtolower($input, $this->encoding); |
| 96 | 96 | $parts = explode('.', $input); |
| 97 | - foreach ($parts as &$part) { |
|
| 97 | + foreach ($parts as &$part) |
|
| 98 | + { |
|
| 98 | 99 | $part = $this->encodePart($part); |
| 99 | 100 | } |
| 100 | 101 | $output = implode('.', $parts); |
@@ -119,13 +120,16 @@ discard block |
||
| 119 | 120 | $h = $b = count($codePoints['basic']); |
| 120 | 121 | |
| 121 | 122 | $output = ''; |
| 122 | - foreach ($codePoints['basic'] as $code) { |
|
| 123 | + foreach ($codePoints['basic'] as $code) |
|
| 124 | + { |
|
| 123 | 125 | $output .= $this->codePointToChar($code); |
| 124 | 126 | } |
| 125 | - if ($input === $output) { |
|
| 127 | + if ($input === $output) |
|
| 128 | + { |
|
| 126 | 129 | return $output; |
| 127 | 130 | } |
| 128 | - if ($b > 0) { |
|
| 131 | + if ($b > 0) |
|
| 132 | + { |
|
| 129 | 133 | $output .= static::DELIMITER; |
| 130 | 134 | } |
| 131 | 135 | |
@@ -134,20 +138,26 @@ discard block |
||
| 134 | 138 | |
| 135 | 139 | $i = 0; |
| 136 | 140 | $length = mb_strlen($input, $this->encoding); |
| 137 | - while ($h < $length) { |
|
| 141 | + while ($h < $length) |
|
| 142 | + { |
|
| 138 | 143 | $m = $codePoints['nonBasic'][$i++]; |
| 139 | 144 | $delta = $delta + ($m - $n) * ($h + 1); |
| 140 | 145 | $n = $m; |
| 141 | 146 | |
| 142 | - foreach ($codePoints['all'] as $c) { |
|
| 143 | - if ($c < $n || $c < static::INITIAL_N) { |
|
| 147 | + foreach ($codePoints['all'] as $c) |
|
| 148 | + { |
|
| 149 | + if ($c < $n || $c < static::INITIAL_N) |
|
| 150 | + { |
|
| 144 | 151 | $delta++; |
| 145 | 152 | } |
| 146 | - if ($c === $n) { |
|
| 153 | + if ($c === $n) |
|
| 154 | + { |
|
| 147 | 155 | $q = $delta; |
| 148 | - for ($k = static::BASE;; $k += static::BASE) { |
|
| 156 | + for ($k = static::BASE;; $k += static::BASE) |
|
| 157 | + { |
|
| 149 | 158 | $t = $this->calculateThreshold($k, $bias); |
| 150 | - if ($q < $t) { |
|
| 159 | + if ($q < $t) |
|
| 160 | + { |
|
| 151 | 161 | break; |
| 152 | 162 | } |
| 153 | 163 | |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * SOFTWARE. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!is_callable('random_bytes')) { |
|
| 29 | +if (!is_callable('random_bytes')) |
|
| 30 | +{ |
|
| 30 | 31 | /** |
| 31 | 32 | * Powered by ext/mcrypt (and thankfully NOT libmcrypt) |
| 32 | 33 | * |
@@ -41,16 +42,20 @@ discard block |
||
| 41 | 42 | */ |
| 42 | 43 | function random_bytes($bytes) |
| 43 | 44 | { |
| 44 | - try { |
|
| 45 | + try |
|
| 46 | + { |
|
| 45 | 47 | /** @var int $bytes */ |
| 46 | 48 | $bytes = RandomCompat_intval($bytes); |
| 47 | - } catch (TypeError $ex) { |
|
| 49 | + } |
|
| 50 | + catch (TypeError $ex) |
|
| 51 | + { |
|
| 48 | 52 | throw new TypeError( |
| 49 | 53 | 'random_bytes(): $bytes must be an integer' |
| 50 | 54 | ); |
| 51 | 55 | } |
| 52 | 56 | |
| 53 | - if ($bytes < 1) { |
|
| 57 | + if ($bytes < 1) |
|
| 58 | + { |
|
| 54 | 59 | throw new Error( |
| 55 | 60 | 'Length must be greater than 0' |
| 56 | 61 | ); |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * SOFTWARE. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!is_callable('random_bytes')) { |
|
| 29 | +if (!is_callable('random_bytes')) |
|
| 30 | +{ |
|
| 30 | 31 | /** |
| 31 | 32 | * Windows with PHP < 5.3.0 will not have the function |
| 32 | 33 | * openssl_random_pseudo_bytes() available, so let's use |
@@ -40,16 +41,20 @@ discard block |
||
| 40 | 41 | */ |
| 41 | 42 | function random_bytes($bytes) |
| 42 | 43 | { |
| 43 | - try { |
|
| 44 | + try |
|
| 45 | + { |
|
| 44 | 46 | /** @var int $bytes */ |
| 45 | 47 | $bytes = RandomCompat_intval($bytes); |
| 46 | - } catch (TypeError $ex) { |
|
| 48 | + } |
|
| 49 | + catch (TypeError $ex) |
|
| 50 | + { |
|
| 47 | 51 | throw new TypeError( |
| 48 | 52 | 'random_bytes(): $bytes must be an integer' |
| 49 | 53 | ); |
| 50 | 54 | } |
| 51 | 55 | |
| 52 | - if ($bytes < 1) { |
|
| 56 | + if ($bytes < 1) |
|
| 57 | + { |
|
| 53 | 58 | throw new Error( |
| 54 | 59 | 'Length must be greater than 0' |
| 55 | 60 | ); |
@@ -57,7 +62,8 @@ discard block |
||
| 57 | 62 | |
| 58 | 63 | /** @var string $buf */ |
| 59 | 64 | $buf = ''; |
| 60 | - if (!class_exists('COM')) { |
|
| 65 | + if (!class_exists('COM')) |
|
| 66 | + { |
|
| 61 | 67 | throw new Error( |
| 62 | 68 | 'COM does not exist' |
| 63 | 69 | ); |
@@ -72,7 +78,8 @@ discard block |
||
| 72 | 78 | */ |
| 73 | 79 | do { |
| 74 | 80 | $buf .= base64_decode((string) $util->GetRandom($bytes, 0)); |
| 75 | - if (RandomCompat_strlen($buf) >= $bytes) { |
|
| 81 | + if (RandomCompat_strlen($buf) >= $bytes) |
|
| 82 | + { |
|
| 76 | 83 | /** |
| 77 | 84 | * Return our random entropy buffer here: |
| 78 | 85 | */ |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * SOFTWARE. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!is_callable('random_bytes')) { |
|
| 29 | +if (!is_callable('random_bytes')) |
|
| 30 | +{ |
|
| 30 | 31 | /** |
| 31 | 32 | * If the libsodium PHP extension is loaded, we'll use it above any other |
| 32 | 33 | * solution. |
@@ -42,16 +43,20 @@ discard block |
||
| 42 | 43 | */ |
| 43 | 44 | function random_bytes($bytes) |
| 44 | 45 | { |
| 45 | - try { |
|
| 46 | + try |
|
| 47 | + { |
|
| 46 | 48 | /** @var int $bytes */ |
| 47 | 49 | $bytes = RandomCompat_intval($bytes); |
| 48 | - } catch (TypeError $ex) { |
|
| 50 | + } |
|
| 51 | + catch (TypeError $ex) |
|
| 52 | + { |
|
| 49 | 53 | throw new TypeError( |
| 50 | 54 | 'random_bytes(): $bytes must be an integer' |
| 51 | 55 | ); |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | - if ($bytes < 1) { |
|
| 58 | + if ($bytes < 1) |
|
| 59 | + { |
|
| 55 | 60 | throw new Error( |
| 56 | 61 | 'Length must be greater than 0' |
| 57 | 62 | ); |
@@ -66,19 +71,25 @@ discard block |
||
| 66 | 71 | * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be |
| 67 | 72 | * generated in one invocation. |
| 68 | 73 | */ |
| 69 | - if ($bytes > 2147483647) { |
|
| 70 | - for ($i = 0; $i < $bytes; $i += 1073741824) { |
|
| 74 | + if ($bytes > 2147483647) |
|
| 75 | + { |
|
| 76 | + for ($i = 0; $i < $bytes; $i += 1073741824) |
|
| 77 | + { |
|
| 71 | 78 | $n = ($bytes - $i) > 1073741824 |
| 72 | 79 | ? 1073741824 |
| 73 | 80 | : $bytes - $i; |
| 74 | 81 | $buf .= Sodium::randombytes_buf((int) $n); |
| 75 | 82 | } |
| 76 | - } else { |
|
| 83 | + } |
|
| 84 | + else |
|
| 85 | + { |
|
| 77 | 86 | $buf .= Sodium::randombytes_buf((int) $bytes); |
| 78 | 87 | } |
| 79 | 88 | |
| 80 | - if (is_string($buf)) { |
|
| 81 | - if (RandomCompat_strlen($buf) === $bytes) { |
|
| 89 | + if (is_string($buf)) |
|
| 90 | + { |
|
| 91 | + if (RandomCompat_strlen($buf) === $bytes) |
|
| 92 | + { |
|
| 82 | 93 | return $buf; |
| 83 | 94 | } |
| 84 | 95 | } |
@@ -29,7 +29,8 @@ discard block |
||
| 29 | 29 | * SOFTWARE. |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | -if (!defined('PHP_VERSION_ID')) { |
|
| 32 | +if (!defined('PHP_VERSION_ID')) |
|
| 33 | +{ |
|
| 33 | 34 | // This constant was introduced in PHP 5.2.7 |
| 34 | 35 | $RandomCompatversion = array_map('intval', explode('.', PHP_VERSION)); |
| 35 | 36 | define( |
@@ -44,11 +45,13 @@ discard block |
||
| 44 | 45 | /** |
| 45 | 46 | * PHP 7.0.0 and newer have these functions natively. |
| 46 | 47 | */ |
| 47 | -if (PHP_VERSION_ID >= 70000) { |
|
| 48 | +if (PHP_VERSION_ID >= 70000) |
|
| 49 | +{ |
|
| 48 | 50 | return; |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | -if (!defined('RANDOM_COMPAT_READ_BUFFER')) { |
|
| 53 | +if (!defined('RANDOM_COMPAT_READ_BUFFER')) |
|
| 54 | +{ |
|
| 52 | 55 | define('RANDOM_COMPAT_READ_BUFFER', 8); |
| 53 | 56 | } |
| 54 | 57 | |
@@ -58,7 +61,8 @@ discard block |
||
| 58 | 61 | require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'cast_to_int.php'; |
| 59 | 62 | require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'error_polyfill.php'; |
| 60 | 63 | |
| 61 | -if (!is_callable('random_bytes')) { |
|
| 64 | +if (!is_callable('random_bytes')) |
|
| 65 | +{ |
|
| 62 | 66 | /** |
| 63 | 67 | * PHP 5.2.0 - 5.6.x way to implement random_bytes() |
| 64 | 68 | * |
@@ -73,11 +77,15 @@ discard block |
||
| 73 | 77 | * |
| 74 | 78 | * See RATIONALE.md for our reasoning behind this particular order |
| 75 | 79 | */ |
| 76 | - if (extension_loaded('libsodium')) { |
|
| 80 | + if (extension_loaded('libsodium')) |
|
| 81 | + { |
|
| 77 | 82 | // See random_bytes_libsodium.php |
| 78 | - if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { |
|
| 83 | + if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) |
|
| 84 | + { |
|
| 79 | 85 | require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium.php'; |
| 80 | - } elseif (method_exists('Sodium', 'randombytes_buf')) { |
|
| 86 | + } |
|
| 87 | + elseif (method_exists('Sodium', 'randombytes_buf')) |
|
| 88 | + { |
|
| 81 | 89 | require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium_legacy.php'; |
| 82 | 90 | } |
| 83 | 91 | } |
@@ -85,13 +93,15 @@ discard block |
||
| 85 | 93 | /** |
| 86 | 94 | * Reading directly from /dev/urandom: |
| 87 | 95 | */ |
| 88 | - if (DIRECTORY_SEPARATOR === '/') { |
|
| 96 | + if (DIRECTORY_SEPARATOR === '/') |
|
| 97 | + { |
|
| 89 | 98 | // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast |
| 90 | 99 | // way to exclude Windows. |
| 91 | 100 | $RandomCompatUrandom = true; |
| 92 | 101 | $RandomCompat_basedir = ini_get('open_basedir'); |
| 93 | 102 | |
| 94 | - if (!empty($RandomCompat_basedir)) { |
|
| 103 | + if (!empty($RandomCompat_basedir)) |
|
| 104 | + { |
|
| 95 | 105 | $RandomCompat_open_basedir = explode( |
| 96 | 106 | PATH_SEPARATOR, |
| 97 | 107 | strtolower($RandomCompat_basedir) |
@@ -121,7 +131,9 @@ discard block |
||
| 121 | 131 | } |
| 122 | 132 | // Unset variables after use |
| 123 | 133 | $RandomCompat_basedir = null; |
| 124 | - } else { |
|
| 134 | + } |
|
| 135 | + else |
|
| 136 | + { |
|
| 125 | 137 | $RandomCompatUrandom = false; |
| 126 | 138 | } |
| 127 | 139 | |
@@ -179,14 +191,19 @@ discard block |
||
| 179 | 191 | strtolower(ini_get('disable_classes')) |
| 180 | 192 | ); |
| 181 | 193 | |
| 182 | - if (!in_array('com', $RandomCompat_disabled_classes)) { |
|
| 183 | - try { |
|
| 194 | + if (!in_array('com', $RandomCompat_disabled_classes)) |
|
| 195 | + { |
|
| 196 | + try |
|
| 197 | + { |
|
| 184 | 198 | $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); |
| 185 | - if (method_exists($RandomCompatCOMtest, 'GetRandom')) { |
|
| 199 | + if (method_exists($RandomCompatCOMtest, 'GetRandom')) |
|
| 200 | + { |
|
| 186 | 201 | // See random_bytes_com_dotnet.php |
| 187 | 202 | require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_com_dotnet.php'; |
| 188 | 203 | } |
| 189 | - } catch (com_exception $e) { |
|
| 204 | + } |
|
| 205 | + catch (com_exception $e) |
|
| 206 | + { |
|
| 190 | 207 | // Don't try to use it. |
| 191 | 208 | } |
| 192 | 209 | } |
@@ -197,7 +214,8 @@ discard block |
||
| 197 | 214 | /** |
| 198 | 215 | * throw new Exception |
| 199 | 216 | */ |
| 200 | - if (!is_callable('random_bytes')) { |
|
| 217 | + if (!is_callable('random_bytes')) |
|
| 218 | + { |
|
| 201 | 219 | /** |
| 202 | 220 | * We don't have any more options, so let's throw an exception right now |
| 203 | 221 | * and hope the developer won't let it fail silently. |
@@ -218,7 +236,8 @@ discard block |
||
| 218 | 236 | } |
| 219 | 237 | } |
| 220 | 238 | |
| 221 | -if (!is_callable('random_int')) { |
|
| 239 | +if (!is_callable('random_int')) |
|
| 240 | +{ |
|
| 222 | 241 | require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_int.php'; |
| 223 | 242 | } |
| 224 | 243 | |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * SOFTWARE. |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!class_exists('Error', false)) { |
|
| 29 | +if (!class_exists('Error', false)) |
|
| 30 | +{ |
|
| 30 | 31 | // We can't really avoid making this extend Exception in PHP 5. |
| 31 | 32 | class Error extends Exception |
| 32 | 33 | { |
@@ -34,13 +35,17 @@ discard block |
||
| 34 | 35 | } |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | -if (!class_exists('TypeError', false)) { |
|
| 38 | - if (is_subclass_of('Error', 'Exception')) { |
|
| 38 | +if (!class_exists('TypeError', false)) |
|
| 39 | +{ |
|
| 40 | + if (is_subclass_of('Error', 'Exception')) |
|
| 41 | + { |
|
| 39 | 42 | class TypeError extends Error |
| 40 | 43 | { |
| 41 | 44 | |
| 42 | 45 | } |
| 43 | - } else { |
|
| 46 | + } |
|
| 47 | + else |
|
| 48 | + { |
|
| 44 | 49 | class TypeError extends Exception |
| 45 | 50 | { |
| 46 | 51 | |
@@ -1,6 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!is_callable('random_int')) { |
|
| 3 | +if (!is_callable('random_int')) |
|
| 4 | +{ |
|
| 4 | 5 | /** |
| 5 | 6 | * Random_* Compatibility Library |
| 6 | 7 | * for using the new PHP 7 random_* API in PHP 5 projects |
@@ -50,19 +51,25 @@ discard block |
||
| 50 | 51 | * through. |
| 51 | 52 | */ |
| 52 | 53 | |
| 53 | - try { |
|
| 54 | + try |
|
| 55 | + { |
|
| 54 | 56 | /** @var int $min */ |
| 55 | 57 | $min = RandomCompat_intval($min); |
| 56 | - } catch (TypeError $ex) { |
|
| 58 | + } |
|
| 59 | + catch (TypeError $ex) |
|
| 60 | + { |
|
| 57 | 61 | throw new TypeError( |
| 58 | 62 | 'random_int(): $min must be an integer' |
| 59 | 63 | ); |
| 60 | 64 | } |
| 61 | 65 | |
| 62 | - try { |
|
| 66 | + try |
|
| 67 | + { |
|
| 63 | 68 | /** @var int $max */ |
| 64 | 69 | $max = RandomCompat_intval($max); |
| 65 | - } catch (TypeError $ex) { |
|
| 70 | + } |
|
| 71 | + catch (TypeError $ex) |
|
| 72 | + { |
|
| 66 | 73 | throw new TypeError( |
| 67 | 74 | 'random_int(): $max must be an integer' |
| 68 | 75 | ); |
@@ -73,13 +80,15 @@ discard block |
||
| 73 | 80 | * let's validate the logic then we can move forward with generating random |
| 74 | 81 | * integers along a given range. |
| 75 | 82 | */ |
| 76 | - if ($min > $max) { |
|
| 83 | + if ($min > $max) |
|
| 84 | + { |
|
| 77 | 85 | throw new Error( |
| 78 | 86 | 'Minimum value must be less than or equal to the maximum value' |
| 79 | 87 | ); |
| 80 | 88 | } |
| 81 | 89 | |
| 82 | - if ($max === $min) { |
|
| 90 | + if ($max === $min) |
|
| 91 | + { |
|
| 83 | 92 | return (int) $min; |
| 84 | 93 | } |
| 85 | 94 | |
@@ -110,7 +119,8 @@ discard block |
||
| 110 | 119 | /** |
| 111 | 120 | * Test for integer overflow: |
| 112 | 121 | */ |
| 113 | - if (!is_int($range)) { |
|
| 122 | + if (!is_int($range)) |
|
| 123 | + { |
|
| 114 | 124 | |
| 115 | 125 | /** |
| 116 | 126 | * Still safely calculate wider ranges. |
@@ -127,14 +137,18 @@ discard block |
||
| 127 | 137 | /** @var int $mask */ |
| 128 | 138 | $mask = ~0; |
| 129 | 139 | |
| 130 | - } else { |
|
| 140 | + } |
|
| 141 | + else |
|
| 142 | + { |
|
| 131 | 143 | |
| 132 | 144 | /** |
| 133 | 145 | * $bits is effectively ceil(log($range, 2)) without dealing with |
| 134 | 146 | * type juggling |
| 135 | 147 | */ |
| 136 | - while ($range > 0) { |
|
| 137 | - if ($bits % 8 === 0) { |
|
| 148 | + while ($range > 0) |
|
| 149 | + { |
|
| 150 | + if ($bits % 8 === 0) |
|
| 151 | + { |
|
| 138 | 152 | ++$bytes; |
| 139 | 153 | } |
| 140 | 154 | ++$bits; |
@@ -157,7 +171,8 @@ discard block |
||
| 157 | 171 | * The rejection probability is at most 0.5, so this corresponds |
| 158 | 172 | * to a failure probability of 2^-128 for a working RNG |
| 159 | 173 | */ |
| 160 | - if ($attempts > 128) { |
|
| 174 | + if ($attempts > 128) |
|
| 175 | + { |
|
| 161 | 176 | throw new Exception( |
| 162 | 177 | 'random_int: RNG is broken - too many rejections' |
| 163 | 178 | ); |
@@ -179,7 +194,8 @@ discard block |
||
| 179 | 194 | * 204631455 |
| 180 | 195 | */ |
| 181 | 196 | $val &= 0; |
| 182 | - for ($i = 0; $i < $bytes; ++$i) { |
|
| 197 | + for ($i = 0; $i < $bytes; ++$i) |
|
| 198 | + { |
|
| 183 | 199 | $val |= ord($randomByteString[$i]) << ($i * 8); |
| 184 | 200 | } |
| 185 | 201 | /** @var int $val */ |