Passed
Pull Request — release-2.1 (#6786)
by Jon
05:08
created
Sources/Subs.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 			{
379 379
 				$val = 'CASE ';
380 380
 				foreach ($members as $k => $v)
381
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. alert_count($v, true) . ' ';
381
+					$val .= 'WHEN id_member = ' . $v . ' THEN ' . alert_count($v, true) . ' ';
382 382
 
383 383
 				$val = $val . ' END';
384 384
 				$type = 'raw';
@@ -1041,11 +1041,11 @@  discard block
 block discarded – undo
1041 1041
 			// Anything that isn't a specification, punctuation mark, or whitespace.
1042 1042
 			'~(?<!%)\p{L}|[^\p{L}\p{P}\s]~u',
1043 1043
 			// A series of punctuation marks (except %), possibly separated by whitespace.
1044
-			'~([^%\P{P}])(\s*)(?'.'>(\1|[^%\P{Po}])\s*(?!$))*~u',
1044
+			'~([^%\P{P}])(\s*)(?' . '>(\1|[^%\P{Po}])\s*(?!$))*~u',
1045 1045
 			// Unwanted trailing punctuation and whitespace.
1046
-			'~(?'.'>([\p{Pd}\p{Ps}\p{Pi}\p{Pc}]|[^%\P{Po}])\s*)*$~u',
1046
+			'~(?' . '>([\p{Pd}\p{Ps}\p{Pi}\p{Pc}]|[^%\P{Po}])\s*)*$~u',
1047 1047
 			// Unwanted opening punctuation and whitespace.
1048
-			'~^\s*(?'.'>([\p{Pd}\p{Pe}\p{Pf}\p{Pc}]|[^%\P{Po}])\s*)*~u',
1048
+			'~^\s*(?' . '>([\p{Pd}\p{Pe}\p{Pf}\p{Pc}]|[^%\P{Po}])\s*)*~u',
1049 1049
 		),
1050 1050
 		array(
1051 1051
 			'',
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 	}
1278 1278
 
1279 1279
 	// Replace all illegal entities with the entity for the replacement character.
1280
-	$string = preg_replace('/&#(?'.'>x0*' . $disallowed['hex'] . '|0*' . $disallowed['dec'] . ');/i', $substitute, $string);
1280
+	$string = preg_replace('/&#(?' . '>x0*' . $disallowed['hex'] . '|0*' . $disallowed['dec'] . ');/i', $substitute, $string);
1281 1281
 
1282 1282
 	return $string;
1283 1283
 }
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
 	}
1315 1315
 	elseif (!empty($context['character_set']) && is_callable('mb_decode_numericentity'))
1316 1316
 	{
1317
-		$substitute = mb_decode_numericentity('&#xFFFD;', array(0xFFFD,0xFFFD,0,0xFFFF), $context['character_set']);
1317
+		$substitute = mb_decode_numericentity('&#xFFFD;', array(0xFFFD, 0xFFFD, 0, 0xFFFF), $context['character_set']);
1318 1318
 	}
1319 1319
 	else
1320 1320
 		$substitute = '?';
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
 								$returnContext .= '<img src="' . $currentAttachment['href'] . '"' . $alt . $title . ' class="bbc_img"></a>';
1737 1737
 							else
1738 1738
 							{
1739
-								$width = !empty($params['{width}']) ? ' width="' . $params['{width}'] . '"': '';
1739
+								$width = !empty($params['{width}']) ? ' width="' . $params['{width}'] . '"' : '';
1740 1740
 								$height = !empty($params['{height}']) ? 'height="' . $params['{height}'] . '"' : '';
1741 1741
 								$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img resized"/>';
1742 1742
 							}
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
 							$width = !empty($width) ? ' width="' . $width . '"' : '';
1748 1748
 							$height = !empty($height) ? ' height="' . $height . '"' : '';
1749 1749
 
1750
-							$returnContext .= '<div class="videocontainer"><video controls preload="metadata" src="'. $currentAttachment['href'] . '" playsinline' . $width . $height . '><a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a></video></div>' . (!empty($data) && $data != $currentAttachment['name'] ? '<div class="smalltext">' . $data . '</div>' : '');
1750
+							$returnContext .= '<div class="videocontainer"><video controls preload="metadata" src="' . $currentAttachment['href'] . '" playsinline' . $width . $height . '><a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a></video></div>' . (!empty($data) && $data != $currentAttachment['name'] ? '<div class="smalltext">' . $data . '</div>' : '');
1751 1751
 						}
