@@ -44,7 +44,7 @@ |
||
| 44 | 44 | ORDER BY m.icon_order', |
| 45 | 45 | [] |
| 46 | 46 | )->fetch_callback( |
| 47 | - function ($row) use (&$icons, &$last_icon, &$trueOrder) { |
|
| 47 | + function($row) use (&$icons, &$last_icon, &$trueOrder) { |
|
| 48 | 48 | global $settings, $txt; |
| 49 | 49 | |
| 50 | 50 | $icons[$row['id_icon']] = [ |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | 'moderate_forum' => 'moderate_forum', |
| 109 | 109 | ] |
| 110 | 110 | )->fetch_callback( |
| 111 | - function ($row) use (&$groups) { |
|
| 111 | + function($row) use (&$groups) { |
|
| 112 | 112 | $groups[] = $row['id_group']; |
| 113 | 113 | } |
| 114 | 114 | ); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | 'group_array_implode' => implode(', additional_groups) != 0 OR FIND_IN_SET(', $groups), |
| 133 | 133 | ] |
| 134 | 134 | )->fetch_callback( |
| 135 | - function ($row) use ($type, $member_name, $memberID, $language) { |
|
| 135 | + function($row) use ($type, $member_name, $memberID, $language) { |
|
| 136 | 136 | global $scripturl, $modSettings; |
| 137 | 137 | |
| 138 | 138 | $replacements = [ |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | 'mention_types' => $notification_types, |
| 285 | 285 | ] |
| 286 | 286 | )->fetch_callback( |
| 287 | - function ($row) use (&$results) { |
|
| 287 | + function($row) use (&$results) { |
|
| 288 | 288 | if (!isset($results[$row['id_member']])) |
| 289 | 289 | { |
| 290 | 290 | $results[$row['id_member']] = []; |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | return false; |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - $blowfish_salt = '$2a$07$' . $memSalt . $modSettings['unsubscribe_site_salt']. '$'; |
|
| 505 | + $blowfish_salt = '$2a$07$' . $memSalt . $modSettings['unsubscribe_site_salt'] . '$'; |
|
| 506 | 506 | $expected = substr($blowfish_salt, 0, 28) . $hash; |
| 507 | 507 | $check = crypt($area . $memEmail . $memSalt, $blowfish_salt); |
| 508 | 508 | |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | 'attachment_type' => 0, |
| 541 | 541 | ] |
| 542 | 542 | )->fetch_callback( |
| 543 | - function ($row) use (&$topicData, &$boards_index, $type) { |
|
| 543 | + function($row) use (&$topicData, &$boards_index, $type) { |
|
| 544 | 544 | // all the boards for these topics, used to find all the members to be notified |
| 545 | 545 | $boards_index[] = $row['id_board']; |
| 546 | 546 | |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | 'members_only' => is_array($members_only) ? $members_only : [$members_only], |
| 633 | 633 | ] |
| 634 | 634 | )->fetch_callback( |
| 635 | - function ($row) use (&$boardNotifyData) { |
|
| 635 | + function($row) use (&$boardNotifyData) { |
|
| 636 | 636 | // The board subscription information for the member |
| 637 | 637 | $clean = [ |
| 638 | 638 | 'id_member' => (int) $row['id_member'], |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | 'members_only' => is_array($members_only) ? $members_only : [$members_only], |
| 716 | 716 | ] |
| 717 | 717 | )->fetch_callback( |
| 718 | - function ($row) use (&$topicNotifyData) { |
|
| 718 | + function($row) use (&$topicNotifyData) { |
|
| 719 | 719 | // The topic subscription information for the member |
| 720 | 720 | $clean = [ |
| 721 | 721 | 'id_member' => (int) $row['id_member'], |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | 'notify_regularity' => 2, |
| 820 | 820 | ] |
| 821 | 821 | )->fetch_callback( |
| 822 | - function ($row) use (&$approvalNotifyData) { |
|
| 822 | + function($row) use (&$approvalNotifyData) { |
|
| 823 | 823 | $clean = [ |
| 824 | 824 | 'id_member' => (int) $row['id_member'], |
| 825 | 825 | 'email_address' => $row['email_address'], |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | 'smiley_list' => $smileys, |
| 44 | 44 | ] |
| 45 | 45 | )->fetch_callback( |
| 46 | - function ($row) use (&$found) { |
|
| 46 | + function($row) use (&$found) { |
|
| 47 | 47 | $found[] = $row['filename']; |
| 48 | 48 | } |
| 49 | 49 | ); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | 'current_smiley' => $id, |
| 213 | 213 | ] |
| 214 | 214 | )->fetch_callback( |
| 215 | - function ($row) use (&$current_smiley) |
|
| 215 | + function($row) use (&$current_smiley) |
|
| 216 | 216 | { |
| 217 | 217 | $current_smiley = [ |
| 218 | 218 | 'id' => $row['id'], |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | 'hidden' => 1, |
| 381 | 381 | ] |
| 382 | 382 | )->fetch_callback( |
| 383 | - function ($row) use (&$smileys) { |
|
| 383 | + function($row) use (&$smileys) { |
|
| 384 | 384 | global $context; |
| 385 | 385 | |
| 386 | 386 | $location = empty($row['hidden']) ? 'postform' : 'popup'; |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | { |
| 630 | 630 | global $modSettings; |
| 631 | 631 | |
| 632 | - $smiley_types = ['jpg', 'gif', 'jpeg', 'png', 'webp', 'svg']; |
|
| 632 | + $smiley_types = ['jpg', 'gif', 'jpeg', 'png', 'webp', 'svg']; |
|
| 633 | 633 | $smileys_dir = empty($modSettings['smileys_dir']) ? BOARDDIR . '/smileys' : $modSettings['smileys_dir']; |
| 634 | 634 | $fileFunc = FileFunctions::instance(); |
| 635 | 635 | $extensionTypes = []; |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | ORDER BY smiley_row, smiley_order', |
| 688 | 688 | [] |
| 689 | 689 | )->fetch_callback( |
| 690 | - function ($row) use (&$smileys, $context) { |
|
| 690 | + function($row) use (&$smileys, $context) { |
|
| 691 | 691 | $filename = $row['filename'] . '.' . $context['smiley_extension']; |
| 692 | 692 | if (possibleSmileEmoji($row)) |
| 693 | 693 | { |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | if ($test !== $row['filename'] && preg_match('~data-emoji-code=["\'](.*?)["\']~', $test, $result)) |
| 739 | 739 | { |
| 740 | 740 | // Valid emoji, set the filename to the proper emoji file and type |
| 741 | - $row['emoji'] = $result[1]; |
|
| 741 | + $row['emoji'] = $result[1]; |
|
| 742 | 742 | return true; |
| 743 | 743 | } |
| 744 | 744 | } |
@@ -486,7 +486,7 @@ |
||
| 486 | 486 | { |
| 487 | 487 | // Now loop through the remaining (database-based) settings. |
| 488 | 488 | $this->configVars = array_map( |
| 489 | - static function ($configVar) { |
|
| 489 | + static function($configVar) { |
|
| 490 | 490 | // We just saved the file-based settings, so skip their definitions. |
| 491 | 491 | if (!is_array($configVar) || $configVar[2] === 'file') |
| 492 | 492 | { |
@@ -275,7 +275,7 @@ |
||
| 275 | 275 | { |
| 276 | 276 | global $modSettings; |
| 277 | 277 | |
| 278 | - set_error_handler(static function () { /* ignore errors */ }); |
|
| 278 | + set_error_handler(static function() { /* ignore errors */ }); |
|
| 279 | 279 | try |
| 280 | 280 | { |
| 281 | 281 | $mySphinx = mysqli_connect(($modSettings['sphinx_searchd_server'] === 'localhost' ? '127.0.0.1' : $modSettings['sphinx_searchd_server']), '', '', '', (int) $modSettings['sphinxql_searchd_port']); |
@@ -777,7 +777,7 @@ |
||
| 777 | 777 | updateTopicStats(); |
| 778 | 778 | require_once(SUBSDIR . '/Messages.subs.php'); |
| 779 | 779 | updateMessageStats(); |
| 780 | - updateSettings(['calendar_updated' => time(),]); |
|
| 780 | + updateSettings(['calendar_updated' => time(), ]); |
|
| 781 | 781 | |
| 782 | 782 | if (!empty($affectedBoards)) |
| 783 | 783 | { |
@@ -230,7 +230,7 @@ |
||
| 230 | 230 | </div>'; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $has_top_border =(!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 233 | + $has_top_border = (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 234 | 234 | || (!empty($message['member']['custom_fields']) && empty($options['show_no_signatures']) && $context['signature_enabled']); |
| 235 | 235 | |
| 236 | 236 | echo ' |
@@ -274,7 +274,7 @@ |
||
| 274 | 274 | global $txt; |
| 275 | 275 | |
| 276 | 276 | // Try to connect to the SMTP server... if it doesn't exist, only wait three seconds. |
| 277 | - set_error_handler(static function () { /* ignore errors */ }); |
|
| 277 | + set_error_handler(static function() { /* ignore errors */ }); |
|
| 278 | 278 | try |
| 279 | 279 | { |
| 280 | 280 | $socket = fsockopen($smtp_host, $smtp_port, $errno, $errstr, 3); |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | */ |
| 1206 | 1206 | private static function ensureExpandedStates() { |
| 1207 | 1207 | // Already done? |
| 1208 | - if ( self::$expandedStates ) { |
|
| 1208 | + if (self::$expandedStates) { |
|
| 1209 | 1209 | return; |
| 1210 | 1210 | } |
| 1211 | 1211 | self::$expandedStates = true; |
@@ -1213,12 +1213,12 @@ discard block |
||
| 1213 | 1213 | // Add copies of all states (except FUNC and GENFUNC) with negative numbers. |
| 1214 | 1214 | // These negative states represent states inside generator functions. When in these states, |
| 1215 | 1215 | // TYPE_YIELD is treated as TYPE_RETURN, otherwise as TYPE_LITERAL |
| 1216 | - foreach ( self::$model as $state => $transitions ) { |
|
| 1217 | - if ( $state !== self::FUNC && $state !== self::GENFUNC ) { |
|
| 1218 | - foreach ( $transitions as $tokenType => $actions ) { |
|
| 1219 | - foreach ( $actions as $action => $target ) { |
|
| 1220 | - if ( is_array( $target ) ) { |
|
| 1221 | - foreach ( $target as $subaction => $subtarget ) { |
|
| 1216 | + foreach (self::$model as $state => $transitions) { |
|
| 1217 | + if ($state !== self::FUNC && $state !== self::GENFUNC) { |
|
| 1218 | + foreach ($transitions as $tokenType => $actions) { |
|
| 1219 | + foreach ($actions as $action => $target) { |
|
| 1220 | + if (is_array($target)) { |
|
| 1221 | + foreach ($target as $subaction => $subtarget) { |
|
| 1222 | 1222 | self::$model[-$state][$tokenType][$action][$subaction] = |
| 1223 | 1223 | $subtarget === self::FUNC || $subtarget === true || $subtarget === self::GENFUNC |
| 1224 | 1224 | ? $subtarget : -$subtarget; |
@@ -1237,10 +1237,10 @@ discard block |
||
| 1237 | 1237 | self::$model[-self::PROPERTY_ASSIGNMENT][self::TYPE_BRACE_OPEN][self::ACTION_GOTO] = self::STATEMENT; |
| 1238 | 1238 | |
| 1239 | 1239 | // Also add negative versions of states to the other arrays |
| 1240 | - foreach ( self::$semicolon as $state => $value ) { |
|
| 1240 | + foreach (self::$semicolon as $state => $value) { |
|
| 1241 | 1241 | self::$semicolon[-$state] = $value; |
| 1242 | 1242 | } |
| 1243 | - foreach ( self::$divStates as $state => $value ) { |
|
| 1243 | + foreach (self::$divStates as $state => $value) { |
|
| 1244 | 1244 | self::$divStates[-$state] = $value; |
| 1245 | 1245 | } |
| 1246 | 1246 | } |
@@ -1251,8 +1251,8 @@ discard block |
||
| 1251 | 1251 | * @param string $s JavaScript code to minify |
| 1252 | 1252 | * @return string|bool Minified code or false on failure |
| 1253 | 1253 | */ |
| 1254 | - public static function minify( $s ) { |
|
| 1255 | - return self::minifyInternal( $s ); |
|
| 1254 | + public static function minify($s) { |
|
| 1255 | + return self::minifyInternal($s); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | /** |
@@ -1297,14 +1297,14 @@ discard block |
||
| 1297 | 1297 | * @param MappingsGenerator|null $mapGenerator |
| 1298 | 1298 | * @return bool|string |
| 1299 | 1299 | */ |
| 1300 | - public static function minifyInternal( $s, $mapGenerator = null ) { |
|
| 1300 | + public static function minifyInternal($s, $mapGenerator = null) { |
|
| 1301 | 1301 | self::ensureExpandedStates(); |
| 1302 | 1302 | |
| 1303 | 1303 | // Here's where the minifying takes place: Loop through the input, looking for tokens |
| 1304 | 1304 | // and output them to $out, taking actions to the above defined rules when appropriate. |
| 1305 | 1305 | $out = ''; |
| 1306 | 1306 | $pos = 0; |
| 1307 | - $length = strlen( $s ); |
|
| 1307 | + $length = strlen($s); |
|
| 1308 | 1308 | $lineLength = 0; |
| 1309 | 1309 | $dotlessNum = false; |
| 1310 | 1310 | $lastDotlessNum = false; |
@@ -1313,26 +1313,26 @@ discard block |
||
| 1313 | 1313 | $stack = []; |
| 1314 | 1314 | $topOfStack = null; // Optimization: calling end( $stack ) repeatedly is expensive |
| 1315 | 1315 | $last = ';'; // Pretend that we have seen a semicolon yet |
| 1316 | - while ( $pos < $length ) { |
|
| 1316 | + while ($pos < $length) { |
|
| 1317 | 1317 | // First, skip over any whitespace and multiline comments, recording whether we |
| 1318 | 1318 | // found any newline character |
| 1319 | - $skip = strspn( $s, " \t\n\r\xb\xc", $pos ); |
|
| 1320 | - if ( !$skip ) { |
|
| 1319 | + $skip = strspn($s, " \t\n\r\xb\xc", $pos); |
|
| 1320 | + if (!$skip) { |
|
| 1321 | 1321 | $ch = $s[$pos]; |
| 1322 | - if ( $ch === '/' && substr( $s, $pos, 2 ) === '/*' ) { |
|
| 1322 | + if ($ch === '/' && substr($s, $pos, 2) === '/*') { |
|
| 1323 | 1323 | // Multiline comment. Search for the end token or EOT. |
| 1324 | - $end = strpos( $s, '*/', $pos + 2 ); |
|
| 1324 | + $end = strpos($s, '*/', $pos + 2); |
|
| 1325 | 1325 | $skip = $end === false ? $length - $pos : $end - $pos + 2; |
| 1326 | 1326 | } |
| 1327 | 1327 | } |
| 1328 | - if ( $skip ) { |
|
| 1328 | + if ($skip) { |
|
| 1329 | 1329 | // The semicolon insertion mechanism needs to know whether there was a newline |
| 1330 | 1330 | // between two tokens, so record it now. |
| 1331 | - if ( !$newlineFound && strcspn( $s, "\r\n", $pos, $skip ) !== $skip ) { |
|
| 1331 | + if (!$newlineFound && strcspn($s, "\r\n", $pos, $skip) !== $skip) { |
|
| 1332 | 1332 | $newlineFound = true; |
| 1333 | 1333 | } |
| 1334 | - if ( $mapGenerator ) { |
|
| 1335 | - $mapGenerator->consumeSource( $skip ); |
|
| 1334 | + if ($mapGenerator) { |
|
| 1335 | + $mapGenerator->consumeSource($skip); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | $pos += $skip; |
| 1338 | 1338 | continue; |
@@ -1341,13 +1341,13 @@ discard block |
||
| 1341 | 1341 | // comments by the browser, regardless of whether the end tag is on the same line. |
| 1342 | 1342 | // Handle --> the same way, but only if it's at the beginning of the line |
| 1343 | 1343 | // @phan-suppress-next-line PhanPossiblyUndeclaredVariable |
| 1344 | - if ( ( $ch === '/' && substr( $s, $pos, 2 ) === '//' ) |
|
| 1345 | - || ( $ch === '<' && substr( $s, $pos, 4 ) === '<!--' ) |
|
| 1346 | - || ( $ch === '-' && $newlineFound && substr( $s, $pos, 3 ) === '-->' ) |
|
| 1344 | + if (($ch === '/' && substr($s, $pos, 2) === '//') |
|
| 1345 | + || ($ch === '<' && substr($s, $pos, 4) === '<!--') |
|
| 1346 | + || ($ch === '-' && $newlineFound && substr($s, $pos, 3) === '-->') |
|
| 1347 | 1347 | ) { |
| 1348 | - $skip = strcspn( $s, "\r\n", $pos ); |
|
| 1349 | - if ( $mapGenerator ) { |
|
| 1350 | - $mapGenerator->consumeSource( $skip ); |
|
| 1348 | + $skip = strcspn($s, "\r\n", $pos); |
|
| 1349 | + if ($mapGenerator) { |
|
| 1350 | + $mapGenerator->consumeSource($skip); |
|
| 1351 | 1351 | } |
| 1352 | 1352 | $pos += $skip; |
| 1353 | 1353 | continue; |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | // of any next token in the stream. |
| 1362 | 1362 | $end = $pos + 1; |
| 1363 | 1363 | // Handle string literals |
| 1364 | - if ( $ch === "'" || $ch === '"' ) { |
|
| 1364 | + if ($ch === "'" || $ch === '"') { |
|
| 1365 | 1365 | // Search to the end of the string literal, skipping over backslash escapes |
| 1366 | 1366 | $search = $ch . '\\'; |
| 1367 | 1367 | do { |
@@ -1369,13 +1369,13 @@ discard block |
||
| 1369 | 1369 | // the next iteration will start 2 characters further (one for the |
| 1370 | 1370 | // backslash, one for the escaped character). |
| 1371 | 1371 | // We'll correct this outside the loop. |
| 1372 | - $end += strcspn( $s, $search, $end ) + 2; |
|
| 1372 | + $end += strcspn($s, $search, $end) + 2; |
|
| 1373 | 1373 | // If the last character in our search for a quote or a backlash |
| 1374 | 1374 | // matched a backslash and we haven't reached the end, keep searching.. |
| 1375 | - } while ( $end - 2 < $length && $s[$end - 2] === '\\' ); |
|
| 1375 | + } while ($end - 2 < $length && $s[$end - 2] === '\\'); |
|
| 1376 | 1376 | // Correction (1): Undo speculative add, keep only one (end of string literal) |
| 1377 | 1377 | $end--; |
| 1378 | - if ( $end > $length ) { |
|
| 1378 | + if ($end > $length) { |
|
| 1379 | 1379 | // Correction (2): Loop wrongly assumed an end quote ended the search, |
| 1380 | 1380 | // but search ended because we've reached the end. Correct $end. |
| 1381 | 1381 | // TODO: This is invalid and should throw. |
@@ -1384,33 +1384,33 @@ discard block |
||
| 1384 | 1384 | |
| 1385 | 1385 | // Handle template strings, either from "`" to begin a new string, |
| 1386 | 1386 | // or continuation after the "}" that ends a "${"-expression. |
| 1387 | - } elseif ( $ch === '`' || ( $ch === '}' && $topOfStack === self::TEMPLATE_STRING_TAIL ) ) { |
|
| 1388 | - if ( $ch === '}' ) { |
|
| 1387 | + } elseif ($ch === '`' || ($ch === '}' && $topOfStack === self::TEMPLATE_STRING_TAIL)) { |
|
| 1388 | + if ($ch === '}') { |
|
| 1389 | 1389 | // Pop the TEMPLATE_STRING_TAIL state off the stack |
| 1390 | 1390 | // We don't let it get popped off the stack the normal way, to avoid the newline |
| 1391 | 1391 | // and comment stripping code above running on the continuation of the literal |
| 1392 | - array_pop( $stack ); |
|
| 1392 | + array_pop($stack); |
|
| 1393 | 1393 | // Also pop the previous state off the stack |
| 1394 | - $state = array_pop( $stack ); |
|
| 1395 | - $topOfStack = end( $stack ); |
|
| 1394 | + $state = array_pop($stack); |
|
| 1395 | + $topOfStack = end($stack); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | // Search until we reach either a closing ` or a ${, skipping over backslash escapes |
| 1398 | 1398 | // and $ characters followed by something other than { or ` |
| 1399 | 1399 | do { |
| 1400 | - $end += strcspn( $s, '`$\\', $end ) + 1; |
|
| 1401 | - if ( $end - 1 < $length && $s[$end - 1] === '`' ) { |
|
| 1400 | + $end += strcspn($s, '`$\\', $end) + 1; |
|
| 1401 | + if ($end - 1 < $length && $s[$end - 1] === '`') { |
|
| 1402 | 1402 | // End of the string, stop |
| 1403 | 1403 | // We don't do this in the while() condition because the $end++ in the |
| 1404 | 1404 | // backslash escape branch makes it difficult to do so without incorrectly |
| 1405 | 1405 | // considering an escaped backtick (\`) the end of the string |
| 1406 | 1406 | break; |
| 1407 | 1407 | } |
| 1408 | - if ( $end - 1 < $length && $s[$end - 1] === '\\' ) { |
|
| 1408 | + if ($end - 1 < $length && $s[$end - 1] === '\\') { |
|
| 1409 | 1409 | // Backslash escape. Skip the next character, and keep going |
| 1410 | 1410 | $end++; |
| 1411 | 1411 | continue; |
| 1412 | 1412 | } |
| 1413 | - if ( $end < $length && $s[$end - 1] === '$' && $s[$end] === '{' ) { |
|
| 1413 | + if ($end < $length && $s[$end - 1] === '$' && $s[$end] === '{') { |
|
| 1414 | 1414 | // Beginning of an expression in ${ ... }. Skip the {, and stop |
| 1415 | 1415 | $end++; |
| 1416 | 1416 | // Push the current state to the stack. We'll pop this off later when hitting |
@@ -1423,8 +1423,8 @@ discard block |
||
| 1423 | 1423 | $state = self::TEMPLATE_STRING_HEAD; |
| 1424 | 1424 | break; |
| 1425 | 1425 | } |
| 1426 | - } while ( $end - 1 < $length ); |
|
| 1427 | - if ( $end > $length ) { |
|
| 1426 | + } while ($end - 1 < $length); |
|
| 1427 | + if ($end > $length) { |
|
| 1428 | 1428 | // Loop wrongly assumed an end quote or ${ ended the search, |
| 1429 | 1429 | // but search ended because we've reached the end. Correct $end. |
| 1430 | 1430 | // TODO: This is invalid and should throw. |
@@ -1433,28 +1433,28 @@ discard block |
||
| 1433 | 1433 | |
| 1434 | 1434 | // We have to distinguish between regexp literals and division operators |
| 1435 | 1435 | // A division operator is only possible in certain states |
| 1436 | - } elseif ( $ch === '/' && !isset( self::$divStates[$state] ) ) { |
|
| 1436 | + } elseif ($ch === '/' && !isset(self::$divStates[$state])) { |
|
| 1437 | 1437 | // Regexp literal |
| 1438 | - for ( ; ; ) { |
|
| 1438 | + for (;;) { |
|
| 1439 | 1439 | // Search until we find "/" (end of regexp), "\" (backslash escapes), |
| 1440 | 1440 | // or "[" (start of character classes). |
| 1441 | 1441 | do { |
| 1442 | 1442 | // Speculatively add 2 to ensure next iteration skips |
| 1443 | 1443 | // over backslash and escaped character. |
| 1444 | 1444 | // We'll correct this outside the loop. |
| 1445 | - $end += strcspn( $s, '/[\\', $end ) + 2; |
|
| 1445 | + $end += strcspn($s, '/[\\', $end) + 2; |
|
| 1446 | 1446 | // If backslash escape, keep searching... |
| 1447 | - } while ( $end - 2 < $length && $s[$end - 2] === '\\' ); |
|
| 1447 | + } while ($end - 2 < $length && $s[$end - 2] === '\\'); |
|
| 1448 | 1448 | // Correction (1): Undo speculative add, keep only one (end of regexp) |
| 1449 | 1449 | $end--; |
| 1450 | - if ( $end > $length ) { |
|
| 1450 | + if ($end > $length) { |
|
| 1451 | 1451 | // Correction (2): Loop wrongly assumed end slash was seen |
| 1452 | 1452 | // String ended without end of regexp. Correct $end. |
| 1453 | 1453 | // TODO: This is invalid and should throw. |
| 1454 | 1454 | $end--; |
| 1455 | 1455 | break; |
| 1456 | 1456 | } |
| 1457 | - if ( $s[$end - 1] === '/' ) { |
|
| 1457 | + if ($s[$end - 1] === '/') { |
|
| 1458 | 1458 | break; |
| 1459 | 1459 | } |
| 1460 | 1460 | // (Implicit else), we must've found the start of a char class, |
@@ -1462,12 +1462,12 @@ discard block |
||
| 1462 | 1462 | do { |
| 1463 | 1463 | // Speculatively add 2 for backslash escape. |
| 1464 | 1464 | // We'll substract one outside the loop. |
| 1465 | - $end += strcspn( $s, ']\\', $end ) + 2; |
|
| 1465 | + $end += strcspn($s, ']\\', $end) + 2; |
|
| 1466 | 1466 | // If backslash escape, keep searching... |
| 1467 | - } while ( $end - 2 < $length && $s[$end - 2] === '\\' ); |
|
| 1467 | + } while ($end - 2 < $length && $s[$end - 2] === '\\'); |
|
| 1468 | 1468 | // Correction (1): Undo speculative add, keep only one (end of regexp) |
| 1469 | 1469 | $end--; |
| 1470 | - if ( $end > $length ) { |
|
| 1470 | + if ($end > $length) { |
|
| 1471 | 1471 | // Correction (2): Loop wrongly assumed "]" was seen |
| 1472 | 1472 | // String ended without ending char class or regexp. Correct $end. |
| 1473 | 1473 | // TODO: This is invalid and should throw. |
@@ -1476,21 +1476,21 @@ discard block |
||
| 1476 | 1476 | } |
| 1477 | 1477 | } |
| 1478 | 1478 | // Search past the regexp modifiers (gi) |
| 1479 | - while ( $end < $length && ctype_alpha( $s[$end] ) ) { |
|
| 1479 | + while ($end < $length && ctype_alpha($s[$end])) { |
|
| 1480 | 1480 | $end++; |
| 1481 | 1481 | } |
| 1482 | 1482 | } elseif ( |
| 1483 | 1483 | $ch === '0' |
| 1484 | - && ( $pos + 1 < $length ) && ( $s[$pos + 1] === 'x' || $s[$pos + 1] === 'X' ) |
|
| 1484 | + && ($pos + 1 < $length) && ($s[$pos + 1] === 'x' || $s[$pos + 1] === 'X') |
|
| 1485 | 1485 | ) { |
| 1486 | 1486 | // Hex numeric literal |
| 1487 | 1487 | $end++; // x or X |
| 1488 | - $len = strspn( $s, '0123456789ABCDEFabcdef', $end ); |
|
| 1489 | - if ( !$len ) { |
|
| 1488 | + $len = strspn($s, '0123456789ABCDEFabcdef', $end); |
|
| 1489 | + if (!$len) { |
|
| 1490 | 1490 | return self::parseError( |
| 1491 | 1491 | $s, |
| 1492 | 1492 | $pos, |
| 1493 | - 'Expected a hexadecimal number but found ' . substr( $s, $pos, 5 ) . '...' |
|
| 1493 | + 'Expected a hexadecimal number but found ' . substr($s, $pos, 5) . '...' |
|
| 1494 | 1494 | ); |
| 1495 | 1495 | } |
| 1496 | 1496 | $end += $len; |
@@ -1501,30 +1501,30 @@ discard block |
||
| 1501 | 1501 | // numbers, and exponents (e.g. strings like "+012.34e6"). But, it is fine here |
| 1502 | 1502 | // because we know $ch is a single character, and we believe the only single |
| 1503 | 1503 | // characters that is_numeric() accepts are ASCII digits 0-9. |
| 1504 | - is_numeric( $ch ) |
|
| 1505 | - || ( $ch === '.' && $pos + 1 < $length && is_numeric( $s[$pos + 1] ) ) |
|
| 1504 | + is_numeric($ch) |
|
| 1505 | + || ($ch === '.' && $pos + 1 < $length && is_numeric($s[$pos + 1])) |
|
| 1506 | 1506 | ) { |
| 1507 | - $end += strspn( $s, '0123456789', $end ); |
|
| 1508 | - $decimal = strspn( $s, '.', $end ); |
|
| 1509 | - if ( $decimal ) { |
|
| 1510 | - if ( $decimal > 2 ) { |
|
| 1511 | - return self::parseError( $s, $end, 'The number has too many decimal points' ); |
|
| 1507 | + $end += strspn($s, '0123456789', $end); |
|
| 1508 | + $decimal = strspn($s, '.', $end); |
|
| 1509 | + if ($decimal) { |
|
| 1510 | + if ($decimal > 2) { |
|
| 1511 | + return self::parseError($s, $end, 'The number has too many decimal points'); |
|
| 1512 | 1512 | } |
| 1513 | - $end += strspn( $s, '0123456789', $end + 1 ) + $decimal; |
|
| 1513 | + $end += strspn($s, '0123456789', $end + 1) + $decimal; |
|
| 1514 | 1514 | } else { |
| 1515 | 1515 | $dotlessNum = true; |
| 1516 | 1516 | } |
| 1517 | - $exponent = strspn( $s, 'eE', $end ); |
|
| 1518 | - if ( $exponent ) { |
|
| 1519 | - if ( $exponent > 1 ) { |
|
| 1520 | - return self::parseError( $s, $end, 'Number with several E' ); |
|
| 1517 | + $exponent = strspn($s, 'eE', $end); |
|
| 1518 | + if ($exponent) { |
|
| 1519 | + if ($exponent > 1) { |
|
| 1520 | + return self::parseError($s, $end, 'Number with several E'); |
|
| 1521 | 1521 | } |
| 1522 | 1522 | $end++; |
| 1523 | 1523 | |
| 1524 | 1524 | // + sign is optional; - sign is required. |
| 1525 | - $end += strspn( $s, '-+', $end ); |
|
| 1526 | - $len = strspn( $s, '0123456789', $end ); |
|
| 1527 | - if ( !$len ) { |
|
| 1525 | + $end += strspn($s, '-+', $end); |
|
| 1526 | + $len = strspn($s, '0123456789', $end); |
|
| 1527 | + if (!$len) { |
|
| 1528 | 1528 | return self::parseError( |
| 1529 | 1529 | $s, |
| 1530 | 1530 | $pos, |
@@ -1533,12 +1533,12 @@ discard block |
||
| 1533 | 1533 | } |
| 1534 | 1534 | $end += $len; |
| 1535 | 1535 | } |
| 1536 | - } elseif ( isset( self::$opChars[$ch] ) ) { |
|
| 1536 | + } elseif (isset(self::$opChars[$ch])) { |
|
| 1537 | 1537 | // Punctuation character. Search for the longest matching operator. |
| 1538 | - for ( $tokenLength = self::LONGEST_PUNCTUATION_TOKEN; $tokenLength > 1; $tokenLength-- ) { |
|
| 1538 | + for ($tokenLength = self::LONGEST_PUNCTUATION_TOKEN; $tokenLength > 1; $tokenLength--) { |
|
| 1539 | 1539 | if ( |
| 1540 | 1540 | $pos + $tokenLength <= $length && |
| 1541 | - isset( self::$tokenTypes[ substr( $s, $pos, $tokenLength ) ] ) |
|
| 1541 | + isset(self::$tokenTypes[substr($s, $pos, $tokenLength)]) |
|
| 1542 | 1542 | ) { |
| 1543 | 1543 | $end = $pos + $tokenLength; |
| 1544 | 1544 | break; |
@@ -1547,29 +1547,29 @@ discard block |
||
| 1547 | 1547 | } else { |
| 1548 | 1548 | // Identifier or reserved word. Search for the end by excluding whitespace and |
| 1549 | 1549 | // punctuation. |
| 1550 | - $end += strcspn( $s, " \t\n.;,=<>+-{}()[]?:*/%'\"`!&|^~\xb\xc\r", $end ); |
|
| 1550 | + $end += strcspn($s, " \t\n.;,=<>+-{}()[]?:*/%'\"`!&|^~\xb\xc\r", $end); |
|
| 1551 | 1551 | } |
| 1552 | 1552 | |
| 1553 | 1553 | // Now get the token type from our type array |
| 1554 | - $token = substr( $s, $pos, $end - $pos ); // so $end - $pos == strlen( $token ) |
|
| 1555 | - $type = isset( self::$model[$state][self::TYPE_SPECIAL][$token] ) |
|
| 1554 | + $token = substr($s, $pos, $end - $pos); // so $end - $pos == strlen( $token ) |
|
| 1555 | + $type = isset(self::$model[$state][self::TYPE_SPECIAL][$token]) |
|
| 1556 | 1556 | ? self::TYPE_SPECIAL |
| 1557 | 1557 | : self::$tokenTypes[$token] ?? self::TYPE_LITERAL; |
| 1558 | - if ( $type === self::TYPE_YIELD ) { |
|
| 1558 | + if ($type === self::TYPE_YIELD) { |
|
| 1559 | 1559 | // yield is treated as TYPE_RETURN inside a generator function (negative state) |
| 1560 | 1560 | // but as TYPE_LITERAL when not in a generator function (positive state) |
| 1561 | 1561 | $type = $state < 0 ? self::TYPE_RETURN : self::TYPE_LITERAL; |
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | 1564 | $pad = ''; |
| 1565 | - if ( $newlineFound && isset( self::$semicolon[$state][$type] ) ) { |
|
| 1565 | + if ($newlineFound && isset(self::$semicolon[$state][$type])) { |
|
| 1566 | 1566 | // This token triggers the semicolon insertion mechanism of javascript. While we |
| 1567 | 1567 | // could add the ; token here ourselves, keeping the newline has a few advantages. |
| 1568 | 1568 | $pad = "\n"; |
| 1569 | 1569 | $state = $state < 0 ? -self::STATEMENT : self::STATEMENT; |
| 1570 | 1570 | $lineLength = 0; |
| 1571 | - } elseif ( $lineLength + $end - $pos > self::$maxLineLength && |
|
| 1572 | - !isset( self::$semicolon[$state][$type] ) && |
|
| 1571 | + } elseif ($lineLength + $end - $pos > self::$maxLineLength && |
|
| 1572 | + !isset(self::$semicolon[$state][$type]) && |
|
| 1573 | 1573 | $type !== self::TYPE_INCR_OP && |
| 1574 | 1574 | $type !== self::TYPE_ARROW |
| 1575 | 1575 | ) { |
@@ -1580,27 +1580,27 @@ discard block |
||
| 1580 | 1580 | $pad = "\n"; |
| 1581 | 1581 | $lineLength = 0; |
| 1582 | 1582 | // Check, whether we have to separate the token from the last one with whitespace |
| 1583 | - } elseif ( !isset( self::$opChars[$last] ) && !isset( self::$opChars[$ch] ) ) { |
|
| 1583 | + } elseif (!isset(self::$opChars[$last]) && !isset(self::$opChars[$ch])) { |
|
| 1584 | 1584 | $pad = ' '; |
| 1585 | 1585 | $lineLength++; |
| 1586 | 1586 | // Don't accidentally create ++, -- or // tokens |
| 1587 | - } elseif ( $last === $ch && ( $ch === '+' || $ch === '-' || $ch === '/' ) ) { |
|
| 1587 | + } elseif ($last === $ch && ($ch === '+' || $ch === '-' || $ch === '/')) { |
|
| 1588 | 1588 | $pad = ' '; |
| 1589 | 1589 | $lineLength++; |
| 1590 | 1590 | // Don't create invalid dot notation after number literal (T303827). |
| 1591 | 1591 | // Keep whitespace in "42. foo". |
| 1592 | 1592 | // But keep minifying "foo.bar", "42..foo", and "42.0.foo" per $opChars. |
| 1593 | - } elseif ( $lastDotlessNum && $type === self::TYPE_DOT ) { |
|
| 1593 | + } elseif ($lastDotlessNum && $type === self::TYPE_DOT) { |
|
| 1594 | 1594 | $pad = ' '; |
| 1595 | 1595 | $lineLength++; |
| 1596 | 1596 | } |
| 1597 | 1597 | |
| 1598 | 1598 | // self::debug( $topOfStack, $last, $lastType, $state, $ch, $token, $type, ); |
| 1599 | 1599 | |
| 1600 | - if ( $mapGenerator ) { |
|
| 1601 | - $mapGenerator->outputSpace( $pad ); |
|
| 1602 | - $mapGenerator->outputToken( $token ); |
|
| 1603 | - $mapGenerator->consumeSource( $end - $pos ); |
|
| 1600 | + if ($mapGenerator) { |
|
| 1601 | + $mapGenerator->outputSpace($pad); |
|
| 1602 | + $mapGenerator->outputToken($token); |
|
| 1603 | + $mapGenerator->consumeSource($end - $pos); |
|
| 1604 | 1604 | } |
| 1605 | 1605 | $out .= $pad; |
| 1606 | 1606 | $out .= $token; |
@@ -1613,18 +1613,17 @@ discard block |
||
| 1613 | 1613 | |
| 1614 | 1614 | // Now that we have output our token, transition into the new state. |
| 1615 | 1615 | $actions = $type === self::TYPE_SPECIAL ? |
| 1616 | - self::$model[$state][$type][$token] : |
|
| 1617 | - self::$model[$state][$type] ?? []; |
|
| 1618 | - if ( isset( $actions[self::ACTION_PUSH] ) && |
|
| 1619 | - count( $stack ) < self::STACK_LIMIT |
|
| 1616 | + self::$model[$state][$type][$token] : self::$model[$state][$type] ?? []; |
|
| 1617 | + if (isset($actions[self::ACTION_PUSH]) && |
|
| 1618 | + count($stack) < self::STACK_LIMIT |
|
| 1620 | 1619 | ) { |
| 1621 | 1620 | $topOfStack = $actions[self::ACTION_PUSH]; |
| 1622 | 1621 | $stack[] = $topOfStack; |
| 1623 | 1622 | } |
| 1624 | - if ( $stack && isset( $actions[self::ACTION_POP] ) ) { |
|
| 1625 | - $state = array_pop( $stack ); |
|
| 1626 | - $topOfStack = end( $stack ); |
|
| 1627 | - } elseif ( isset( $actions[self::ACTION_GOTO] ) ) { |
|
| 1623 | + if ($stack && isset($actions[self::ACTION_POP])) { |
|
| 1624 | + $state = array_pop($stack); |
|
| 1625 | + $topOfStack = end($stack); |
|
| 1626 | + } elseif (isset($actions[self::ACTION_GOTO])) { |
|
| 1628 | 1627 | $state = $actions[self::ACTION_GOTO]; |
| 1629 | 1628 | } |
| 1630 | 1629 | } |
@@ -1637,7 +1636,7 @@ discard block |
||
| 1637 | 1636 | * @param string $errorMsg |
| 1638 | 1637 | * @return bool |
| 1639 | 1638 | */ |
| 1640 | - public static function parseError( $fullJavascript, $position, $errorMsg ) { |
|
| 1639 | + public static function parseError($fullJavascript, $position, $errorMsg) { |
|
| 1641 | 1640 | // TODO: Handle the error: trigger_error, throw exception, return false... |
| 1642 | 1641 | return false; |
| 1643 | 1642 | } |
@@ -1656,32 +1655,32 @@ discard block |
||
| 1656 | 1655 | int $state, string $ch, string $token, int $type |
| 1657 | 1656 | ) { |
| 1658 | 1657 | static $first = true; |
| 1659 | - $self = new \ReflectionClass( self::class ); |
|
| 1658 | + $self = new \ReflectionClass(self::class); |
|
| 1660 | 1659 | $constants = $self->getConstants(); |
| 1661 | 1660 | |
| 1662 | - foreach ( $self->getConstants() as $name => $value ) { |
|
| 1663 | - if ( $value === $top ) { |
|
| 1661 | + foreach ($self->getConstants() as $name => $value) { |
|
| 1662 | + if ($value === $top) { |
|
| 1664 | 1663 | $top = $name; |
| 1665 | 1664 | } |
| 1666 | - if ( $value === $lastType ) { |
|
| 1665 | + if ($value === $lastType) { |
|
| 1667 | 1666 | $lastType = $name; |
| 1668 | 1667 | } |
| 1669 | - if ( $value === $state ) { |
|
| 1668 | + if ($value === $state) { |
|
| 1670 | 1669 | $state = $name; |
| 1671 | 1670 | } |
| 1672 | - if ( $value === $type ) { |
|
| 1671 | + if ($value === $type) { |
|
| 1673 | 1672 | $type = $name; |
| 1674 | 1673 | } |
| 1675 | 1674 | } |
| 1676 | 1675 | |
| 1677 | - if ( $first ) { |
|
| 1678 | - print sprintf( "| %-29s | %-4s | %-29s | %-29s | %-2s | %-10s | %-29s\n", |
|
| 1679 | - 'topOfStack', 'last', 'lastType', 'state', 'ch', 'token', 'type' ); |
|
| 1680 | - print sprintf( "| %'-29s | %'-4s | %'-29s | %'-29s | %'-2s | %'-10s | %'-29s\n", |
|
| 1681 | - '', '', '', '', '', '', '' ); |
|
| 1676 | + if ($first) { |
|
| 1677 | + print sprintf("| %-29s | %-4s | %-29s | %-29s | %-2s | %-10s | %-29s\n", |
|
| 1678 | + 'topOfStack', 'last', 'lastType', 'state', 'ch', 'token', 'type'); |
|
| 1679 | + print sprintf("| %'-29s | %'-4s | %'-29s | %'-29s | %'-2s | %'-10s | %'-29s\n", |
|
| 1680 | + '', '', '', '', '', '', ''); |
|
| 1682 | 1681 | $first = false; |
| 1683 | 1682 | } |
| 1684 | - print sprintf( "| %-29s | %-4s | %-29s | %-29s | %-2s | %-10s | %-29s\n", |
|
| 1685 | - (string)$top, $last, $lastType, $state, $ch, $token, $type ); |
|
| 1683 | + print sprintf("| %-29s | %-4s | %-29s | %-29s | %-2s | %-10s | %-29s\n", |
|
| 1684 | + (string) $top, $last, $lastType, $state, $ch, $token, $type); |
|
| 1686 | 1685 | } |
| 1687 | 1686 | } |