Completed
Pull Request — release-2.1 (#6101)
by Jon
12:48 queued 07:46
created
Sources/random_compat/random_bytes_libsodium.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -27,65 +27,65 @@
 block discarded – undo
27 27
  */
28 28
 
29 29
 if (!is_callable('random_bytes')) {
30
-    /**
31
-     * If the libsodium PHP extension is loaded, we'll use it above any other
32
-     * solution.
33
-     *
34
-     * libsodium-php project:
35
-     * @ref https://github.com/jedisct1/libsodium-php
36
-     *
37
-     * @param int $bytes
38
-     *
39
-     * @throws Exception
40
-     *
41
-     * @return string
42
-     */
43
-    function random_bytes($bytes)
44
-    {
45
-        try {
46
-            /** @var int $bytes */
47
-            $bytes = RandomCompat_intval($bytes);
48
-        } catch (TypeError $ex) {
49
-            throw new TypeError(
50
-                'random_bytes(): $bytes must be an integer'
51
-            );
52
-        }
30
+	/**
31
+	 * If the libsodium PHP extension is loaded, we'll use it above any other
32
+	 * solution.
33
+	 *
34
+	 * libsodium-php project:
35
+	 * @ref https://github.com/jedisct1/libsodium-php
36
+	 *
37
+	 * @param int $bytes
38
+	 *
39
+	 * @throws Exception
40
+	 *
41
+	 * @return string
42
+	 */
43
+	function random_bytes($bytes)
44
+	{
45
+		try {
46
+			/** @var int $bytes */
47
+			$bytes = RandomCompat_intval($bytes);
48
+		} catch (TypeError $ex) {
49
+			throw new TypeError(
50
+				'random_bytes(): $bytes must be an integer'
51
+			);
52
+		}
53 53
 
54
-        if ($bytes < 1) {
55
-            throw new Error(
56
-                'Length must be greater than 0'
57
-            );
58
-        }
54
+		if ($bytes < 1) {
55
+			throw new Error(
56
+				'Length must be greater than 0'
57
+			);
58
+		}
59 59
 
60
-        /**
61
-         * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
62
-         * generated in one invocation.
63
-         */
64
-        /** @var string|bool $buf */
65
-        if ($bytes > 2147483647) {
66
-            $buf = '';
67
-            for ($i = 0; $i < $bytes; $i += 1073741824) {
68
-                $n = ($bytes - $i) > 1073741824
69
-                    ? 1073741824
70
-                    : $bytes - $i;
71
-                $buf .= \Sodium\randombytes_buf($n);
72
-            }
73
-        } else {
74
-            /** @var string|bool $buf */
75
-            $buf = \Sodium\randombytes_buf($bytes);
76
-        }
60
+		/**
61
+		 * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
62
+		 * generated in one invocation.
63
+		 */
64
+		/** @var string|bool $buf */
65
+		if ($bytes > 2147483647) {
66
+			$buf = '';
67
+			for ($i = 0; $i < $bytes; $i += 1073741824) {
68
+				$n = ($bytes - $i) > 1073741824
69
+					? 1073741824
70
+					: $bytes - $i;
71
+				$buf .= \Sodium\randombytes_buf($n);
72
+			}
73
+		} else {
74
+			/** @var string|bool $buf */
75
+			$buf = \Sodium\randombytes_buf($bytes);
76
+		}
77 77
 
78
-        if (is_string($buf)) {
79
-            if (RandomCompat_strlen($buf) === $bytes) {
80
-                return $buf;
81
-            }
82
-        }
78
+		if (is_string($buf)) {
79
+			if (RandomCompat_strlen($buf) === $bytes) {
80
+				return $buf;
81
+			}
82
+		}
83 83
 
84
-        /**
85
-         * If we reach here, PHP has failed us.
86
-         */
87
-        throw new Exception(
88
-            'Could not gather sufficient random data'
89
-        );
90
-    }
84
+		/**
85
+		 * If we reach here, PHP has failed us.
86
+		 */
87
+		throw new Exception(
88
+			'Could not gather sufficient random data'
89
+		);
90
+	}
91 91
 }
Please login to merge, or discard this patch.
Sources/random_compat/cast_to_int.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -28,50 +28,50 @@
 block discarded – undo
28 28
 
29 29
 if (!is_callable('RandomCompat_intval')) {
30 30
 
31
-    /**
32
-     * Cast to an integer if we can, safely.
33
-     *
34
-     * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
35
-     * (non-inclusive), it will sanely cast it to an int. If you it's equal to
36
-     * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats
37
-     * lose precision, so the <= and => operators might accidentally let a float
38
-     * through.
39
-     *
40
-     * @param int|float $number    The number we want to convert to an int
41
-     * @param bool      $fail_open Set to true to not throw an exception
42
-     *
43
-     * @return float|int
44
-     * @psalm-suppress InvalidReturnType
45
-     *
46
-     * @throws TypeError
47
-     */
48
-    function RandomCompat_intval($number, $fail_open = false)
49
-    {
50
-        if (is_int($number) || is_float($number)) {
51
-            $number += 0;
52
-        } elseif (is_numeric($number)) {
53
-            /** @psalm-suppress InvalidOperand */
54
-            $number += 0;
55
-        }
56
-        /** @var int|float $number */
31
+	/**
32
+	 * Cast to an integer if we can, safely.
33
+	 *
34
+	 * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
35
+	 * (non-inclusive), it will sanely cast it to an int. If you it's equal to
36
+	 * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats
37
+	 * lose precision, so the <= and => operators might accidentally let a float
38
+	 * through.
39
+	 *
40
+	 * @param int|float $number    The number we want to convert to an int
41
+	 * @param bool      $fail_open Set to true to not throw an exception
42
+	 *
43
+	 * @return float|int
44
+	 * @psalm-suppress InvalidReturnType
45
+	 *
46
+	 * @throws TypeError
47
+	 */
48
+	function RandomCompat_intval($number, $fail_open = false)
49
+	{
50
+		if (is_int($number) || is_float($number)) {
51
+			$number += 0;
52
+		} elseif (is_numeric($number)) {
53
+			/** @psalm-suppress InvalidOperand */
54
+			$number += 0;
55
+		}
56
+		/** @var int|float $number */
57 57
 
58
-        if (
59
-            is_float($number)
60
-                &&
61
-            $number > ~PHP_INT_MAX
62
-                &&
63
-            $number < PHP_INT_MAX
64
-        ) {
65
-            $number = (int) $number;
66
-        }
58
+		if (
59
+			is_float($number)
60
+				&&
61
+			$number > ~PHP_INT_MAX
62
+				&&
63
+			$number < PHP_INT_MAX
64
+		) {
65
+			$number = (int) $number;
66
+		}
67 67
 
68
-        if (is_int($number)) {
69
-            return (int) $number;
70
-        } elseif (!$fail_open) {
71
-            throw new TypeError(
72
-                'Expected an integer.'
73
-            );
74
-        }
75
-        return $number;
76
-    }
68
+		if (is_int($number)) {
69
+			return (int) $number;
70
+		} elseif (!$fail_open) {
71
+			throw new TypeError(
72
+				'Expected an integer.'
73
+			);
74
+		}
75
+		return $number;
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Sources/News.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2263,7 +2263,7 @@
 block discarded – undo
2263 2263
 			{
2264 2264
 				uasort($loaded_attachments, function($a, $b) {
2265 2265
 					if ($a['filesize'] == $b['filesize'])
2266
-					        return 0;
2266
+							return 0;
2267 2267
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
2268 2268
 				});
2269 2269
 			}
Please login to merge, or discard this patch.
cron.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -310,7 +310,7 @@
 block discarded – undo
310 310
 {
311 311
 	/**
312 312
 	 * Constants for notification types.
313
-	*/
313
+	 */
314 314
 	const RECEIVE_NOTIFY_EMAIL = 0x02;
315 315
 	const RECEIVE_NOTIFY_ALERT = 0x01;
316 316
 
Please login to merge, or discard this patch.
Sources/tasks/CreatePost-Notify.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 {
20 20
 	/**
21 21
 	 * Constants for reply types.
22
-	*/
22
+	 */
23 23
 	const NOTIFY_TYPE_REPLY_AND_MODIFY = 1;
24 24
 	const NOTIFY_TYPE_REPLY_AND_TOPIC_START_FOLLOWING = 2;
25 25
 	const NOTIFY_TYPE_ONLY_REPLIES = 3;
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 	/**
29 29
 	 * Constants for frequencies.
30
-	*/
30
+	 */
31 31
 	const FREQUENCY_NOTHING = 0;
32 32
 	const FREQUENCY_EVERYTHING = 1;
33 33
 	const FREQUENCY_FIRST_UNREAD_MSG = 2;
Please login to merge, or discard this patch.
Sources/Subs.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -7239,32 +7239,32 @@  discard block
 block discarded – undo
7239 7239
  */
7240 7240
 function truncate_array($array, $max_length = 1900, $deep = 3)
7241 7241
 {
7242
-    $array = (array) $array;
7242
+	$array = (array) $array;
7243 7243
 
7244
-    $curr_length = array_length($array, $deep);
7244
+	$curr_length = array_length($array, $deep);
7245 7245
 
7246
-    if ($curr_length <= $max_length)
7247
-        return $array;
7246
+	if ($curr_length <= $max_length)
7247
+		return $array;
7248 7248
 
7249
-    else
7250
-    {
7251
-        // Truncate each element's value to a reasonable length
7252
-        $param_max = floor($max_length / count($array));
7249
+	else
7250
+	{
7251
+		// Truncate each element's value to a reasonable length
7252
+		$param_max = floor($max_length / count($array));
7253 7253
 
7254
-        $current_deep = $deep - 1;
7254
+		$current_deep = $deep - 1;
7255 7255
 
7256
-        foreach ($array as $key => &$value)
7257
-        {
7258
-            if (is_array($value))
7259
-                if ($current_deep > 0)
7260
-                    $value = truncate_array($value, $current_deep);
7256
+		foreach ($array as $key => &$value)
7257
+		{
7258
+			if (is_array($value))
7259
+				if ($current_deep > 0)
7260
+					$value = truncate_array($value, $current_deep);
7261 7261
 
7262
-            else
7263
-                $value = substr($value, 0, $param_max - strlen($key) - 5);
7264
-        }
7262
+			else
7263
+				$value = substr($value, 0, $param_max - strlen($key) - 5);
7264
+		}
7265 7265
 
7266
-        return $array;
7267
-    }
7266
+		return $array;
7267
+	}
7268 7268
 }
7269 7269
 
7270 7270
 /**
@@ -7275,29 +7275,29 @@  discard block
 block discarded – undo
7275 7275
  */
7276 7276
 function array_length($array, $deep = 3)
7277 7277
 {
7278
-    // Work with arrays
7279
-    $array = (array) $array;
7280
-    $length = 0;
7278
+	// Work with arrays
7279
+	$array = (array) $array;
7280
+	$length = 0;
7281 7281
 
7282
-    $deep_count = $deep - 1;
7282
+	$deep_count = $deep - 1;
7283 7283
 
7284
-    foreach ($array as $value)
7285
-    {
7286
-        // Recursive?
7287
-        if (is_array($value))
7288
-        {
7289
-            // No can't do
7290
-            if ($deep_count <= 0)
7291
-                continue;
7284
+	foreach ($array as $value)
7285
+	{
7286
+		// Recursive?
7287
+		if (is_array($value))
7288
+		{
7289
+			// No can't do
7290
+			if ($deep_count <= 0)
7291
+				continue;
7292 7292
 
7293
-            $length += array_length($value, $deep_count);
7294
-        }
7293
+			$length += array_length($value, $deep_count);
7294
+		}
7295 7295
 
7296
-        else
7297
-            $length += strlen($value);
7298
-    }
7296
+		else
7297
+			$length += strlen($value);
7298
+	}
7299 7299
 
7300
-    return $length;
7300
+	return $length;
7301 7301
 }
7302 7302
 
7303 7303
 /**
Please login to merge, or discard this patch.