Completed
Push — release-2.1 ( d7437d...6e2675 )
by Mathias
18:35
created
Sources/random_compat/cast_to_int.php 1 patch
Braces   +12 added lines, -5 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('RandomCompat_intval')) {
29
+if (!is_callable('RandomCompat_intval'))
30
+{
30 31
 
31 32
     /**
32 33
      * Cast to an integer if we can, safely.
@@ -47,9 +48,12 @@  discard block
 block discarded – undo
47 48
      */
48 49
     function RandomCompat_intval($number, $fail_open = false)
49 50
     {
50
-        if (is_int($number) || is_float($number)) {
51
+        if (is_int($number) || is_float($number))
52
+        {
51 53
             $number += 0;
52
-        } elseif (is_numeric($number)) {
54
+        }
55
+        elseif (is_numeric($number))
56
+        {
53 57
             /** @psalm-suppress InvalidOperand */
54 58
             $number += 0;
55 59
         }
@@ -65,9 +69,12 @@  discard block
 block discarded – undo
65 69
             $number = (int) $number;
66 70
         }
67 71
 
68
-        if (is_int($number)) {
72
+        if (is_int($number))
73
+        {
69 74
             return (int) $number;
70
-        } elseif (!$fail_open) {
75
+        }
76
+        elseif (!$fail_open)
77
+        {
71 78
             throw new TypeError(
72 79
                 'Expected an integer.'
73 80
             );
Please login to merge, or discard this patch.
Sources/random_compat/random_bytes_libsodium.php 1 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.
Sources/random_compat/byte_safe_strings.php 1 patch
Braces   +35 added lines, -16 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('RandomCompat_strlen')) {
29
+if (!is_callable('RandomCompat_strlen'))
30
+{
30 31
     if (
31 32
         defined('MB_OVERLOAD_STRING')
32 33
             &&
@@ -46,7 +47,8 @@  discard block
 block discarded – undo
46 47
          */
47 48
         function RandomCompat_strlen($binary_string)
48 49
         {
49
-            if (!is_string($binary_string)) {
50
+            if (!is_string($binary_string))
51
+            {
50 52
                 throw new TypeError(
51 53
                     'RandomCompat_strlen() expects a string'
52 54
                 );
@@ -55,7 +57,9 @@  discard block
 block discarded – undo
55 57
             return (int) mb_strlen($binary_string, '8bit');
56 58
         }
57 59
 
58
-    } else {
60
+    }
61
+    else
62
+    {
59 63
         /**
60 64
          * strlen() implementation that isn't brittle to mbstring.func_overload
61 65
          *
@@ -69,7 +73,8 @@  discard block
 block discarded – undo
69 73
          */
70 74
         function RandomCompat_strlen($binary_string)
71 75
         {
72
-            if (!is_string($binary_string)) {
76
+            if (!is_string($binary_string))
77
+            {
73 78
                 throw new TypeError(
74 79
                     'RandomCompat_strlen() expects a string'
75 80
                 );
@@ -79,7 +84,8 @@  discard block
 block discarded – undo
79 84
     }
80 85
 }
81 86
 
82
-if (!is_callable('RandomCompat_substr')) {
87
+if (!is_callable('RandomCompat_substr'))
88
+{
83 89
 
84 90
     if (
85 91
         defined('MB_OVERLOAD_STRING')
@@ -102,36 +108,43 @@  discard block
 block discarded – undo
102 108
          */
103 109
         function RandomCompat_substr($binary_string, $start, $length = null)
104 110
         {
105
-            if (!is_string($binary_string)) {
111
+            if (!is_string($binary_string))
112
+            {
106 113
                 throw new TypeError(
107 114
                     'RandomCompat_substr(): First argument should be a string'
108 115
                 );
109 116
             }
110 117
 
111
-            if (!is_int($start)) {
118
+            if (!is_int($start))
119
+            {
112 120
                 throw new TypeError(
113 121
                     'RandomCompat_substr(): Second argument should be an integer'
114 122
                 );
115 123
             }
116 124
 
117
-            if ($length === null) {
125
+            if ($length === null)
126
+            {
118 127
                 /**
119 128
                  * mb_substr($str, 0, NULL, '8bit') returns an empty string on
120 129
                  * PHP 5.3, so we have to find the length ourselves.
121 130
                  */
122 131
                 /** @var int $length */
123 132
                 $length = RandomCompat_strlen($binary_string) - $start;
124
-            } elseif (!is_int($length)) {
133
+            }
134
+            elseif (!is_int($length))
135
+            {
125 136
                 throw new TypeError(
126 137
                     'RandomCompat_substr(): Third argument should be an integer, or omitted'
127 138
                 );
128 139
             }
129 140
 
130 141
             // Consistency with PHP's behavior
131
-            if ($start === RandomCompat_strlen($binary_string) && $length === 0) {
142
+            if ($start === RandomCompat_strlen($binary_string) && $length === 0)
143
+            {
132 144
                 return '';
133 145
             }
134
-            if ($start > RandomCompat_strlen($binary_string)) {
146
+            if ($start > RandomCompat_strlen($binary_string))
147
+            {
135 148
                 return '';
136 149
             }
137 150
 
@@ -143,7 +156,9 @@  discard block
 block discarded – undo
143 156
             );
144 157
         }
145 158
 
146
-    } else {
159
+    }
160
+    else
161
+    {
147 162
 
148 163
         /**
149 164
          * substr() implementation that isn't brittle to mbstring.func_overload
@@ -160,20 +175,24 @@  discard block
 block discarded – undo
160 175
          */
161 176
         function RandomCompat_substr($binary_string, $start, $length = null)
162 177
         {
163
-            if (!is_string($binary_string)) {
178
+            if (!is_string($binary_string))
179
+            {
164 180
                 throw new TypeError(
165 181
                     'RandomCompat_substr(): First argument should be a string'
166 182
                 );
167 183
             }
168 184
 
169
-            if (!is_int($start)) {
185
+            if (!is_int($start))
186
+            {
170 187
                 throw new TypeError(
171 188
                     'RandomCompat_substr(): Second argument should be an integer'
172 189
                 );
173 190
             }
174 191
 
175
-            if ($length !== null) {
176
-                if (!is_int($length)) {
192
+            if ($length !== null)
193
+            {
194
+                if (!is_int($length))
195
+                {
177 196
                     throw new TypeError(
178 197
                         'RandomCompat_substr(): Third argument should be an integer, or omitted'
179 198
                     );
Please login to merge, or discard this patch.
Sources/Subs-BoardIndex.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -420,7 +420,7 @@
 block discarded – undo
420 420
 					$board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']);
421 421
 			}
422 422
 		}
423
-	else
423
+		else
424 424
 		foreach ($this_category as &$board)
425 425
 		{
426 426
 			if (!empty($moderators[$board['id']]))
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.
Themes/default/Admin.template.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -742,7 +742,7 @@
 block discarded – undo
742 742
 
743 743
 	// Filter out any redundant separators before we start the loop
744 744
 	$context['config_vars'] = array_filter($context['config_vars'], function ($v) use ($context)
745
-		{
745
+	{
746 746
 			static $config_vars, $prev;
747 747
 
748 748
 			$at_start = is_null($config_vars);
Please login to merge, or discard this patch.
other/upgrade.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3205,7 +3205,9 @@
 block discarded – undo
3205 3205
 		return $string;
3206 3206
 
3207 3207
 	// This bit fixes incorrect string lengths, which can happen if the character encoding was changed (e.g. conversion to UTF-8)
3208
-	$new_string = preg_replace_callback('~\bs:(\d+):"(.*?)";(?=$|[bidsa]:|[{}]|N;)~s', function ($matches) {return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";';}, $string);
3208
+	$new_string = preg_replace_callback('~\bs:(\d+):"(.*?)";(?=$|[bidsa]:|[{}]|N;)~s', function ($matches)
3209
+	{
3210
+return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";';}, $string);
3209 3211
 
3210 3212
 	// @todo Add more possible fixes here. For example, fix incorrect array lengths, try to handle truncated strings gracefully, etc.
3211 3213
 
Please login to merge, or discard this patch.
Sources/ManagePermissions.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1827,7 +1827,7 @@
 block discarded – undo
1827 1827
 	{
1828 1828
 		// Make sure this is an array of integers
1829 1829
 		$excluded_groups = array_filter((array) $excluded_groups, function ($v)
1830
-			{
1830
+		{
1831 1831
 				return is_int($v) || is_string($v) && (string) intval($v) === $v;
1832 1832
 			});
1833 1833
 
Please login to merge, or discard this patch.