Completed
Push — master ( d99bf9...491baf )
by Stephen
13:47
created
src/wp-includes/Requests/Cookie/Jar.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @return string Item value
72 72
 	 */
73 73
 	public function offsetGet($key) {
74
-		if (!isset($this->cookies[$key])) {
74
+		if ( ! isset($this->cookies[$key])) {
75 75
 			return null;
76 76
 		}
77 77
 
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 * @param array $options
135 135
 	 */
136 136
 	public function before_request($url, &$headers, &$data, &$type, &$options) {
137
-		if (!$url instanceof Requests_IRI) {
137
+		if ( ! $url instanceof Requests_IRI) {
138 138
 			$url = new Requests_IRI($url);
139 139
 		}
140 140
 
141
-		if (!empty($this->cookies)) {
141
+		if ( ! empty($this->cookies)) {
142 142
 			$cookies = array();
143 143
 			foreach ($this->cookies as $key => $cookie) {
144 144
 				$cookie = $this->normalize_cookie($cookie, $key);
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @var Requests_Response $response
164 164
 	 */
165
-	public function before_redirect_check(Requests_Response &$return) {
165
+	public function before_redirect_check(Requests_Response & $return) {
166 166
 		$url = $return->url;
167
-		if (!$url instanceof Requests_IRI) {
167
+		if ( ! $url instanceof Requests_IRI) {
168 168
 			$url = new Requests_IRI($url);
169 169
 		}
170 170
 
Please login to merge, or discard this patch.
src/wp-includes/Requests/Transport/fsockopen.php 2 patches
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -90,8 +90,7 @@  discard block
 block discarded – undo
90 90
 			if (isset($options['verify'])) {
91 91
 				if ($options['verify'] === false) {
92 92
 					$context_options['verify_peer'] = false;
93
-				}
94
-				elseif (is_string($options['verify'])) {
93
+				} elseif (is_string($options['verify'])) {
95 94
 					$context_options['cafile'] = $options['verify'];
96 95
 				}
97 96
 			}
@@ -101,8 +100,7 @@  discard block
 block discarded – undo
101 100
 			}
102 101
 
103 102
 			stream_context_set_option($context, array('ssl' => $context_options));
104
-		}
105
-		else {
103
+		} else {
106 104
 			$remote_socket = 'tcp://' . $host;
107 105
 		}
108 106
 
@@ -139,8 +137,7 @@  discard block
 block discarded – undo
139 137
 		if ($data_format === 'query') {
140 138
 			$path = self::format_get($url_parts, $data);
141 139
 			$data = '';
142
-		}
143
-		else {
140
+		} else {
144 141
 			$path = self::format_get($url_parts, array());
145 142
 		}
146 143
 
@@ -152,8 +149,7 @@  discard block
 block discarded – undo
152 149
 		if ($options['type'] !== Requests::TRACE) {
153 150
 			if (is_array($data)) {
154 151
 				$request_body = http_build_query($data, null, '&');
155
-			}
156
-			else {
152
+			} else {
157 153
 				$request_body = $data;
158 154
 			}
159 155
 
@@ -219,8 +215,7 @@  discard block
 block discarded – undo
219 215
 		$timeout_sec = (int) floor($options['timeout']);
220 216
 		if ($timeout_sec == $options['timeout']) {
221 217
 			$timeout_msec = 0;
222
-		}
223
-		else {
218
+		} else {
224 219
 			$timeout_msec = self::SECOND_IN_MICROSECONDS * $options['timeout'] % self::SECOND_IN_MICROSECONDS;
225 220
 		}
226 221
 		stream_set_timeout($socket, $timeout_sec, $timeout_msec);
@@ -268,8 +263,7 @@  discard block
 block discarded – undo
268 263
 				$size += strlen($block);
269 264
 				if ($download) {
270 265
 					fwrite($download, $block);
271
-				}
272
-				else {
266
+				} else {
273 267
 					$body .= $block;
274 268
 				}
275 269
 			}
@@ -278,8 +272,7 @@  discard block
 block discarded – undo
278 272
 
279 273
 		if ($download) {
280 274
 			fclose($download);
281
-		}
282
-		else {
275
+		} else {
283 276
 			$this->headers .= "\r\n\r\n" . $body;
284 277
 		}
285 278
 		fclose($socket);
@@ -304,8 +297,7 @@  discard block
 block discarded – undo
304 297
 				$responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']);
305 298
 
306 299
 				$request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request));
307
-			}
308
-			catch (Requests_Exception $e) {
300
+			} catch (Requests_Exception $e) {
309 301
 				$responses[$id] = $e;
310 302
 			}
311 303
 
@@ -356,12 +348,10 @@  discard block
 block discarded – undo
356 348
 		if (isset($url_parts['path'])) {
357 349
 			if (isset($url_parts['query'])) {
358 350
 				$get = $url_parts['path'] . '?' . $url_parts['query'];
359
-			}
360
-			else {
351
+			} else {
361 352
 				$get = $url_parts['path'];
362 353
 			}
363
-		}
364
-		else {
354
+		} else {
365 355
 			$get = '/';
366 356
 		}
367 357
 		return $get;
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 
70 70
 		// HTTPS support
71 71
 		if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
72
-			$remote_socket = 'ssl://' . $host;
73
-			if (!isset($url_parts['port'])) {
72
+			$remote_socket = 'ssl://'.$host;
73
+			if ( ! isset($url_parts['port'])) {
74 74
 				$url_parts['port'] = 443;
75 75
 			}
76 76
 
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 			stream_context_set_option($context, array('ssl' => $context_options));
107 107
 		}
108 108
 		else {
109
-			$remote_socket = 'tcp://' . $host;
109
+			$remote_socket = 'tcp://'.$host;
110 110
 		}
111 111
 
112 112
 		$this->max_bytes = $options['max_bytes'];
113 113
 
114
-		if (!isset($url_parts['port'])) {
114
+		if ( ! isset($url_parts['port'])) {
115 115
 			$url_parts['port'] = 80;
116 116
 		}
117
-		$remote_socket .= ':' . $url_parts['port'];
117
+		$remote_socket .= ':'.$url_parts['port'];
118 118
 
119 119
 		set_error_handler(array($this, 'connect_error_handler'), E_WARNING | E_NOTICE);
120 120
 
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 
125 125
 		restore_error_handler();
126 126
 
127
-		if ($verifyname && !$this->verify_certificate_from_context($host, $context)) {
127
+		if ($verifyname && ! $this->verify_certificate_from_context($host, $context)) {
128 128
 			throw new Requests_Exception('SSL certificate did not match the requested domain name', 'ssl.no_match');
129 129
 		}
130 130
 
131
-		if (!$socket) {
131
+		if ( ! $socket) {
132 132
 			if ($errno === 0) {
133 133
 				// Connection issue
134 134
 				throw new Requests_Exception(rtrim($this->connect_error), 'fsockopen.connect_error');
@@ -160,39 +160,39 @@  discard block
 block discarded – undo
160 160
 				$request_body = $data;
161 161
 			}
162 162
 
163
-			if (!empty($data)) {
164
-				if (!isset($case_insensitive_headers['Content-Length'])) {
163
+			if ( ! empty($data)) {
164
+				if ( ! isset($case_insensitive_headers['Content-Length'])) {
165 165
 					$headers['Content-Length'] = strlen($request_body);
166 166
 				}
167 167
 
168
-				if (!isset($case_insensitive_headers['Content-Type'])) {
168
+				if ( ! isset($case_insensitive_headers['Content-Type'])) {
169 169
 					$headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
170 170
 				}
171 171
 			}
172 172
 		}
173 173
 
174
-		if (!isset($case_insensitive_headers['Host'])) {
174
+		if ( ! isset($case_insensitive_headers['Host'])) {
175 175
 			$out .= sprintf('Host: %s', $url_parts['host']);
176 176
 
177
-			if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) {
178
-				$out .= ':' . $url_parts['port'];
177
+			if (('http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80) || ('https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443)) {
178
+				$out .= ':'.$url_parts['port'];
179 179
 			}
180 180
 			$out .= "\r\n";
181 181
 		}
182 182
 
183
-		if (!isset($case_insensitive_headers['User-Agent'])) {
183
+		if ( ! isset($case_insensitive_headers['User-Agent'])) {
184 184
 			$out .= sprintf("User-Agent: %s\r\n", $options['useragent']);
185 185
 		}
186 186
 
187 187
 		$accept_encoding = $this->accept_encoding();
188
-		if (!isset($case_insensitive_headers['Accept-Encoding']) && !empty($accept_encoding)) {
188
+		if ( ! isset($case_insensitive_headers['Accept-Encoding']) && ! empty($accept_encoding)) {
189 189
 			$out .= sprintf("Accept-Encoding: %s\r\n", $accept_encoding);
190 190
 		}
191 191
 
192 192
 		$headers = Requests::flatten($headers);
193 193
 
194
-		if (!empty($headers)) {
195
-			$out .= implode($headers, "\r\n") . "\r\n";
194
+		if ( ! empty($headers)) {
195
+			$out .= implode($headers, "\r\n")."\r\n";
196 196
 		}
197 197
 
198 198
 		$options['hooks']->dispatch('fsockopen.after_headers', array(&$out));
@@ -201,18 +201,18 @@  discard block
 block discarded – undo
201 201
 			$out .= "\r\n";
202 202
 		}
203 203
 
204
-		if (!isset($case_insensitive_headers['Connection'])) {
204
+		if ( ! isset($case_insensitive_headers['Connection'])) {
205 205
 			$out .= "Connection: Close\r\n";
206 206
 		}
207 207
 
208
-		$out .= "\r\n" . $request_body;
208
+		$out .= "\r\n".$request_body;
209 209
 
210 210
 		$options['hooks']->dispatch('fsockopen.before_send', array(&$out));
211 211
 
212 212
 		fwrite($socket, $out);
213 213
 		$options['hooks']->dispatch('fsockopen.after_send', array($out));
214 214
 
215
-		if (!$options['blocking']) {
215
+		if ( ! $options['blocking']) {
216 216
 			fclose($socket);
217 217
 			$fake_headers = '';
218 218
 			$options['hooks']->dispatch('fsockopen.after_request', array(&$fake_headers));
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
 			$download = fopen($options['filename'], 'wb');
238 238
 		}
239 239
 
240
-		while (!feof($socket)) {
240
+		while ( ! feof($socket)) {
241 241
 			$this->info = stream_get_meta_data($socket);
242 242
 			if ($this->info['timed_out']) {
243 243
 				throw new Requests_Exception('fsocket timed out', 'timeout');
244 244
 			}
245 245
 
246 246
 			$block = fread($socket, Requests::BUFFER_SIZE);
247
-			if (!$doingbody) {
247
+			if ( ! $doingbody) {
248 248
 				$response .= $block;
249 249
 				if (strpos($response, "\r\n\r\n")) {
250 250
 					list($headers, $block) = explode("\r\n\r\n", $response, 2);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 			fclose($download);
284 284
 		}
285 285
 		else {
286
-			$this->headers .= "\r\n\r\n" . $body;
286
+			$this->headers .= "\r\n\r\n".$body;
287 287
 		}
288 288
 		fclose($socket);
289 289
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 				$responses[$id] = $e;
313 313
 			}
314 314
 
315
-			if (!is_string($responses[$id])) {
315
+			if ( ! is_string($responses[$id])) {
316 316
 				$request['options']['hooks']->dispatch('multiple.request.complete', array(&$responses[$id], $id));
317 317
 			}
318 318
 		}
@@ -348,17 +348,17 @@  discard block
 block discarded – undo
348 348
 	 * @return string URL with data
349 349
 	 */
350 350
 	protected static function format_get($url_parts, $data) {
351
-		if (!empty($data)) {
351
+		if ( ! empty($data)) {
352 352
 			if (empty($url_parts['query'])) {
353 353
 				$url_parts['query'] = '';
354 354
 			}
355 355
 
356
-			$url_parts['query'] .= '&' . http_build_query($data, null, '&');
356
+			$url_parts['query'] .= '&'.http_build_query($data, null, '&');
357 357
 			$url_parts['query'] = trim($url_parts['query'], '&');
358 358
 		}
359 359
 		if (isset($url_parts['path'])) {
360 360
 			if (isset($url_parts['query'])) {
361
-				$get = $url_parts['path'] . '?' . $url_parts['query'];
361
+				$get = $url_parts['path'].'?'.$url_parts['query'];
362 362
 			}
363 363
 			else {
364 364
 				$get = $url_parts['path'];
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 			return false;
384 384
 		}
385 385
 
386
-		$this->connect_error .= $errstr . "\n";
386
+		$this->connect_error .= $errstr."\n";
387 387
 		return true;
388 388
 	}
389 389
 
@@ -423,13 +423,13 @@  discard block
 block discarded – undo
423 423
 	 * @return boolean True if the transport is valid, false otherwise.
424 424
 	 */
425 425
 	public static function test($capabilities = array()) {
426
-		if (!function_exists('fsockopen')) {
426
+		if ( ! function_exists('fsockopen')) {
427 427
 			return false;
428 428
 		}
429 429
 
430 430
 		// If needed, check that streams support SSL
431 431
 		if (isset($capabilities['ssl']) && $capabilities['ssl']) {
432
-			if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) {
432
+			if ( ! extension_loaded('openssl') || ! function_exists('openssl_x509_parse')) {
433 433
 				return false;
434 434
 			}
435 435
 
Please login to merge, or discard this patch.
src/wp-includes/Requests/Hooks.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,10 +35,10 @@
 block discarded – undo
35 35
 	 * @param int $priority Priority number. <0 is executed earlier, >0 is executed later
36 36
 	 */
37 37
 	public function register($hook, $callback, $priority = 0) {
38
-		if (!isset($this->hooks[$hook])) {
38
+		if ( ! isset($this->hooks[$hook])) {
39 39
 			$this->hooks[$hook] = array();
40 40
 		}
41
-		if (!isset($this->hooks[$hook][$priority])) {
41
+		if ( ! isset($this->hooks[$hook][$priority])) {
42 42
 			$this->hooks[$hook][$priority] = array();
43 43
 		}
44 44
 
Please login to merge, or discard this patch.
src/wp-includes/Requests/IPv6.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 		}
63 63
 		// xxx::xxx
64 64
 		else {
65
-			$fill = ':' . str_repeat('0:', 6 - $c2 - $c1);
65
+			$fill = ':'.str_repeat('0:', 6 - $c2 - $c1);
66 66
 			$ip = str_replace('::', $fill, $ip);
67 67
 		}
68 68
 		return $ip;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -106,8 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 		if ($ip_parts[1] !== '') {
108 108
 			return implode(':', $ip_parts);
109
-		}
110
-		else {
109
+		} else {
111 110
 			return $ip_parts[0];
112 111
 		}
113 112
 	}
@@ -130,8 +129,7 @@  discard block
 block discarded – undo
130 129
 			$ipv6_part = substr($ip, 0, $pos);
131 130
 			$ipv4_part = substr($ip, $pos + 1);
132 131
 			return array($ipv6_part, $ipv4_part);
133
-		}
134
-		else {
132
+		} else {
135 133
 			return array($ip, '');
136 134
 		}
137 135
 	}
@@ -182,8 +180,7 @@  discard block
 block discarded – undo
182 180
 				}
183 181
 			}
184 182
 			return true;
185
-		}
186
-		else {
183
+		} else {
187 184
 			return false;
188 185
 		}
189 186
 	}
Please login to merge, or discard this patch.
src/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 */
51 51
 	public function offsetGet($key) {
52 52
 		$key = strtolower($key);
53
-		if (!isset($this->data[$key])) {
53
+		if ( ! isset($this->data[$key])) {
54 54
 			return null;
55 55
 		}
56 56
 
Please login to merge, or discard this patch.
src/wp-includes/random_compat/random_bytes_openssl.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -41,43 +41,43 @@
 block discarded – undo
41 41
  */
42 42
 function random_bytes($bytes)
43 43
 {
44
-    try {
45
-        $bytes = RandomCompat_intval($bytes);
46
-    } catch (TypeError $ex) {
47
-        throw new TypeError(
48
-            'random_bytes(): $bytes must be an integer'
49
-        );
50
-    }
44
+	try {
45
+		$bytes = RandomCompat_intval($bytes);
46
+	} catch (TypeError $ex) {
47
+		throw new TypeError(
48
+			'random_bytes(): $bytes must be an integer'
49
+		);
50
+	}
51 51
 
52
-    if ($bytes < 1) {
53
-        throw new Error(
54
-            'Length must be greater than 0'
55
-        );
56
-    }
52
+	if ($bytes < 1) {
53
+		throw new Error(
54
+			'Length must be greater than 0'
55
+		);
56
+	}
57 57
 
58
-    /**
59
-     * $secure is passed by reference. If it's set to false, fail. Note
60
-     * that this will only return false if this function fails to return
61
-     * any data.
62
-     * 
63
-     * @ref https://github.com/paragonie/random_compat/issues/6#issuecomment-119564973
64
-     */
65
-    $secure = true;
66
-    $buf = openssl_random_pseudo_bytes($bytes, $secure);
67
-    if (
68
-        $buf !== false
69
-        &&
70
-        $secure
71
-        &&
72
-        RandomCompat_strlen($buf) === $bytes
73
-    ) {
74
-        return $buf;
75
-    }
58
+	/**
59
+	 * $secure is passed by reference. If it's set to false, fail. Note
60
+	 * that this will only return false if this function fails to return
61
+	 * any data.
62
+	 * 
63
+	 * @ref https://github.com/paragonie/random_compat/issues/6#issuecomment-119564973
64
+	 */
65
+	$secure = true;
66
+	$buf = openssl_random_pseudo_bytes($bytes, $secure);
67
+	if (
68
+		$buf !== false
69
+		&&
70
+		$secure
71
+		&&
72
+		RandomCompat_strlen($buf) === $bytes
73
+	) {
74
+		return $buf;
75
+	}
76 76
 
77
-    /**
78
-     * If we reach here, PHP has failed us.
79
-     */
80
-    throw new Exception(
81
-        'Could not gather sufficient random data'
82
-    );
77
+	/**
78
+	 * If we reach here, PHP has failed us.
79
+	 */
80
+	throw new Exception(
81
+		'Could not gather sufficient random data'
82
+	);
83 83
 }
Please login to merge, or discard this patch.
src/wp-includes/random_compat/random_bytes_com_dotnet.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -39,43 +39,43 @@
 block discarded – undo
39 39
  */
40 40
 function random_bytes($bytes)
41 41
 {
42
-    try {
43
-        $bytes = RandomCompat_intval($bytes);
44
-    } catch (TypeError $ex) {
45
-        throw new TypeError(
46
-            'random_bytes(): $bytes must be an integer'
47
-        );
48
-    }
42
+	try {
43
+		$bytes = RandomCompat_intval($bytes);
44
+	} catch (TypeError $ex) {
45
+		throw new TypeError(
46
+			'random_bytes(): $bytes must be an integer'
47
+		);
48
+	}
49 49
 
50
-    if ($bytes < 1) {
51
-        throw new Error(
52
-            'Length must be greater than 0'
53
-        );
54
-    }
50
+	if ($bytes < 1) {
51
+		throw new Error(
52
+			'Length must be greater than 0'
53
+		);
54
+	}
55 55
 
56
-    $buf = '';
57
-    $util = new COM('CAPICOM.Utilities.1');
58
-    $execCount = 0;
56
+	$buf = '';
57
+	$util = new COM('CAPICOM.Utilities.1');
58
+	$execCount = 0;
59 59
 
60
-    /**
61
-     * Let's not let it loop forever. If we run N times and fail to
62
-     * get N bytes of random data, then CAPICOM has failed us.
63
-     */
64
-    do {
65
-        $buf .= base64_decode($util->GetRandom($bytes, 0));
66
-        if (RandomCompat_strlen($buf) >= $bytes) {
67
-            /**
68
-             * Return our random entropy buffer here:
69
-             */
70
-            return RandomCompat_substr($buf, 0, $bytes);
71
-        }
72
-        ++$execCount; 
73
-    } while ($execCount < $bytes);
60
+	/**
61
+	 * Let's not let it loop forever. If we run N times and fail to
62
+	 * get N bytes of random data, then CAPICOM has failed us.
63
+	 */
64
+	do {
65
+		$buf .= base64_decode($util->GetRandom($bytes, 0));
66
+		if (RandomCompat_strlen($buf) >= $bytes) {
67
+			/**
68
+			 * Return our random entropy buffer here:
69
+			 */
70
+			return RandomCompat_substr($buf, 0, $bytes);
71
+		}
72
+		++$execCount; 
73
+	} while ($execCount < $bytes);
74 74
 
75
-    /**
76
-     * If we reach here, PHP has failed us.
77
-     */
78
-    throw new Exception(
79
-        'Could not gather sufficient random data'
80
-    );
75
+	/**
76
+	 * If we reach here, PHP has failed us.
77
+	 */
78
+	throw new Exception(
79
+		'Could not gather sufficient random data'
80
+	);
81 81
 }
Please login to merge, or discard this patch.
src/wp-includes/random_compat/random_bytes_libsodium_legacy.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -41,46 +41,46 @@
 block discarded – undo
41 41
  */
42 42
 function random_bytes($bytes)
43 43
 {
44
-    try {
45
-        $bytes = RandomCompat_intval($bytes);
46
-    } catch (TypeError $ex) {
47
-        throw new TypeError(
48
-            'random_bytes(): $bytes must be an integer'
49
-        );
50
-    }
44
+	try {
45
+		$bytes = RandomCompat_intval($bytes);
46
+	} catch (TypeError $ex) {
47
+		throw new TypeError(
48
+			'random_bytes(): $bytes must be an integer'
49
+		);
50
+	}
51 51
 
52
-    if ($bytes < 1) {
53
-        throw new Error(
54
-            'Length must be greater than 0'
55
-        );
56
-    }
52
+	if ($bytes < 1) {
53
+		throw new Error(
54
+			'Length must be greater than 0'
55
+		);
56
+	}
57 57
 
58
-    /**
59
-     * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
60
-     * generated in one invocation.
61
-     */
62
-    if ($bytes > 2147483647) {
63
-        $buf = '';
64
-        for ($i = 0; $i < $bytes; $i += 1073741824) {
65
-            $n = ($bytes - $i) > 1073741824
66
-                ? 1073741824
67
-                : $bytes - $i;
68
-            $buf .= Sodium::randombytes_buf($n);
69
-        }
70
-    } else {
71
-        $buf = Sodium::randombytes_buf($bytes);
72
-    }
58
+	/**
59
+	 * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
60
+	 * generated in one invocation.
61
+	 */
62
+	if ($bytes > 2147483647) {
63
+		$buf = '';
64
+		for ($i = 0; $i < $bytes; $i += 1073741824) {
65
+			$n = ($bytes - $i) > 1073741824
66
+				? 1073741824
67
+				: $bytes - $i;
68
+			$buf .= Sodium::randombytes_buf($n);
69
+		}
70
+	} else {
71
+		$buf = Sodium::randombytes_buf($bytes);
72
+	}
73 73
 
74
-    if ($buf !== false) {
75
-        if (RandomCompat_strlen($buf) === $bytes) {
76
-            return $buf;
77
-        }
78
-    }
74
+	if ($buf !== false) {
75
+		if (RandomCompat_strlen($buf) === $bytes) {
76
+			return $buf;
77
+		}
78
+	}
79 79
 
80
-    /**
81
-     * If we reach here, PHP has failed us.
82
-     */
83
-    throw new Exception(
84
-        'Could not gather sufficient random data'
85
-    );
80
+	/**
81
+	 * If we reach here, PHP has failed us.
82
+	 */
83
+	throw new Exception(
84
+		'Could not gather sufficient random data'
85
+	);
86 86
 }
Please login to merge, or discard this patch.
src/wp-includes/random_compat/random_bytes_mcrypt.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -41,36 +41,36 @@
 block discarded – undo
41 41
  */
42 42
 function random_bytes($bytes)
43 43
 {
44
-    try {
45
-        $bytes = RandomCompat_intval($bytes);
46
-    } catch (TypeError $ex) {
47
-        throw new TypeError(
48
-            'random_bytes(): $bytes must be an integer'
49
-        );
50
-    }
44
+	try {
45
+		$bytes = RandomCompat_intval($bytes);
46
+	} catch (TypeError $ex) {
47
+		throw new TypeError(
48
+			'random_bytes(): $bytes must be an integer'
49
+		);
50
+	}
51 51
 
52
-    if ($bytes < 1) {
53
-        throw new Error(
54
-            'Length must be greater than 0'
55
-        );
56
-    }
52
+	if ($bytes < 1) {
53
+		throw new Error(
54
+			'Length must be greater than 0'
55
+		);
56
+	}
57 57
 
58
-    $buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
59
-    if (
60
-        $buf !== false
61
-        &&
62
-        RandomCompat_strlen($buf) === $bytes
63
-    ) {
64
-        /**
65
-         * Return our random entropy buffer here:
66
-         */
67
-        return $buf;
68
-    }
58
+	$buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
59
+	if (
60
+		$buf !== false
61
+		&&
62
+		RandomCompat_strlen($buf) === $bytes
63
+	) {
64
+		/**
65
+		 * Return our random entropy buffer here:
66
+		 */
67
+		return $buf;
68
+	}
69 69
 
70
-    /**
71
-     * If we reach here, PHP has failed us.
72
-     */
73
-    throw new Exception(
74
-        'Could not gather sufficient random data'
75
-    );
70
+	/**
71
+	 * If we reach here, PHP has failed us.
72
+	 */
73
+	throw new Exception(
74
+		'Could not gather sufficient random data'
75
+	);
76 76
 }
Please login to merge, or discard this patch.