1752 1752
 						// Audio.
1753 1753
 						elseif (strpos($currentAttachment['mime_type'], 'audio/') === 0)
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
 							$width = 'max-width:100%; width: ' . (!empty($width) ? $width : '400') . 'px;';
1756 1756
 							$height = !empty($height) ? 'height: ' . $height . 'px;' : '';
1757 1757
 
1758
-							$returnContext .= (!empty($data) && $data != $currentAttachment['name'] ? $data . ' ' : '') . '<audio controls preload="none" src="'. $currentAttachment['href'] . '" class="bbc_audio" style="vertical-align:middle;' . $width . $height . '"><a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a></audio>';
1758
+							$returnContext .= (!empty($data) && $data != $currentAttachment['name'] ? $data . ' ' : '') . '<audio controls preload="none" src="' . $currentAttachment['href'] . '" class="bbc_audio" style="vertical-align:middle;' . $width . $height . '"><a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a></audio>';
1759 1759
 						}
1760 1760
 						// Anything else.
1761 1761
 						else
@@ -1924,7 +1924,7 @@  discard block
 block discarded – undo
1924 1924
 				'type' => 'unparsed_commas_content',
1925 1925
 				'test' => '\d+,\d+\]',
1926 1926
 				'content' => '<a href="$1" target="_blank" rel="noopener">$1</a>',
