Completed
Pull Request — release-2.1 (#4908)
by Rick
07:52
created
Sources/Subs.php 1 patch
Spacing   +111 added lines, -111 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 '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
394
+					$val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' ';
395 395
 				$val = $val . ' END';
396 396
 				$type = 'raw';
397 397
 			}
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 	static $non_twelve_hour, $locale_cache;
745 745
 	static $unsupportedFormats, $finalizedFormats;
746 746
 
747
-	$unsupportedFormatsWindows = array('z','Z');
747
+	$unsupportedFormatsWindows = array('z', 'Z');
748 748
 
749 749
 	// Ensure required values are set
750 750
 	$user_info['time_offset'] = !empty($user_info['time_offset']) ? $user_info['time_offset'] : 0;
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 			$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
830 830
 		if (empty($unsupportedFormats))
831 831
 		{
832
-			foreach($strftimeFormatSubstitutions as $format => $substitution)
832
+			foreach ($strftimeFormatSubstitutions as $format => $substitution)
833 833
 			{
834 834
 				// Avoid a crashing bug with PHP 7 on certain versions of Windows
835 835
 				if ($context['server']['is_windows'] && in_array($format, $unsupportedFormatsWindows))
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 					'height' => array('optional' => true, 'match' => '(\d+)'),
1207 1207
 				),
1208 1208
 				'content' => '$1',
1209
-				'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1209
+				'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1210 1210
 				{
1211 1211
 					$returnContext = '';
1212 1212
 
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 						}
1242 1242
 
1243 1243
 						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1244
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1244
+							$returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>';
1245 1245
 						else
1246 1246
 							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1247 1247
 					}
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 				'type' => 'unparsed_content',
1294 1294
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1295 1295
 				// @todo Maybe this can be simplified?
