Passed
Pull Request — release-2.1 (#5413)
by Mert
04:45
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.
Themes/default/Packages.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -369,7 +369,7 @@
 block discarded – undo
369 369
 	// And a bit more for database changes.
370 370
 	if ($context['uninstalling'] && !empty($context['database_changes']))
371 371
 		echo '
372
-		makeToggle(document.getElementById(\'db_changes_div\'), ', JavaScriptEscape($txt['package_db_uninstall_details']) , ');';
372
+		makeToggle(document.getElementById(\'db_changes_div\'), ', JavaScriptEscape($txt['package_db_uninstall_details']), ');';
373 373
 
374 374
 	echo '
375 375
 	</script>';
Please login to merge, or discard this patch.
Sources/Profile-Modify.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -498,7 +498,7 @@
 block discarded – undo
498 498
 						log_error(sprintf($txt['smiley_set_dir_not_found'], $set_names[array_search($set, $context['smiley_sets'])]));
499 499
 
500 500
 						$context['smiley_sets'] = array_filter($context['smiley_sets'], function($v) use ($set)
501
-							{
501
+						{
502 502
 								return $v != $set;
503 503
 							});
504 504
 					}
Please login to merge, or discard this patch.
Themes/default/Admin.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -741,7 +741,7 @@
 block discarded – undo
741 741
 							<div class="information">', $context['settings_message'], '</div>';
742 742
 
743 743
 	// Filter out any redundant separators before we start the loop
744
-	$context['config_vars'] = array_filter($context['config_vars'], function ($v) use ($context)
744
+	$context['config_vars'] = array_filter($context['config_vars'], function($v) use ($context)
745 745
 		{
746 746
 			static $config_vars, $prev;
747 747
 
Please login to merge, or discard this 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.
Sources/ManageSmileys.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1965,7 +1965,7 @@
 block discarded – undo
1965 1965
 	// Remove anything that isn't actually new from our list of files
1966 1966
 	foreach ($to_unset as $key => $ids)
1967 1967
 	{
1968
-		if (array_reduce($ids, function ($carry, $item) { return $carry * $item; }, true) == true)
1968
+		if (array_reduce($ids, function($carry, $item) { return $carry * $item; }, true) == true)
1969 1969
 			unset($smiley_files[$key]);
1970 1970
 	}
1971 1971
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1965,7 +1965,9 @@
 block discarded – undo
1965 1965
 	// Remove anything that isn't actually new from our list of files
1966 1966
 	foreach ($to_unset as $key => $ids)
1967 1967
 	{
1968
-		if (array_reduce($ids, function ($carry, $item) { return $carry * $item; }, true) == true)
1968
+		if (array_reduce($ids, function ($carry, $item)
1969
+		{
1970
+return $carry * $item; }, true) == true)
1969 1971
 			unset($smiley_files[$key]);
1970 1972
 	}
1971 1973
 
Please login to merge, or discard this patch.
Sources/Subs.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			{
392 392
 				$val = 'CASE ';
393 393
 				foreach ($members as $k => $v)
394
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. alert_count($v, true) . ' ';
394
+					$val .= 'WHEN id_member = ' . $v . ' THEN ' . alert_count($v, true) . ' ';
395 395
 				$val = $val . ' END';
396 396
 				$type = 'raw';
397 397
 			}
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 				'type' => 'unparsed_commas_content',
1408 1408
 				'test' => '\d+,\d+\]',
1409 1409
 				'content' => '<a href="$1" target="_blank" rel="noopener">$1</a>',
1410
-				'validate' => function (&$tag, &$data, $disabled)
1410
+				'validate' => function(&$tag, &$data, $disabled)
1411 1411
 				{
1412 1412
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1413 1413
 					if (empty($scheme))
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 		$codes[] = array(
1970 1970
 			'tag' => 'cowsay',
1971 1971
 			'parameters' => array(
1972
-				'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function ($eyes) use ($smcFunc)
1972
+				'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function($eyes) use ($smcFunc)
1973 1973
 					{
1974 1974
 						static $css_added;
1975 1975
 
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
 						return $smcFunc['substr']($eyes . 'oo', 0, 2);
1987 1987
 					},
1988 1988
 				),
1989
-				't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => '  ', 'validate' => function ($tongue) use ($smcFunc)
1989
+				't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => '  ', 'validate' => function($tongue) use ($smcFunc)
1990 1990
 					{
1991 1991
 						return $smcFunc['substr']($tongue . '  ', 0, 2);
1992 1992
 					},
@@ -5382,15 +5382,15 @@  discard block
 block discarded – undo
5382 5382
 
5383 5383
 	// UTF-8 occurences of MS special characters
5384 5384
 	$findchars_utf8 = array(
5385
-		"\xe2\x80\x9a",	// single low-9 quotation mark
5386
-		"\xe2\x80\x9e",	// double low-9 quotation mark
5387
-		"\xe2\x80\xa6",	// horizontal ellipsis
5388
-		"\xe2\x80\x98",	// left single curly quote
5389
-		"\xe2\x80\x99",	// right single curly quote
5390
-		"\xe2\x80\x9c",	// left double curly quote
5391
-		"\xe2\x80\x9d",	// right double curly quote
5392
-		"\xe2\x80\x93",	// en dash
5393
-		"\xe2\x80\x94",	// em dash
5385
+		"\xe2\x80\x9a", // single low-9 quotation mark
5386
+		"\xe2\x80\x9e", // double low-9 quotation mark
5387
+		"\xe2\x80\xa6", // horizontal ellipsis
5388
+		"\xe2\x80\x98", // left single curly quote
5389
+		"\xe2\x80\x99", // right single curly quote
5390
+		"\xe2\x80\x9c", // left double curly quote
5391
+		"\xe2\x80\x9d", // right double curly quote
5392
+		"\xe2\x80\x93", // en dash
5393
+		"\xe2\x80\x94", // em dash
5394 5394
 	);
5395 5395
 
5396 5396
 	// windows 1252 / iso equivalents
@@ -5408,15 +5408,15 @@  discard block
 block discarded – undo
5408 5408
 
5409 5409
 	// safe replacements
5410 5410
 	$replacechars = array(
5411
-		',',	// &sbquo;
5412
-		',,',	// &bdquo;
5413
-		'...',	// &hellip;
5414
-		"'",	// &lsquo;
5415
-		"'",	// &rsquo;
5416
-		'"',	// &ldquo;
5417
-		'"',	// &rdquo;
5418
-		'-',	// &ndash;
5419
-		'--',	// &mdash;
5411
+		',', // &sbquo;
5412
+		',,', // &bdquo;
5413
+		'...', // &hellip;
5414
+		"'", // &lsquo;
5415
+		"'", // &rsquo;
5416
+		'"', // &ldquo;
5417
+		'"', // &rdquo;
5418
+		'-', // &ndash;
5419
+		'--', // &mdash;
5420 5420
 	);
5421 5421
 
5422 5422
 	if ($context['utf8'])
@@ -6584,7 +6584,7 @@  discard block
 block discarded – undo
6584 6584
 			EXISTS (
6585 6585
 				SELECT bpv.id_board
6586 6586
 				FROM ' . $db_prefix . 'board_permissions_view AS bpv
6587
-				WHERE bpv.id_group IN ('. implode(',', $groups) .')
6587
+				WHERE bpv.id_group IN ('. implode(',', $groups) . ')
6588 6588
 					AND bpv.deny = 0
6589 6589
 					AND bpv.id_board = b.id_board
6590 6590
 			)';
@@ -6594,7 +6594,7 @@  discard block
 block discarded – undo
6594 6594
 			AND NOT EXISTS (
6595 6595
 				SELECT bpv.id_board
6596 6596
 				FROM ' . $db_prefix . 'board_permissions_view AS bpv
6597
-				WHERE bpv.id_group IN ( '. implode(',', $groups) .')
6597
+				WHERE bpv.id_group IN ( '. implode(',', $groups) . ')
6598 6598
 					AND bpv.deny = 1
6599 6599
 					AND bpv.id_board = b.id_board
6600 6600
 			)';
@@ -6854,8 +6854,8 @@  discard block
 block discarded – undo
6854 6854
 	$i = 0;
6855 6855
 	while (empty($done))
6856 6856
 	{
6857
-		if (strpos($format, '{'. --$i . '}') !== false)
6858
-			$replacements['{'. $i . '}'] = array_pop($list);
6857
+		if (strpos($format, '{' . --$i . '}') !== false)
6858
+			$replacements['{' . $i . '}'] = array_pop($list);
6859 6859
 		else
6860 6860
 			$done = true;
6861 6861
 	}
@@ -6865,8 +6865,8 @@  discard block
 block discarded – undo
6865 6865
 	$i = 0;
6866 6866
 	while (empty($done))
6867 6867
 	{
6868
-		if (strpos($format, '{'. ++$i . '}') !== false)
6869
-			$replacements['{'. $i . '}'] = array_shift($list);
6868
+		if (strpos($format, '{' . ++$i . '}') !== false)
6869
+			$replacements['{' . $i . '}'] = array_shift($list);
6870 6870
 		else
6871 6871
 			$done = true;
6872 6872
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -302,7 +302,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 				),
@@ -3088,7 +3087,7 @@  discard block
 block discarded – undo
3088 3087
 
3089 3088
 	// Replace away!
3090 3089
 	$message = preg_replace_callback($smileyPregSearch, function($matches) use ($smileyPregReplacements)
3091
-		{
3090
+	{
3092 3091
 			return $smileyPregReplacements[$matches[1]];
3093 3092
 		}, $message);
3094 3093
 }
@@ -3874,7 +3873,6 @@  discard block
 block discarded – undo
3874 3873
 				if (!isset($minSeed) && isset($js_file['options']['seed']))
3875 3874
 					$minSeed = $js_file['options']['seed'];
3876 3875
 			}
3877
-
3878 3876
 			else
3879 3877
 				echo '
3880 3878
 	<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>';
@@ -6029,7 +6027,6 @@  discard block
 block discarded – undo
6029 6027
 			$isWritable = true;
6030 6028
 			break;
6031 6029
 		}
6032
-
6033 6030
 		else
6034 6031
 			@chmod($file, $val);
6035 6032
 	}
Please login to merge, or discard this patch.
Sources/Subs-Post.php 1 patch
Braces   -1 removed lines patch added patch discarded remove patch
@@ -1254,7 +1254,6 @@
 block discarded – undo
1254 1254
 
1255 1255
 		return array($charset, $string, 'base64');
1256 1256
 	}
1257
-
1258 1257
 	else
1259 1258
 		return array($charset, $string, '7bit');
1260 1259
 }
Please login to merge, or discard this patch.
Sources/Load.php 1 patch
Braces   +1 added lines, -6 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	// Set a list of common functions.
83 83
 	$ent_list = '&(?:#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . '|quot|amp|lt|gt|nbsp);';
84 84
 	$ent_check = empty($modSettings['disableEntityCheck']) ? function($string)
85
-		{
85
+	{
86 86
 			$string = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string);
87 87
 			return $string;
88 88
 		} : function($string)
@@ -2131,7 +2131,6 @@  discard block
 block discarded – undo
2131 2131
 		loadLanguage('index+Modifications');
2132 2132
 		$context['template_layers'] = array();
2133 2133
 	}
2134
-
2135 2134
 	else
2136 2135
 	{
2137 2136
 		// Custom templates to load, or just default?
@@ -2509,14 +2508,12 @@  discard block
 block discarded – undo
2509 2508
 				$fileUrl = $settings['default_theme_url'] . '/css/' . $fileName;
2510 2509
 				$filePath = $settings['default_theme_dir'] . '/css/' . $fileName;
2511 2510
 			}
2512
-
2513 2511
 			else
2514 2512
 			{
2515 2513
 				$fileUrl = false;
2516 2514
 				$filePath = false;
2517 2515
 			}
2518 2516
 		}
2519
-
2520 2517
 		else
2521 2518
 		{
2522 2519
 			$fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName;
@@ -2623,14 +2620,12 @@  discard block
 block discarded – undo
2623 2620
 				$fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName;
2624 2621
 				$filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName;
2625 2622
 			}
2626
-
2627 2623
 			else
2628 2624
 			{
2629 2625
 				$fileUrl = false;
2630 2626
 				$filePath = false;
2631 2627
 			}
2632 2628
 		}
2633
-
2634 2629
 		else
2635 2630
 		{
2636 2631
 			$fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName;
Please login to merge, or discard this patch.