Passed
Pull Request — release-2.1 (#5337)
by Michael
05:21
created
Sources/random_compat/random_bytes_libsodium.php 2 patches
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.
Braces   +20 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             );
@@ -62,21 +67,27 @@  discard block
 block discarded – undo
62 67
          * generated in one invocation.
63 68
          */
64 69
         /** @var string|bool $buf */
65
-        if ($bytes > 2147483647) {
70
+        if ($bytes > 2147483647)
71
+        {
66 72
             $buf = '';
67
-            for ($i = 0; $i < $bytes; $i += 1073741824) {
73
+            for ($i = 0; $i < $bytes; $i += 1073741824)
74
+            {
68 75
                 $n = ($bytes - $i) > 1073741824
69 76
                     ? 1073741824
70 77
                     : $bytes - $i;
71 78
                 $buf .= \Sodium\randombytes_buf($n);
72 79
             }
73
-        } else {
80
+        }
81
+        else
82
+        {
74 83
             /** @var string|bool $buf */
75 84
             $buf = \Sodium\randombytes_buf($bytes);
76 85
         }
77 86
 
78
-        if (is_string($buf)) {
79
-            if (RandomCompat_strlen($buf) === $bytes) {
87
+        if (is_string($buf))
88
+        {
89
+            if (RandomCompat_strlen($buf) === $bytes)
90
+            {
80 91
                 return $buf;
81 92
             }
82 93
         }
Please login to merge, or discard this patch.
other/upgrade-helper.php 1 patch
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -428,21 +428,28 @@
 block discarded – undo
428 428
  * @param $index to use as index if specified
429 429
  * @return array of values of specified $col from $array
430 430
  */
431
-if (!function_exists('array_column')) {
432
-	function array_column($input, $column_key, $index_key = null) {
433
-		$arr = array_map(function($d) use ($column_key, $index_key) {
434
-			if (!isset($d[$column_key])) {
431
+if (!function_exists('array_column'))
432
+{
433
+	function array_column($input, $column_key, $index_key = null)
434
+	{
435
+		$arr = array_map(function($d) use ($column_key, $index_key)
436
+		{
437
+			if (!isset($d[$column_key]))
438
+			{
435 439
 				return null;
436 440
 			}
437
-			if ($index_key !== null) {
441
+			if ($index_key !== null)
442
+			{
438 443
 				return array($d[$index_key] => $d[$column_key]);
439 444
 			}
440 445
 			return $d[$column_key];
441 446
 		}, $input);
442 447
 
443
-		if ($index_key !== null) {
448
+		if ($index_key !== null)
449
+		{
444 450
 			$tmp = array();
445
-			foreach ($arr as $ar) {
451
+			foreach ($arr as $ar)
452
+			{
446 453
 				$tmp[key($ar)] = current($ar);
447 454
 			}
448 455
 			$arr = $tmp;
Please login to merge, or discard this patch.
Sources/Subs-Post.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1728,20 +1728,20 @@
 block discarded – undo
1728 1728
 
1729 1729
 	if (!empty($modSettings['enable_mentions']))
1730 1730
 	{
1731
-	    // Get any members who were possibly mentioned
1731
+		// Get any members who were possibly mentioned
1732 1732
 		$msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']);
1733 1733
 		if (!empty($msgOptions['mentioned_members']))
1734
-        {
1735
-            // Replace @name with [member=id]@name[/member]
1734
+		{
1735
+			// Replace @name with [member=id]@name[/member]
1736 1736
 			$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1737 1737
 
1738 1738
 			// Remove any members who weren't actually mentioned, to prevent bogus notifications
1739
-            foreach ($msgOptions['mentioned_members'] as $m)
1740
-            {
1741
-                if (preg_match('~\[member=' . $m['id'] . '\]@' . $m['real_name'] . '\[/member\]~u', $msgOptions['body']) === 0)
1742
-                    unset($msgOptions['mentioned_members'][$m['id']]);
1743
-            }
1744
-        }
1739
+			foreach ($msgOptions['mentioned_members'] as $m)
1740
+			{
1741
+				if (preg_match('~\[member=' . $m['id'] . '\]@' . $m['real_name'] . '\[/member\]~u', $msgOptions['body']) === 0)
1742
+					unset($msgOptions['mentioned_members'][$m['id']]);
1743
+			}
1744
+		}
1745 1745
 	}
1746 1746
 
1747 1747
 	// It's do or die time: forget any user aborts!
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -116,7 +116,8 @@  discard block
 block discarded – undo
116 116
 	if (!$previewing && strpos($message, '[html]') !== false)
117 117
 	{
118 118
 		if (allowedTo('admin_forum'))
119
-			$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
119
+			$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
120
+			{
120 121
 				return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => '&#13;', '  ' => ' &#32;', '[' => '&#91;', ']' => '&#93;')) . '[/html]';
121 122
 			}, $message);
122 123
 
@@ -1245,7 +1246,6 @@  discard block
 block discarded – undo
1245 1246
 
1246 1247
 		return array($charset, $string, 'base64');
1247 1248
 	}
1248
-
1249 1249
 	else
1250 1250
 		return array($charset, $string, '7bit');
1251 1251
 }
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 	    // Get any members who were possibly mentioned
1732 1732
 		$msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']);
1733 1733
 		if (!empty($msgOptions['mentioned_members']))
1734
-        {
1734
+		{
1735 1735
             // Replace @name with [member=id]@name[/member]
1736 1736
 			$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1737 1737
 
Please login to merge, or discard this patch.