1296
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1296
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1297 1297
 				{
1298 1298
 					if (!isset($disabled['code']))
1299 1299
 					{
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 				'type' => 'unparsed_equals_content',
1331 1331
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1332 1332
 				// @todo Maybe this can be simplified?
1333
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1333
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1334 1334
 				{
1335 1335
 					if (!isset($disabled['code']))
1336 1336
 					{
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 				'type' => 'unparsed_content',
1375 1375
 				'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
1376 1376
 				// @todo Should this respect guest_hideContacts?
1377
-				'validate' => function (&$tag, &$data, $disabled)
1377
+				'validate' => function(&$tag, &$data, $disabled)
1378 1378
 				{
1379 1379
 					$data = strtr($data, array('<br>' => ''));
1380 1380
 				},
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
 				'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]',
1395 1395
 				'before' => '<div $1>',
1396 1396
 				'after' => '</div>',
1397
-				'validate' => function (&$tag, &$data, $disabled)
1397
+				'validate' => function(&$tag, &$data, $disabled)
1398 1398
 				{
1399 1399
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1400 1400
 
@@ -1480,7 +1480,7 @@  discard block
 block discarded – undo
1480 1480
 					'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
1481 1481
 				),
1482 1482
 				'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">',
1483
-				'validate' => function (&$tag, &$data, $disabled)
1483
+				'validate' => function(&$tag, &$data, $disabled)
1484 1484
 				{
1485 1485
 					global $image_proxy_enabled, $user_info;
1486 1486
 
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
 				'tag' => 'img',
1507 1507
 				'type' => 'unparsed_content',
1508 1508
 				'content' => '<img src="$1" alt="" class="bbc_img">',
1509
-				'validate' => function (&$tag, &$data, $disabled)
1509
+				'validate' => function(&$tag, &$data, $disabled)
1510 1510
 				{
1511 1511
 					global $image_proxy_enabled, $user_info;
1512 1512
 
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
 				'tag' => 'iurl',
1533 1533
 				'type' => 'unparsed_content',
1534 1534
 				'content' => '<a href="$1" class="bbc_link">$1</a>',
1535
-				'validate' => function (&$tag, &$data, $disabled)
1535
+				'validate' => function(&$tag, &$data, $disabled)
1536 1536
 				{
1537 1537
 					$data = strtr($data, array('<br>' => ''));
1538 1538
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
 				'quoted' => 'optional',
1547 1547
 				'before' => '<a href="$1" class="bbc_link">',
1548 1548
 				'after' => '</a>',
1549
-				'validate' => function (&$tag, &$data, $disabled)
1549
+				'validate' => function(&$tag, &$data, $disabled)
1550 1550
 				{
1551 1551
 					if (substr($data, 0, 1) == '#')
1552 1552
 						$data = '#post_' . substr($data, 1);
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
 				'tag' => 'php',
1640 1640
 				'type' => 'unparsed_content',
1641 1641
 				'content' => '<span class="phpcode">$1</span>',
1642
-				'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled)
1642
+				'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled)
1643 1643
 				{
1644 1644
 					if (!isset($disabled['php']))
1645 1645
 					{
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 				'test' => '[1-7]\]',
1789 1789
 				'before' => '<span style="font-size: $1;" class="bbc_size">',
1790 1790
 				'after' => '</span>',
1791
-				'validate' => function (&$tag, &$data, $disabled)
1791
+				'validate' => function(&$tag, &$data, $disabled)
1792 1792
 				{
1793 1793
 					$sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95);
1794 1794
 					$data = $sizes[$data] . 'em';
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
 				'tag' => 'time',
1827 1827
 				'type' => 'unparsed_content',
1828 1828
 				'content' => '$1',
1829
-				'validate' => function (&$tag, &$data, $disabled)
1829
+				'validate' => function(&$tag, &$data, $disabled)
1830 1830
 				{
1831 1831
 					if (is_numeric($data))
1832 1832
 						$data = timeformat($data);
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
 				'tag' => 'url',
1860 1860
 				'type' => 'unparsed_content',
1861 1861
 				'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>',
1862
-				'validate' => function (&$tag, &$data, $disabled)
1862
+				'validate' => function(&$tag, &$data, $disabled)
1863 1863
 				{
1864 1864
 					$data = strtr($data, array('<br>' => ''));
1865 1865
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1873,7 +1873,7 @@  discard block
 block discarded – undo
1873 1873
 				'quoted' => 'optional',
1874 1874
 				'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">',
1875 1875
 				'after' => '</a>',
1876
-				'validate' => function (&$tag, &$data, $disabled)
1876
+				'validate' => function(&$tag, &$data, $disabled)
1877 1877
 				{
1878 1878
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1879 1879
 					if (empty($scheme))
@@ -1912,7 +1912,7 @@  discard block
 block discarded – undo
1912 1912
 		{
1913 1913
 			if (isset($temp_bbc))
1914 1914
 				$bbc_codes = $temp_bbc;
1915
-			usort($codes, function ($a, $b) {
1915
+			usort($codes, function($a, $b) {
1916 1916
 				return strcmp($a['tag'], $b['tag']);
1917 1917
 			});
1918 1918
 			return $codes;
@@ -2128,7 +2128,7 @@  discard block
 block discarded – undo
2128 2128
 										# a run of Unicode domain name characters and a dot
2129 2129
 										[\p{L}\p{M}\p{N}\-.:@]+\.
2130 2130
 										# and then a TLD valid in the DNS or the reserved "local" TLD
2131
-										(?:'. $modSettings['tld_regex'] .'|local)
2131
+										(?:'. $modSettings['tld_regex'] . '|local)
2132 2132
 									)
2133 2133
 									# followed by a non-domain character or end of line
2134 2134
 									(?=[^\p{L}\p{N}\-.]|$)
@@ -2196,7 +2196,7 @@  discard block
 block discarded – undo
2196 2196
 						)?
2197 2197
 						';
2198 2198
 
2199
-						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) {
2199
+						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) {
2200 2200
 							$url = array_shift($matches);
2201 2201
 
2202 2202
 							// If this isn't a clean URL, bail out
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
 								$fullUrl = $url;
2222 2222
 
2223 2223
 							// Make sure that $fullUrl really is valid
2224
-							if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false)
2224
+							if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '') . $fullUrl) === false)
2225 2225
 								return $url;
2226 2226
 
2227 2227
 							return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2286 2286
 
2287 2287
 			// A closing tag that doesn't match any open tags? Skip it.
2288
-			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags)))
2288
+			if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags)))
2289 2289
 				continue;
2290 2290
 
2291 2291
 			$to_close = array();
@@ -2958,7 +2958,7 @@  discard block
 block discarded – undo
2958 2958
 			{
2959 2959
 				$exts = array('svg', 'png', 'gif', 'jpg');
2960 2960
 				$fname = pathinfo($smileysto[$i], PATHINFO_FILENAME);
2961
-				$alt_images = glob($smileys_dir . $fname .  '.{' . (implode(',', $exts)) . '}', GLOB_BRACE);
2961
+				$alt_images = glob($smileys_dir . $fname . '.{' . (implode(',', $exts)) . '}', GLOB_BRACE);
2962 2962
 				if (!empty($alt_images))
2963 2963
 				{
2964 2964
 					foreach ($exts as $ext)
@@ -2974,7 +2974,7 @@  discard block
 block discarded – undo
2974 2974
 			}
2975 2975
 
2976 2976
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
2977
-			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2977
+			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2978 2978
 
2979 2979
 			$smileyPregReplacements[$smileysfrom[$i]] = $smileyCode;
2980 2980
 
@@ -2991,7 +2991,7 @@  discard block
 block discarded – undo
2991 2991
 
2992 2992
 	// Replace away!
2993 2993
 	$message = preg_replace_callback($smileyPregSearch,
2994
-		function ($matches) use ($smileyPregReplacements)
2994
+		function($matches) use ($smileyPregReplacements)
2995 2995
 		{
2996 2996
 			return $smileyPregReplacements[$matches[1]];
2997 2997
 		}, $message);
@@ -3088,13 +3088,13 @@  discard block
 block discarded – undo
3088 3088
 	{
3089 3089
 		if (defined('SID') && SID != '')
3090 3090
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
3091
-				function ($m) use ($scripturl)
3091
+				function($m) use ($scripturl)
3092 3092
 				{
3093
-					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
3093
+					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
3094 3094
 				}, $setLocation);
3095 3095
 		else
3096 3096
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
3097
-				function ($m) use ($scripturl)
3097
+				function($m) use ($scripturl)
3098 3098
 				{
3099 3099
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
3100 3100
 				}, $setLocation);
@@ -3415,7 +3415,7 @@  discard block
 block discarded – undo
3415 3415
 
3416 3416
 	// Add a generic "Are you sure?" confirmation message.
3417 3417
 	addInlineJavaScript('
3418
-	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3418
+	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';');
3419 3419
 
3420 3420
 	// Now add the capping code for avatars.
3421 3421
 	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
@@ -3881,7 +3881,7 @@  discard block
 block discarded – undo
3881 3881
 	if (!empty($normal))
3882 3882
 		foreach ($normal as $nf)
3883 3883
 			echo '
3884
-	<link rel="stylesheet" href="', $nf ,'">';
3884
+	<link rel="stylesheet" href="', $nf, '">';
3885 3885
 
3886 3886
 	if ($db_show_debug === true)
3887 3887
 	{
@@ -3897,7 +3897,7 @@  discard block
 block discarded – undo
3897 3897
 	<style>';
3898 3898
 
3899 3899
 		foreach ($context['css_header'] as $css)
3900
-			echo $css .'
3900
+			echo $css . '
3901 3901
 	';
3902 3902
 
3903 3903
 		echo'
@@ -3941,7 +3941,7 @@  discard block
 block discarded – undo
3941 3941
 
3942 3942
 
3943 3943
 	// No namespaces, sorry!
3944
-	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
3944
+	$classType = 'MatthiasMullie\\Minify\\' . strtoupper($type);
3945 3945
 
3946 3946
 	// Temp path.
3947 3947
 	$cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/';
@@ -4121,7 +4121,7 @@  discard block
 block discarded – undo
4121 4121
 	else
4122 4122
 		$path = $modSettings['attachmentUploadDir'];
4123 4123
 
4124
-	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
4124
+	return $path . '/' . $attachment_id . '_' . $file_hash . '.dat';
4125 4125
 }
4126 4126
 
4127 4127
 /**
@@ -4165,10 +4165,10 @@  discard block
 block discarded – undo
4165 4165
 		$valid_low = isValidIP($ip_parts[0]);
4166 4166
 		$valid_high = isValidIP($ip_parts[1]);
4167 4167
 		$count = 0;
4168
-		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
4168
+		$mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.');
4169 4169
 		$max = ($mode == ':' ? 'ffff' : '255');
4170 4170
 		$min = 0;
4171
-		if(!$valid_low)
4171
+		if (!$valid_low)
4172 4172
 		{
4173 4173
 			$ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]);
4174 4174
 			$valid_low = isValidIP($ip_parts[0]);
@@ -4182,7 +4182,7 @@  discard block
 block discarded – undo
4182 4182
 		}
4183 4183
 
4184 4184
 		$count = 0;
4185
-		if(!$valid_high)
4185
+		if (!$valid_high)
4186 4186
 		{
4187 4187
 			$ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]);
4188 4188
 			$valid_high = isValidIP($ip_parts[1]);
@@ -4195,7 +4195,7 @@  discard block
 block discarded – undo
4195 4195
 			}
4196 4196
 		}
4197 4197
 
4198
-		if($valid_high && $valid_low)
4198
+		if ($valid_high && $valid_low)
4199 4199
 		{
4200 4200
 			$ip_array['low'] = $ip_parts[0];
4201 4201
 			$ip_array['high'] = $ip_parts[1];
@@ -4376,7 +4376,7 @@  discard block
 block discarded – undo
4376 4376
 		addInlineJavaScript('
4377 4377
 	var user_menus = new smc_PopupMenu();
4378 4378
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4379
-	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4379
+	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true);
4380 4380
 		if ($context['allow_pm'])
4381 4381
 			addInlineJavaScript('
4382 4382
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
@@ -5012,7 +5012,7 @@  discard block
 block discarded – undo
5012 5012
 		// No? try a fallback to $sourcedir
5013 5013
 		else
5014 5014
 		{
5015
-			$absPath = $sourcedir .'/'. $file;
5015
+			$absPath = $sourcedir . '/' . $file;
5016 5016
 
5017 5017
 			if (file_exists($absPath))
5018 5018
 				require_once($absPath);
@@ -5279,15 +5279,15 @@  discard block
 block discarded – undo
5279 5279
 
5280 5280
 	// UTF-8 occurences of MS special characters
5281 5281
 	$findchars_utf8 = array(
5282
-		"\xe2\x80\x9a",	// single low-9 quotation mark
5283
-		"\xe2\x80\x9e",	// double low-9 quotation mark
5284
-		"\xe2\x80\xa6",	// horizontal ellipsis
5285
-		"\xe2\x80\x98",	// left single curly quote
5286
-		"\xe2\x80\x99",	// right single curly quote
5287
-		"\xe2\x80\x9c",	// left double curly quote
5288
-		"\xe2\x80\x9d",	// right double curly quote
5289
-		"\xe2\x80\x93",	// en dash
5290
-		"\xe2\x80\x94",	// em dash
5282
+		"\xe2\x80\x9a", // single low-9 quotation mark
5283
+		"\xe2\x80\x9e", // double low-9 quotation mark
5284
+		"\xe2\x80\xa6", // horizontal ellipsis
5285
+		"\xe2\x80\x98", // left single curly quote
5286
+		"\xe2\x80\x99", // right single curly quote
5287
+		"\xe2\x80\x9c", // left double curly quote
5288
+		"\xe2\x80\x9d", // right double curly quote
5289
+		"\xe2\x80\x93", // en dash
5290
+		"\xe2\x80\x94", // em dash
5291 5291
 	);
5292 5292
 
5293 5293
 	// windows 1252 / iso equivalents
@@ -5305,15 +5305,15 @@  discard block
 block discarded – undo
5305 5305
 
5306 5306
 	// safe replacements
5307 5307
 	$replacechars = array(
5308
-		',',	// &sbquo;
5309
-		',,',	// &bdquo;
5310
-		'...',	// &hellip;
5311
-		"'",	// &lsquo;
5312
-		"'",	// &rsquo;
5313
-		'"',	// &ldquo;
5314
-		'"',	// &rdquo;
5315
-		'-',	// &ndash;
5316
-		'--',	// &mdash;
5308
+		',', // &sbquo;
5309
+		',,', // &bdquo;
5310
+		'...', // &hellip;
5311
+		"'", // &lsquo;
5312
+		"'", // &rsquo;
5313
+		'"', // &ldquo;
5314
+		'"', // &rdquo;
5315
+		'-', // &ndash;
5316
+		'--', // &mdash;
5317 5317
 	);
5318 5318
 
5319 5319
 	if ($context['utf8'])
@@ -5633,7 +5633,7 @@  discard block
 block discarded – undo
5633 5633
  */
5634 5634
 function inet_dtop($bin)
5635 5635
 {
5636
-	if(empty($bin))
5636
+	if (empty($bin))
5637 5637
 		return '';
5638 5638
 
5639 5639
 	global $db_type;
@@ -5664,28 +5664,28 @@  discard block
 block discarded – undo
5664 5664
  */
5665 5665
 function _safe_serialize($value)
5666 5666
 {
5667
-	if(is_null($value))
5667
+	if (is_null($value))
5668 5668
 		return 'N;';
5669 5669
 
5670
-	if(is_bool($value))
5671
-		return 'b:'. (int) $value .';';
5670
+	if (is_bool($value))
5671
+		return 'b:' . (int) $value . ';';
5672 5672
 
5673
-	if(is_int($value))
5674
-		return 'i:'. $value .';';
5673
+	if (is_int($value))
5674
+		return 'i:' . $value . ';';
5675 5675
 
5676
-	if(is_float($value))
5677
-		return 'd:'. str_replace(',', '.', $value) .';';
5676
+	if (is_float($value))
5677
+		return 'd:' . str_replace(',', '.', $value) . ';';
5678 5678
 
5679
-	if(is_string($value))
5680
-		return 's:'. strlen($value) .':"'. $value .'";';
5679
+	if (is_string($value))
5680
+		return 's:' . strlen($value) . ':"' . $value . '";';
5681 5681
 
5682
-	if(is_array($value))
5682
+	if (is_array($value))
5683 5683
 	{
5684 5684
 		$out = '';
5685
-		foreach($value as $k => $v)
5685
+		foreach ($value as $k => $v)
5686 5686
 			$out .= _safe_serialize($k) . _safe_serialize($v);
5687 5687
 
5688
-		return 'a:'. count($value) .':{'. $out .'}';
5688
+		return 'a:' . count($value) . ':{' . $out . '}';
5689 5689
 	}
5690 5690
 
5691 5691
 	// safe_serialize cannot serialize resources or objects.
@@ -5727,7 +5727,7 @@  discard block
 block discarded – undo
5727 5727
 function _safe_unserialize($str)
5728 5728
 {
5729 5729
 	// Input  is not a string.
5730
-	if(empty($str) || !is_string($str))
5730
+	if (empty($str) || !is_string($str))
5731 5731
 		return false;
5732 5732
 
5733 5733
 	$stack = array();
@@ -5741,40 +5741,40 @@  discard block
 block discarded – undo
5741 5741
 	 *   3 - in array, expecting value or another array
5742 5742
 	 */
5743 5743
 	$state = 0;
5744
-	while($state != 1)
5744
+	while ($state != 1)
5745 5745
 	{
5746 5746
 		$type = isset($str[0]) ? $str[0] : '';
5747
-		if($type == '}')
5747
+		if ($type == '}')
5748 5748
 			$str = substr($str, 1);
5749 5749
 
5750
-		else if($type == 'N' && $str[1] == ';')
5750
+		else if ($type == 'N' && $str[1] == ';')
5751 5751
 		{
5752 5752
 			$value = null;
5753 5753
 			$str = substr($str, 2);
5754 5754
 		}
5755
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5755
+		else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5756 5756
 		{
5757 5757
 			$value = $matches[1] == '1' ? true : false;
5758 5758
 			$str = substr($str, 4);
5759 5759
 		}
5760
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5760
+		else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5761 5761
 		{
5762
-			$value = (int)$matches[1];
5762
+			$value = (int) $matches[1];
5763 5763
 			$str = $matches[2];
5764 5764
 		}
5765
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5765
+		else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5766 5766
 		{
5767
-			$value = (float)$matches[1];
5767
+			$value = (float) $matches[1];
5768 5768
 			$str = $matches[3];
5769 5769
 		}
5770
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5770
+		else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";')
5771 5771
 		{
5772
-			$value = substr($matches[2], 0, (int)$matches[1]);
5773
-			$str = substr($matches[2], (int)$matches[1] + 2);
5772
+			$value = substr($matches[2], 0, (int) $matches[1]);
5773
+			$str = substr($matches[2], (int) $matches[1] + 2);
5774 5774
 		}
5775
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5775
+		else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5776 5776
 		{
5777
-			$expectedLength = (int)$matches[1];
5777
+			$expectedLength = (int) $matches[1];
5778 5778
 			$str = $matches[2];
5779 5779
 		}
5780 5780
 
@@ -5782,10 +5782,10 @@  discard block
 block discarded – undo
5782 5782
 		else
5783 5783
 			return false;
5784 5784
 
5785
-		switch($state)
5785
+		switch ($state)
5786 5786
 		{
5787 5787
 			case 3: // In array, expecting value or another array.
5788
-				if($type == 'a')
5788
+				if ($type == 'a')
5789 5789
 				{
5790 5790
 					$stack[] = &$list;
5791 5791
 					$list[$key] = array();
@@ -5794,7 +5794,7 @@  discard block
 block discarded – undo
5794 5794
 					$state = 2;
5795 5795
 					break;
5796 5796
 				}
5797
-				if($type != '}')
5797
+				if ($type != '}')
5798 5798
 				{
5799 5799
 					$list[$key] = $value;
5800 5800
 					$state = 2;
@@ -5805,29 +5805,29 @@  discard block
 block discarded – undo
5805 5805
 				return false;
5806 5806
 
5807 5807
 			case 2: // in array, expecting end of array or a key
5808
-				if($type == '}')
5808
+				if ($type == '}')
5809 5809
 				{
5810 5810
 					// Array size is less than expected.
5811
-					if(count($list) < end($expected))
5811
+					if (count($list) < end($expected))
5812 5812
 						return false;
5813 5813
 
5814 5814
 					unset($list);
5815
-					$list = &$stack[count($stack)-1];
5815
+					$list = &$stack[count($stack) - 1];
5816 5816
 					array_pop($stack);
5817 5817
 
5818 5818
 					// Go to terminal state if we're at the end of the root array.
5819 5819
 					array_pop($expected);
5820 5820
 
5821
-					if(count($expected) == 0)
5821
+					if (count($expected) == 0)
5822 5822
 						$state = 1;
5823 5823
 
5824 5824
 					break;
5825 5825
 				}
5826 5826
 
5827
-				if($type == 'i' || $type == 's')
5827
+				if ($type == 'i' || $type == 's')
5828 5828
 				{
5829 5829
 					// Array size exceeds expected length.
5830
-					if(count($list) >= end($expected))
5830
+					if (count($list) >= end($expected))
5831 5831
 						return false;
5832 5832
 
5833 5833
 					$key = $value;
@@ -5840,7 +5840,7 @@  discard block
 block discarded – undo
5840 5840
 
5841 5841
 			// Expecting array or value.
5842 5842
 			case 0:
5843
-				if($type == 'a')
5843
+				if ($type == 'a')
5844 5844
 				{
5845 5845
 					$data = array();
5846 5846
 					$list = &$data;
@@ -5849,7 +5849,7 @@  discard block
 block discarded – undo
5849 5849
 					break;
5850 5850
 				}
5851 5851
 
5852
-				if($type != '}')
5852
+				if ($type != '}')
5853 5853
 				{
5854 5854
 					$data = $value;
5855 5855
 					$state = 1;
@@ -5862,7 +5862,7 @@  discard block
 block discarded – undo
5862 5862
 	}
5863 5863
 
5864 5864
 	// Trailing data in input.
5865
-	if(!empty($str))
5865
+	if (!empty($str))
5866 5866
 		return false;
5867 5867
 
5868 5868
 	return $data;
@@ -5916,7 +5916,7 @@  discard block
 block discarded – undo
5916 5916
 	// Set different modes.
5917 5917
 	$chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);
5918 5918
 
5919
-	foreach($chmodValues as $val)
5919
+	foreach ($chmodValues as $val)
5920 5920
 	{
5921 5921
 		// If it's writable, break out of the loop.
5922 5922
 		if (is_writable($file))
@@ -5951,13 +5951,13 @@  discard block
 block discarded – undo
5951 5951
 	$returnArray = @json_decode($json, $returnAsArray);
5952 5952
 
5953 5953
 	// PHP 5.3 so no json_last_error_msg()
5954
-	switch(json_last_error())
5954
+	switch (json_last_error())
5955 5955
 	{
5956 5956
 		case JSON_ERROR_NONE:
5957 5957
 			$jsonError = false;
5958 5958
 			break;
5959 5959
 		case JSON_ERROR_DEPTH:
5960
-			$jsonError =  'JSON_ERROR_DEPTH';
5960
+			$jsonError = 'JSON_ERROR_DEPTH';
5961 5961
 			break;
5962 5962
 		case JSON_ERROR_STATE_MISMATCH:
5963 5963
 			$jsonError = 'JSON_ERROR_STATE_MISMATCH';
@@ -5985,10 +5985,10 @@  discard block
 block discarded – undo
5985 5985
 		loadLanguage('Errors');
5986 5986
 
5987 5987
 		if (!empty($jsonDebug))
5988
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5988
+			log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5989 5989
 
5990 5990
 		else
5991
-			log_error($txt['json_'. $jsonError], 'critical');
5991
+			log_error($txt['json_' . $jsonError], 'critical');
5992 5992
 
5993 5993
 		// Everyone expects an array.
5994 5994
 		return array();
@@ -6105,7 +6105,7 @@  discard block
 block discarded – undo
6105 6105
 		// Convert Punycode to Unicode
6106 6106
 		require_once($sourcedir . '/Class-Punycode.php');
6107 6107
 		$Punycode = new Punycode();
6108
-		$tlds = array_map(function ($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds);
6108
+		$tlds = array_map(function($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds);
6109 6109
 	}
6110 6110
 	// Otherwise, use the 2012 list of gTLDs and ccTLDs for now and schedule a background update
6111 6111
 	else
@@ -6199,7 +6199,7 @@  discard block
 block discarded – undo
6199 6199
 	}
6200 6200
 
6201 6201
 	// This recursive function creates the index array from the strings
6202
-	$add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
6202
+	$add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
6203 6203
 	{
6204 6204
 		static $depth = 0;
6205 6205
 		$depth++;
@@ -6226,7 +6226,7 @@  discard block
 block discarded – undo
6226 6226
 	};
6227 6227
 
6228 6228
 	// This recursive function turns the index array into a regular expression
6229
-	$index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex)
6229
+	$index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex)
6230 6230
 	{
6231 6231
 		static $depth = 0;
6232 6232
 		$depth++;
@@ -6250,11 +6250,11 @@  discard block
 block discarded – undo
6250 6250
 
6251 6251
 				if (count(array_keys($value)) == 1)
6252 6252
 				{
6253
-					$new_key_array = explode('(?'.'>', $sub_regex);
6253
+					$new_key_array = explode('(?' . '>', $sub_regex);
6254 6254
 					$new_key .= $new_key_array[0];
6255 6255
 				}
6256 6256
 				else
6257
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
6257
+					$sub_regex = '(?' . '>' . $sub_regex . ')';
6258 6258
 			}
6259 6259
 
6260 6260
 			if ($depth > 1)
@@ -6297,10 +6297,10 @@  discard block
 block discarded – undo
6297 6297
 	{
6298 6298
 		$regex = array();
6299 6299
 		while (!empty($index))
6300
-			$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6300
+			$regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')';
6301 6301
 	}
6302 6302
 	else
6303
-		$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6303
+		$regex = '(?' . '>' . $index_to_regex($index, $delim) . ')';
6304 6304
 
6305 6305
 	// Restore PHP's internal character encoding to whatever it was originally
6306 6306
 	if (!empty($current_encoding))
@@ -6524,7 +6524,7 @@  discard block
 block discarded – undo
6524 6524
 function sanitize_iri($iri)
6525 6525
 {
6526 6526
 	// Encode any non-ASCII characters (but not space or control characters of any sort)
6527
-	$iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function ($matches) {
6527
+	$iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function($matches) {
6528 6528
 		return rawurlencode($matches[0]);
6529 6529
 	}, $iri);
6530 6530
 
@@ -6566,7 +6566,7 @@  discard block
 block discarded – undo
6566 6566
 	$unescaped = array(
6567 6567
 		'%21'=>'!', '%23'=>'#', '%24'=>'$', '%26'=>'&',
6568 6568
 		'%27'=>"'", '%28'=>'(', '%29'=>')', '%2A'=>'*',
6569
-		'%2B'=>'+', '%2C'=>',',	'%2F'=>'/', '%3A'=>':',
6569
+		'%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':',
6570 6570
 		'%3B'=>';', '%3D'=>'=', '%3F'=>'?', '%40'=>'@',
6571 6571
 	);
6572 6572
 	$iri = strtr(rawurlencode($iri), $unescaped);
Please login to merge, or discard this patch.