1927
-				'validate' => function (&$tag, &$data, $disabled)
1927
+				'validate' => function(&$tag, &$data, $disabled)
1928 1928
 				{
1929 1929
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1930 1930
 					if (empty($scheme))
@@ -2466,12 +2466,12 @@  discard block
 block discarded – undo
2466 2466
 		$codes[] = array(
2467 2467
 			'tag' => 'cowsay',
2468 2468
 			'parameters' => array(
2469
-				'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function ($eyes) use ($smcFunc)
2469
+				'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function($eyes) use ($smcFunc)
2470 2470
 					{
2471 2471
 						return $smcFunc['substr']($eyes . 'oo', 0, 2);
2472 2472
 					},
2473 2473
 				),
2474
-				't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => '  ', 'validate' => function ($tongue) use ($smcFunc)
2474
+				't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => '  ', 'validate' => function($tongue) use ($smcFunc)
2475 2475
 					{
2476 2476
 						return $smcFunc['substr']($tongue . '  ', 0, 2);
2477 2477
 					},
@@ -3855,7 +3855,7 @@  discard block
 block discarded – undo
3855 3855
 		if ($fp != false)
3856 3856
 		{
3857 3857
 			// Send the HEAD request (since we don't have to worry about chunked, HTTP/1.1 is fine here.)
3858
-			fwrite($fp, 'HEAD /' . $match[2] . ' HTTP/1.1' . "\r\n" . 'Host: ' . $match[1] . "\r\n" . 'user-agent: '. SMF_USER_AGENT . "\r\n" . 'Connection: close' . "\r\n\r\n");
3858
+			fwrite($fp, 'HEAD /' . $match[2] . ' HTTP/1.1' . "\r\n" . 'Host: ' . $match[1] . "\r\n" . 'user-agent: ' . SMF_USER_AGENT . "\r\n" . 'Connection: close' . "\r\n\r\n");
3859 3859
 
3860 3860
 			// Read in the HTTP/1.1 or whatever.
3861 3861
 			$test = substr(fgets($fp, 11), -1);
@@ -4472,7 +4472,7 @@  discard block
 block discarded – undo
4472 4472
 	$toMinify = array();
4473 4473
 	$normal = array();
4474 4474
 
4475
-	uasort($context['css_files'], function ($a, $b)
4475
+	uasort($context['css_files'], function($a, $b)
4476 4476
 	{
4477 4477
 		return $a['options']['order_pos'] < $b['options']['order_pos'] ? -1 : ($a['options']['order_pos'] > $b['options']['order_pos'] ? 1 : 0);
4478 4478
 	});
@@ -5769,7 +5769,7 @@  discard block
 block discarded – undo
5769 5769
 			{
5770 5770
 				fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n");
5771 5771
 				fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
5772
-				fwrite($fp, 'user-agent: '. SMF_USER_AGENT . "\r\n");
5772
+				fwrite($fp, 'user-agent: ' . SMF_USER_AGENT . "\r\n");
5773 5773
 				if ($keep_alive)
5774 5774
 					fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n");
5775 5775
 				else
@@ -5779,7 +5779,7 @@  discard block
 block discarded – undo
5779 5779
 			{
5780 5780
 				fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n");
5781 5781
 				fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
5782
-				fwrite($fp, 'user-agent: '. SMF_USER_AGENT . "\r\n");
5782
+				fwrite($fp, 'user-agent: ' . SMF_USER_AGENT . "\r\n");
5783 5783
 				if ($keep_alive)
5784 5784
 					fwrite($fp, 'connection: Keep-Alive' . "\r\n");
5785 5785
 				else
@@ -6028,13 +6028,13 @@  discard block
 block discarded – undo
6028 6028
 
6029 6029
 	// UTF-8 occurences of MS special characters
6030 6030
 	$findchars_utf8 = array(
6031
-		"\xe2\x80\x9a",	// single low-9 quotation mark
6032
-		"\xe2\x80\x9e",	// double low-9 quotation mark
6033
-		"\xe2\x80\xa6",	// horizontal ellipsis
6034
-		"\xe2\x80\x98",	// left single curly quote
6035
-		"\xe2\x80\x99",	// right single curly quote
6036
-		"\xe2\x80\x9c",	// left double curly quote
6037
-		"\xe2\x80\x9d",	// right double curly quote
6031
+		"\xe2\x80\x9a", // single low-9 quotation mark
6032
+		"\xe2\x80\x9e", // double low-9 quotation mark
6033
+		"\xe2\x80\xa6", // horizontal ellipsis
6034
+		"\xe2\x80\x98", // left single curly quote
6035
+		"\xe2\x80\x99", // right single curly quote
6036
+		"\xe2\x80\x9c", // left double curly quote
6037
+		"\xe2\x80\x9d", // right double curly quote
6038 6038
 	);
6039 6039
 
6040 6040
 	// windows 1252 / iso equivalents
@@ -6050,13 +6050,13 @@  discard block
 block discarded – undo
6050 6050
 
6051 6051
 	// safe replacements
6052 6052
 	$replacechars = array(
6053
-		',',	// &sbquo;
6054
-		',,',	// &bdquo;
6055
-		'...',	// &hellip;
6056
-		"'",	// &lsquo;
6057
-		"'",	// &rsquo;
6058
-		'"',	// &ldquo;
6059
-		'"',	// &rdquo;
6053
+		',', // &sbquo;
6054
+		',,', // &bdquo;
6055
+		'...', // &hellip;
6056
+		"'", // &lsquo;
6057
+		"'", // &rsquo;
6058
+		'"', // &ldquo;
6059
+		'"', // &rdquo;
6060 6060
 	);
6061 6061
 
6062 6062
 	if ($context['utf8'])
@@ -6283,7 +6283,7 @@  discard block
 block discarded – undo
6283 6283
 			$desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : '');
6284 6284
 
6285 6285
 		// We don't want abbreviations like '+03' or '-11'.
6286
-		$abbrs = array_filter($tzvalue['abbrs'], function ($abbr) {
6286
+		$abbrs = array_filter($tzvalue['abbrs'], function($abbr) {
6287 6287
 			return !strspn($abbr, '+-');
6288 6288
 		});
6289 6289
 		$abbrs = count($abbrs) == count($tzvalue['abbrs']) ? array_unique($abbrs) : array();
@@ -7247,7 +7247,7 @@  discard block
 block discarded – undo
7247 7247
 			EXISTS (
7248 7248
 				SELECT bpv.id_board
7249 7249
 				FROM ' . $db_prefix . 'board_permissions_view AS bpv
7250
-				WHERE bpv.id_group IN ('. implode(',', $groups) .')
7250
+				WHERE bpv.id_group IN ('. implode(',', $groups) . ')
7251 7251
 					AND bpv.deny = 0
7252 7252
 					AND bpv.id_board = b.id_board
7253 7253
 			)';
@@ -7257,7 +7257,7 @@  discard block
 block discarded – undo
7257 7257
 			AND NOT EXISTS (
7258 7258
 				SELECT bpv.id_board
7259 7259
 				FROM ' . $db_prefix . 'board_permissions_view AS bpv
7260
-				WHERE bpv.id_group IN ( '. implode(',', $groups) .')
7260
+				WHERE bpv.id_group IN ( '. implode(',', $groups) . ')
7261 7261
 					AND bpv.deny = 1
7262 7262
 					AND bpv.id_board = b.id_board
7263 7263
 			)';
@@ -7528,8 +7528,8 @@  discard block
 block discarded – undo
7528 7528
 	$i = 0;
7529 7529
 	while (empty($done))
7530 7530
 	{
7531
-		if (strpos($format, '{'. --$i . '}') !== false)
7532
-			$replacements['{'. $i . '}'] = array_pop($list);
7531
+		if (strpos($format, '{' . --$i . '}') !== false)
7532
+			$replacements['{' . $i . '}'] = array_pop($list);
7533 7533
 		else
7534 7534
 			$done = true;
7535 7535
 	}
@@ -7539,8 +7539,8 @@  discard block
 block discarded – undo
7539 7539
 	$i = 0;
7540 7540
 	while (empty($done))
7541 7541
 	{
7542
-		if (strpos($format, '{'. ++$i . '}') !== false)
7543
-			$replacements['{'. $i . '}'] = array_shift($list);
7542
+		if (strpos($format, '{' . ++$i . '}') !== false)
7543
+			$replacements['{' . $i . '}'] = array_shift($list);
7544 7544
 		else
7545 7545
 			$done = true;
7546 7546
 	}
Please login to merge, or discard this patch.
Sources/Load.php 2 patches
Spacing   +9 added lines, -12 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	$context['utf8'] = $utf8;
106 106
 
107 107
 	// Set a list of common functions.
108
-	$ent_list = '&(?'.'>nbsp|quot|gt|lt|a(?'.'>pos|mp)|#(?'.'>\d+|x[0-9a-fA-F]+));';
108
+	$ent_list = '&(?' . '>nbsp|quot|gt|lt|a(?' . '>pos|mp)|#(?' . '>\d+|x[0-9a-fA-F]+));';
109 109
 
110 110
 	// global array of anonymous helper functions, used mostly to properly handle multi byte strings
111 111
 	$smcFunc += array(
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 		'htmltrim' => function($string) use ($utf8)
121 121
 		{
122 122
 			// Find all possible versions of &nbsp;
123
-			$nbsp = '&(?'.'>nbsp|#(?'.'>x0*A0|0*160));';
123
+			$nbsp = '&(?' . '>nbsp|#(?' . '>x0*A0|0*160));';
124 124
 
125 125
 			// Interesting fact: Unicode properties work even when not in UTF-8 mode.
126
-			return preg_replace('~^(?'.'>[\p{Z}\p{C}]|' . $nbsp . ')+|(?'.'>[\p{Z}\p{C}]|' . $nbsp . ')+$~' . ($utf8 ? 'u' : ''), '', sanitize_entities($string));
126
+			return preg_replace('~^(?' . '>[\p{Z}\p{C}]|' . $nbsp . ')+|(?' . '>[\p{Z}\p{C}]|' . $nbsp . ')+$~' . ($utf8 ? 'u' : ''), '', sanitize_entities($string));
127 127
 		},
128 128
 		'strlen' => function($string) use ($ent_list, $utf8)
129 129
 		{
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 			'filename' => empty($user_settings['filename']) ? '' : $user_settings['filename'],
768 768
 			'custom_dir' => !empty($user_settings['attachment_type']) && $user_settings['attachment_type'] == 1,
769 769
 			'id_attach' => isset($user_settings['id_attach']) ? $user_settings['id_attach'] : 0,
770
-			'width' => isset($user_settings['attachment_width']) > 0 ? $user_settings['attachment_width']: 0,
770
+			'width' => isset($user_settings['attachment_width']) > 0 ? $user_settings['attachment_width'] : 0,
771 771
 			'height' => isset($user_settings['attachment_height']) > 0 ? $user_settings['attachment_height'] : 0,
772 772
 		),
773 773
 		'smiley_set' => isset($user_settings['smiley_set']) ? $user_settings['smiley_set'] : '',
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
 		if (!empty($image))
1716 1716
 			$memberContext[$user]['avatar'] = array(
1717 1717
 				'name' => $profile['avatar'],
1718
-				'image' => '<img class="avatar" src="' . $image . '" alt="" loading="lazy" width="' . $profile['attachment_width'] . '" height = "'. $profile['attachment_height'] . '">',
1718
+				'image' => '<img class="avatar" src="' . $image . '" alt="" loading="lazy" width="' . $profile['attachment_width'] . '" height = "' . $profile['attachment_height'] . '">',
1719 1719
 				'href' => $image,
1720 1720
 				'url' => $image,
1721 1721
 			);
@@ -2680,8 +2680,7 @@  discard block
 block discarded – undo
2680 2680
 		$context['css_files_order'] = array();
2681 2681
 
2682 2682
 	$params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ?
2683
-		(array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') :
2684
-		(is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : '');
2683
+		(array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') : (is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : '');
2685 2684
 	$params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false;
2686 2685
 	$themeRef = !empty($params['default_theme']) ? 'default_theme' : 'theme';
2687 2686
 	$params['minimize'] = isset($params['minimize']) ? $params['minimize'] : true;
@@ -2795,8 +2794,7 @@  discard block
 block discarded – undo
2795 2794
 	global $settings, $context, $modSettings;
2796 2795
 
2797 2796
 	$params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ?
2798
-		(array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') :
2799
-		(is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : '');
2797
+		(array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') : (is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : '');
2800 2798
 	$params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false;
2801 2799
 	$themeRef = !empty($params['default_theme']) ? 'default_theme' : 'theme';
2802 2800
 	$params['async'] = isset($params['async']) ? $params['async'] : false;
@@ -3539,8 +3537,7 @@  discard block
 block discarded – undo
3539 3537
 
3540 3538
 	// What accelerator we are going to try.
3541 3539
 	$cache_class_name = !empty($cache_accelerator) ? $cache_accelerator : CacheApi::APIS_DEFAULT;
3542
-	$fully_qualified_class_name = !empty($overrideCache) ? $overrideCache :
3543
-		CacheApi::APIS_NAMESPACE . $cache_class_name;
3540
+	$fully_qualified_class_name = !empty($overrideCache) ? $overrideCache : CacheApi::APIS_NAMESPACE . $cache_class_name;
3544 3541
 
3545 3542
 	// Do some basic tests.
3546 3543
 	if (class_exists($fully_qualified_class_name))
@@ -3844,7 +3841,7 @@  discard block
 block discarded – undo
3844 3841
 			$auth_secret = hash_file('sha256', $boarddir . '/Settings.php');
3845 3842
 
3846 3843
 			// Set the last error to now, but only every 15 minutes.  Don't need to flood the logs.
3847
-			if (empty($db_last_error) || ($db_last_error + 60*15) <= time())
3844
+			if (empty($db_last_error) || ($db_last_error + 60 * 15) <= time())
3848 3845
 			{
3849 3846
 				updateDbLastError(time());
3850 3847
 				loadLanguage('Errors');
Please login to merge, or discard this patch.
Braces   -3 removed lines patch added patch discarded remove patch
@@ -901,7 +901,6 @@  discard block
 block discarded – undo
901 901
 			$user_info_min[$row['id_member']]['time_offset'] = ($tz_user->getOffset($time_user) -
902 902
 					$tz_system->getOffset($time_system)) / 3600;
903 903
 		}
904
-
905 904
 		else
906 905
 			$user_info_min[$row['id_member']]['time_offset'] = empty($row['time_offset']) ? 0 : $row['time_offset'];
907 906
 	}
@@ -1633,7 +1632,6 @@  discard block
 block discarded – undo
1633 1632
 			$time_user = new DateTime('now', $tz_user);
1634 1633
 			$profile['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600;
1635 1634
 		}
1636
-
1637 1635
 		else
1638 1636
 		{
1639 1637
 			// !!! Compatibility.
@@ -2326,7 +2324,6 @@  discard block
 block discarded – undo
2326 2324
 		loadLanguage('index+Modifications');
2327 2325
 		$context['template_layers'] = array();
2328 2326
 	}
2329
-
2330 2327
 	else
2331 2328
 	{
2332 2329
 		// Custom templates to load, or just default?
Please login to merge, or discard this patch.