@@ -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 | { |
@@ -212,7 +212,7 @@ |
||
212 | 212 | |
213 | 213 | // Show the post itself, finally! |
214 | 214 | echo ' |
215 | - <section id="msg_', $message['id'], '" data-msgid="',$message['id'], '" class="messageContent', $ignoring ? ' hide"' : '"', '>', |
|
215 | + <section id="msg_', $message['id'], '" data-msgid="', $message['id'], '" class="messageContent', $ignoring ? ' hide"' : '"', '>', |
|
216 | 216 | $message['body'], ' |
217 | 217 | </section> |
218 | 218 | <footer>'; |
@@ -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 ' |
@@ -607,8 +607,7 @@ |
||
607 | 607 | if ($subIdCheck === $subId |
608 | 608 | || (empty($this->currentSubaction) && $sub->isDefault()) |
609 | 609 | || in_array($subIdCheck, $sub->getActive(), true) |
610 | - ) |
|
611 | - { |
|
610 | + ) { |
|
612 | 611 | $this->currentSubaction = $subId; |
613 | 612 | } |
614 | 613 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | if (isset($_COOKIE[$cookiename])) |
52 | 52 | { |
53 | - $array = serializeToJson($_COOKIE[$cookiename], static function ($array_from) use ($cookiename) { |
|
53 | + $array = serializeToJson($_COOKIE[$cookiename], static function($array_from) use ($cookiename) { |
|
54 | 54 | global $modSettings; |
55 | 55 | |
56 | 56 | require_once(SUBSDIR . '/Auth.subs.php'); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | 'recursive' => true, |
427 | 427 | ) |
428 | 428 | )->fetch_callback( |
429 | - function ($row) use (&$results, $scripturl) { |
|
429 | + function($row) use (&$results, $scripturl) { |
|
430 | 430 | $results[$row['id_member']] = array( |
431 | 431 | 'id' => $row['id_member'], |
432 | 432 | 'name' => $row['real_name'], |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'current_member' => User::$info->id, |
701 | 701 | ) |
702 | 702 | )->fetch_callback( |
703 | - function ($row) { |
|
703 | + function($row) { |
|
704 | 704 | return $row['id_group']; |
705 | 705 | } |
706 | 706 | ); |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | 'username' => $username, |
908 | 908 | ) |
909 | 909 | )->fetch_callback( |
910 | - function ($row) use (&$return) { |
|
910 | + function($row) use (&$return) { |
|
911 | 911 | $return = (int) $row['id_member']; |
912 | 912 | } |
913 | 913 | ); |
@@ -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 | } |
@@ -44,7 +44,8 @@ discard block |
||
44 | 44 | * - <https://262.ecma-international.org/7.0/> |
45 | 45 | * - <https://262.ecma-international.org/6.0/> |
46 | 46 | */ |
47 | -class JavaScriptMinifier { |
|
47 | +class JavaScriptMinifier |
|
48 | +{ |
|
48 | 49 | |
49 | 50 | /* Parsing states. |
50 | 51 | * The state machine is necessary to decide whether to parse a slash as division |
@@ -1203,9 +1204,11 @@ discard block |
||
1203 | 1204 | * Add copies of all states but with negative numbers to self::$model (if not already present), |
1204 | 1205 | * to represent generator function states. |
1205 | 1206 | */ |
1206 | - private static function ensureExpandedStates() { |
|
1207 | + private static function ensureExpandedStates() |
|
1208 | + { |
|
1207 | 1209 | // Already done? |
1208 | - if ( self::$expandedStates ) { |
|
1210 | + if ( self::$expandedStates ) |
|
1211 | + { |
|
1209 | 1212 | return; |
1210 | 1213 | } |
1211 | 1214 | self::$expandedStates = true; |
@@ -1213,17 +1216,25 @@ discard block |
||
1213 | 1216 | // Add copies of all states (except FUNC and GENFUNC) with negative numbers. |
1214 | 1217 | // These negative states represent states inside generator functions. When in these states, |
1215 | 1218 | // 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 ) { |
|
1219 | + foreach ( self::$model as $state => $transitions ) |
|
1220 | + { |
|
1221 | + if ( $state !== self::FUNC && $state !== self::GENFUNC ) |
|
1222 | + { |
|
1223 | + foreach ( $transitions as $tokenType => $actions ) |
|
1224 | + { |
|
1225 | + foreach ( $actions as $action => $target ) |
|
1226 | + { |
|
1227 | + if ( is_array( $target ) ) |
|
1228 | + { |
|
1229 | + foreach ( $target as $subaction => $subtarget ) |
|
1230 | + { |
|
1222 | 1231 | self::$model[-$state][$tokenType][$action][$subaction] = |
1223 | 1232 | $subtarget === self::FUNC || $subtarget === true || $subtarget === self::GENFUNC |
1224 | 1233 | ? $subtarget : -$subtarget; |
1225 | 1234 | } |
1226 | - } else { |
|
1235 | + } |
|
1236 | + else |
|
1237 | + { |
|
1227 | 1238 | self::$model[-$state][$tokenType][$action] = |
1228 | 1239 | $target === self::FUNC || $target === true || $target === self::GENFUNC |
1229 | 1240 | ? $target : -$target; |
@@ -1237,10 +1248,12 @@ discard block |
||
1237 | 1248 | self::$model[-self::PROPERTY_ASSIGNMENT][self::TYPE_BRACE_OPEN][self::ACTION_GOTO] = self::STATEMENT; |
1238 | 1249 | |
1239 | 1250 | // Also add negative versions of states to the other arrays |
1240 | - foreach ( self::$semicolon as $state => $value ) { |
|
1251 | + foreach ( self::$semicolon as $state => $value ) |
|
1252 | + { |
|
1241 | 1253 | self::$semicolon[-$state] = $value; |
1242 | 1254 | } |
1243 | - foreach ( self::$divStates as $state => $value ) { |
|
1255 | + foreach ( self::$divStates as $state => $value ) |
|
1256 | + { |
|
1244 | 1257 | self::$divStates[-$state] = $value; |
1245 | 1258 | } |
1246 | 1259 | } |
@@ -1251,7 +1264,8 @@ discard block |
||
1251 | 1264 | * @param string $s JavaScript code to minify |
1252 | 1265 | * @return string|bool Minified code or false on failure |
1253 | 1266 | */ |
1254 | - public static function minify( $s ) { |
|
1267 | + public static function minify( $s ) |
|
1268 | + { |
|
1255 | 1269 | return self::minifyInternal( $s ); |
1256 | 1270 | } |
1257 | 1271 | |
@@ -1266,7 +1280,8 @@ discard block |
||
1266 | 1280 | * |
1267 | 1281 | * @return JavaScriptMinifierState |
1268 | 1282 | */ |
1269 | - public static function createMinifier() { |
|
1283 | + public static function createMinifier() |
|
1284 | + { |
|
1270 | 1285 | return new JavaScriptMinifierState; |
1271 | 1286 | } |
1272 | 1287 | |
@@ -1284,7 +1299,8 @@ discard block |
||
1284 | 1299 | * |
1285 | 1300 | * @return JavaScriptMapperState |
1286 | 1301 | */ |
1287 | - public static function createSourceMapState() { |
|
1302 | + public static function createSourceMapState() |
|
1303 | + { |
|
1288 | 1304 | return new JavaScriptMapperState; |
1289 | 1305 | } |
1290 | 1306 | |
@@ -1297,7 +1313,8 @@ discard block |
||
1297 | 1313 | * @param MappingsGenerator|null $mapGenerator |
1298 | 1314 | * @return bool|string |
1299 | 1315 | */ |
1300 | - public static function minifyInternal( $s, $mapGenerator = null ) { |
|
1316 | + public static function minifyInternal( $s, $mapGenerator = null ) |
|
1317 | + { |
|
1301 | 1318 | self::ensureExpandedStates(); |
1302 | 1319 | |
1303 | 1320 | // Here's where the minifying takes place: Loop through the input, looking for tokens |
@@ -1313,25 +1330,31 @@ discard block |
||
1313 | 1330 | $stack = []; |
1314 | 1331 | $topOfStack = null; // Optimization: calling end( $stack ) repeatedly is expensive |
1315 | 1332 | $last = ';'; // Pretend that we have seen a semicolon yet |
1316 | - while ( $pos < $length ) { |
|
1333 | + while ( $pos < $length ) |
|
1334 | + { |
|
1317 | 1335 | // First, skip over any whitespace and multiline comments, recording whether we |
1318 | 1336 | // found any newline character |
1319 | 1337 | $skip = strspn( $s, " \t\n\r\xb\xc", $pos ); |
1320 | - if ( !$skip ) { |
|
1338 | + if ( !$skip ) |
|
1339 | + { |
|
1321 | 1340 | $ch = $s[$pos]; |
1322 | - if ( $ch === '/' && substr( $s, $pos, 2 ) === '/*' ) { |
|
1341 | + if ( $ch === '/' && substr( $s, $pos, 2 ) === '/*' ) |
|
1342 | + { |
|
1323 | 1343 | // Multiline comment. Search for the end token or EOT. |
1324 | 1344 | $end = strpos( $s, '*/', $pos + 2 ); |
1325 | 1345 | $skip = $end === false ? $length - $pos : $end - $pos + 2; |
1326 | 1346 | } |
1327 | 1347 | } |
1328 | - if ( $skip ) { |
|
1348 | + if ( $skip ) |
|
1349 | + { |
|
1329 | 1350 | // The semicolon insertion mechanism needs to know whether there was a newline |
1330 | 1351 | // between two tokens, so record it now. |
1331 | - if ( !$newlineFound && strcspn( $s, "\r\n", $pos, $skip ) !== $skip ) { |
|
1352 | + if ( !$newlineFound && strcspn( $s, "\r\n", $pos, $skip ) !== $skip ) |
|
1353 | + { |
|
1332 | 1354 | $newlineFound = true; |
1333 | 1355 | } |
1334 | - if ( $mapGenerator ) { |
|
1356 | + if ( $mapGenerator ) |
|
1357 | + { |
|
1335 | 1358 | $mapGenerator->consumeSource( $skip ); |
1336 | 1359 | } |
1337 | 1360 | $pos += $skip; |
@@ -1346,7 +1369,8 @@ discard block |
||
1346 | 1369 | || ( $ch === '-' && $newlineFound && substr( $s, $pos, 3 ) === '-->' ) |
1347 | 1370 | ) { |
1348 | 1371 | $skip = strcspn( $s, "\r\n", $pos ); |
1349 | - if ( $mapGenerator ) { |
|
1372 | + if ( $mapGenerator ) |
|
1373 | + { |
|
1350 | 1374 | $mapGenerator->consumeSource( $skip ); |
1351 | 1375 | } |
1352 | 1376 | $pos += $skip; |
@@ -1361,10 +1385,12 @@ discard block |
||
1361 | 1385 | // of any next token in the stream. |
1362 | 1386 | $end = $pos + 1; |
1363 | 1387 | // Handle string literals |
1364 | - if ( $ch === "'" || $ch === '"' ) { |
|
1388 | + if ( $ch === "'" || $ch === '"' ) |
|
1389 | + { |
|
1365 | 1390 | // Search to the end of the string literal, skipping over backslash escapes |
1366 | 1391 | $search = $ch . '\\'; |
1367 | - do { |
|
1392 | + do |
|
1393 | + { |
|
1368 | 1394 | // Speculatively add 2 to the end so that if we see a backslash, |
1369 | 1395 | // the next iteration will start 2 characters further (one for the |
1370 | 1396 | // backslash, one for the escaped character). |
@@ -1375,7 +1401,8 @@ discard block |
||
1375 | 1401 | } while ( $end - 2 < $length && $s[$end - 2] === '\\' ); |
1376 | 1402 | // Correction (1): Undo speculative add, keep only one (end of string literal) |
1377 | 1403 | $end--; |
1378 | - if ( $end > $length ) { |
|
1404 | + if ( $end > $length ) |
|
1405 | + { |
|
1379 | 1406 | // Correction (2): Loop wrongly assumed an end quote ended the search, |
1380 | 1407 | // but search ended because we've reached the end. Correct $end. |
1381 | 1408 | // TODO: This is invalid and should throw. |
@@ -1384,8 +1411,11 @@ discard block |
||
1384 | 1411 | |
1385 | 1412 | // Handle template strings, either from "`" to begin a new string, |
1386 | 1413 | // or continuation after the "}" that ends a "${"-expression. |
1387 | - } elseif ( $ch === '`' || ( $ch === '}' && $topOfStack === self::TEMPLATE_STRING_TAIL ) ) { |
|
1388 | - if ( $ch === '}' ) { |
|
1414 | + } |
|
1415 | + elseif ( $ch === '`' || ( $ch === '}' && $topOfStack === self::TEMPLATE_STRING_TAIL ) ) |
|
1416 | + { |
|
1417 | + if ( $ch === '}' ) |
|
1418 | + { |
|
1389 | 1419 | // Pop the TEMPLATE_STRING_TAIL state off the stack |
1390 | 1420 | // We don't let it get popped off the stack the normal way, to avoid the newline |
1391 | 1421 | // and comment stripping code above running on the continuation of the literal |
@@ -1396,21 +1426,25 @@ discard block |
||
1396 | 1426 | } |
1397 | 1427 | // Search until we reach either a closing ` or a ${, skipping over backslash escapes |
1398 | 1428 | // and $ characters followed by something other than { or ` |
1399 | - do { |
|
1429 | + do |
|
1430 | + { |
|
1400 | 1431 | $end += strcspn( $s, '`$\\', $end ) + 1; |
1401 | - if ( $end - 1 < $length && $s[$end - 1] === '`' ) { |
|
1432 | + if ( $end - 1 < $length && $s[$end - 1] === '`' ) |
|
1433 | + { |
|
1402 | 1434 | // End of the string, stop |
1403 | 1435 | // We don't do this in the while() condition because the $end++ in the |
1404 | 1436 | // backslash escape branch makes it difficult to do so without incorrectly |
1405 | 1437 | // considering an escaped backtick (\`) the end of the string |
1406 | 1438 | break; |
1407 | 1439 | } |
1408 | - if ( $end - 1 < $length && $s[$end - 1] === '\\' ) { |
|
1440 | + if ( $end - 1 < $length && $s[$end - 1] === '\\' ) |
|
1441 | + { |
|
1409 | 1442 | // Backslash escape. Skip the next character, and keep going |
1410 | 1443 | $end++; |
1411 | 1444 | continue; |
1412 | 1445 | } |
1413 | - if ( $end < $length && $s[$end - 1] === '$' && $s[$end] === '{' ) { |
|
1446 | + if ( $end < $length && $s[$end - 1] === '$' && $s[$end] === '{' ) |
|
1447 | + { |
|
1414 | 1448 | // Beginning of an expression in ${ ... }. Skip the {, and stop |
1415 | 1449 | $end++; |
1416 | 1450 | // Push the current state to the stack. We'll pop this off later when hitting |
@@ -1424,7 +1458,8 @@ discard block |
||
1424 | 1458 | break; |
1425 | 1459 | } |
1426 | 1460 | } while ( $end - 1 < $length ); |
1427 | - if ( $end > $length ) { |
|
1461 | + if ( $end > $length ) |
|
1462 | + { |
|
1428 | 1463 | // Loop wrongly assumed an end quote or ${ ended the search, |
1429 | 1464 | // but search ended because we've reached the end. Correct $end. |
1430 | 1465 | // TODO: This is invalid and should throw. |
@@ -1433,12 +1468,16 @@ discard block |
||
1433 | 1468 | |
1434 | 1469 | // We have to distinguish between regexp literals and division operators |
1435 | 1470 | // A division operator is only possible in certain states |
1436 | - } elseif ( $ch === '/' && !isset( self::$divStates[$state] ) ) { |
|
1471 | + } |
|
1472 | + elseif ( $ch === '/' && !isset( self::$divStates[$state] ) ) |
|
1473 | + { |
|
1437 | 1474 | // Regexp literal |
1438 | - for ( ; ; ) { |
|
1475 | + for ( ; ; ) |
|
1476 | + { |
|
1439 | 1477 | // Search until we find "/" (end of regexp), "\" (backslash escapes), |
1440 | 1478 | // or "[" (start of character classes). |
1441 | - do { |
|
1479 | + do |
|
1480 | + { |
|
1442 | 1481 | // Speculatively add 2 to ensure next iteration skips |
1443 | 1482 | // over backslash and escaped character. |
1444 | 1483 | // We'll correct this outside the loop. |
@@ -1447,19 +1486,22 @@ discard block |
||
1447 | 1486 | } while ( $end - 2 < $length && $s[$end - 2] === '\\' ); |
1448 | 1487 | // Correction (1): Undo speculative add, keep only one (end of regexp) |
1449 | 1488 | $end--; |
1450 | - if ( $end > $length ) { |
|
1489 | + if ( $end > $length ) |
|
1490 | + { |
|
1451 | 1491 | // Correction (2): Loop wrongly assumed end slash was seen |
1452 | 1492 | // String ended without end of regexp. Correct $end. |
1453 | 1493 | // TODO: This is invalid and should throw. |
1454 | 1494 | $end--; |
1455 | 1495 | break; |
1456 | 1496 | } |
1457 | - if ( $s[$end - 1] === '/' ) { |
|
1497 | + if ( $s[$end - 1] === '/' ) |
|
1498 | + { |
|
1458 | 1499 | break; |
1459 | 1500 | } |
1460 | 1501 | // (Implicit else), we must've found the start of a char class, |
1461 | 1502 | // skip until we find "]" (end of char class), or "\" (backslash escape) |
1462 | - do { |
|
1503 | + do |
|
1504 | + { |
|
1463 | 1505 | // Speculatively add 2 for backslash escape. |
1464 | 1506 | // We'll substract one outside the loop. |
1465 | 1507 | $end += strcspn( $s, ']\\', $end ) + 2; |
@@ -1467,7 +1509,8 @@ discard block |
||
1467 | 1509 | } while ( $end - 2 < $length && $s[$end - 2] === '\\' ); |
1468 | 1510 | // Correction (1): Undo speculative add, keep only one (end of regexp) |
1469 | 1511 | $end--; |
1470 | - if ( $end > $length ) { |
|
1512 | + if ( $end > $length ) |
|
1513 | + { |
|
1471 | 1514 | // Correction (2): Loop wrongly assumed "]" was seen |
1472 | 1515 | // String ended without ending char class or regexp. Correct $end. |
1473 | 1516 | // TODO: This is invalid and should throw. |
@@ -1476,17 +1519,20 @@ discard block |
||
1476 | 1519 | } |
1477 | 1520 | } |
1478 | 1521 | // Search past the regexp modifiers (gi) |
1479 | - while ( $end < $length && ctype_alpha( $s[$end] ) ) { |
|
1522 | + while ( $end < $length && ctype_alpha( $s[$end] ) ) |
|
1523 | + { |
|
1480 | 1524 | $end++; |
1481 | 1525 | } |
1482 | - } elseif ( |
|
1526 | + } |
|
1527 | + elseif ( |
|
1483 | 1528 | $ch === '0' |
1484 | 1529 | && ( $pos + 1 < $length ) && ( $s[$pos + 1] === 'x' || $s[$pos + 1] === 'X' ) |
1485 | 1530 | ) { |
1486 | 1531 | // Hex numeric literal |
1487 | 1532 | $end++; // x or X |
1488 | 1533 | $len = strspn( $s, '0123456789ABCDEFabcdef', $end ); |
1489 | - if ( !$len ) { |
|
1534 | + if ( !$len ) |
|
1535 | + { |
|
1490 | 1536 | return self::parseError( |
1491 | 1537 | $s, |
1492 | 1538 | $pos, |
@@ -1494,7 +1540,8 @@ discard block |
||
1494 | 1540 | ); |
1495 | 1541 | } |
1496 | 1542 | $end += $len; |
1497 | - } elseif ( |
|
1543 | + } |
|
1544 | + elseif ( |
|
1498 | 1545 | // Optimisation: This check must accept only ASCII digits 0-9. |
1499 | 1546 | // Avoid ctype_digit() because it is slower and also accepts locale-specific digits. |
1500 | 1547 | // Using is_numeric() might seem wrong also as it accepts negative numbers, decimal |
@@ -1506,17 +1553,23 @@ discard block |
||
1506 | 1553 | ) { |
1507 | 1554 | $end += strspn( $s, '0123456789', $end ); |
1508 | 1555 | $decimal = strspn( $s, '.', $end ); |
1509 | - if ( $decimal ) { |
|
1510 | - if ( $decimal > 2 ) { |
|
1556 | + if ( $decimal ) |
|
1557 | + { |
|
1558 | + if ( $decimal > 2 ) |
|
1559 | + { |
|
1511 | 1560 | return self::parseError( $s, $end, 'The number has too many decimal points' ); |
1512 | 1561 | } |
1513 | 1562 | $end += strspn( $s, '0123456789', $end + 1 ) + $decimal; |
1514 | - } else { |
|
1563 | + } |
|
1564 | + else |
|
1565 | + { |
|
1515 | 1566 | $dotlessNum = true; |
1516 | 1567 | } |
1517 | 1568 | $exponent = strspn( $s, 'eE', $end ); |
1518 | - if ( $exponent ) { |
|
1519 | - if ( $exponent > 1 ) { |
|
1569 | + if ( $exponent ) |
|
1570 | + { |
|
1571 | + if ( $exponent > 1 ) |
|
1572 | + { |
|
1520 | 1573 | return self::parseError( $s, $end, 'Number with several E' ); |
1521 | 1574 | } |
1522 | 1575 | $end++; |
@@ -1524,7 +1577,8 @@ discard block |
||
1524 | 1577 | // + sign is optional; - sign is required. |
1525 | 1578 | $end += strspn( $s, '-+', $end ); |
1526 | 1579 | $len = strspn( $s, '0123456789', $end ); |
1527 | - if ( !$len ) { |
|
1580 | + if ( !$len ) |
|
1581 | + { |
|
1528 | 1582 | return self::parseError( |
1529 | 1583 | $s, |
1530 | 1584 | $pos, |
@@ -1533,9 +1587,12 @@ discard block |
||
1533 | 1587 | } |
1534 | 1588 | $end += $len; |
1535 | 1589 | } |
1536 | - } elseif ( isset( self::$opChars[$ch] ) ) { |
|
1590 | + } |
|
1591 | + elseif ( isset( self::$opChars[$ch] ) ) |
|
1592 | + { |
|
1537 | 1593 | // Punctuation character. Search for the longest matching operator. |
1538 | - for ( $tokenLength = self::LONGEST_PUNCTUATION_TOKEN; $tokenLength > 1; $tokenLength-- ) { |
|
1594 | + for ( $tokenLength = self::LONGEST_PUNCTUATION_TOKEN; $tokenLength > 1; $tokenLength-- ) |
|
1595 | + { |
|
1539 | 1596 | if ( |
1540 | 1597 | $pos + $tokenLength <= $length && |
1541 | 1598 | isset( self::$tokenTypes[ substr( $s, $pos, $tokenLength ) ] ) |
@@ -1544,7 +1601,9 @@ discard block |
||
1544 | 1601 | break; |
1545 | 1602 | } |
1546 | 1603 | } |
1547 | - } else { |
|
1604 | + } |
|
1605 | + else |
|
1606 | + { |
|
1548 | 1607 | // Identifier or reserved word. Search for the end by excluding whitespace and |
1549 | 1608 | // punctuation. |
1550 | 1609 | $end += strcspn( $s, " \t\n.;,=<>+-{}()[]?:*/%'\"`!&|^~\xb\xc\r", $end ); |
@@ -1555,20 +1614,23 @@ discard block |
||
1555 | 1614 | $type = isset( self::$model[$state][self::TYPE_SPECIAL][$token] ) |
1556 | 1615 | ? self::TYPE_SPECIAL |
1557 | 1616 | : self::$tokenTypes[$token] ?? self::TYPE_LITERAL; |
1558 | - if ( $type === self::TYPE_YIELD ) { |
|
1617 | + if ( $type === self::TYPE_YIELD ) |
|
1618 | + { |
|
1559 | 1619 | // yield is treated as TYPE_RETURN inside a generator function (negative state) |
1560 | 1620 | // but as TYPE_LITERAL when not in a generator function (positive state) |
1561 | 1621 | $type = $state < 0 ? self::TYPE_RETURN : self::TYPE_LITERAL; |
1562 | 1622 | } |
1563 | 1623 | |
1564 | 1624 | $pad = ''; |
1565 | - if ( $newlineFound && isset( self::$semicolon[$state][$type] ) ) { |
|
1625 | + if ( $newlineFound && isset( self::$semicolon[$state][$type] ) ) |
|
1626 | + { |
|
1566 | 1627 | // This token triggers the semicolon insertion mechanism of javascript. While we |
1567 | 1628 | // could add the ; token here ourselves, keeping the newline has a few advantages. |
1568 | 1629 | $pad = "\n"; |
1569 | 1630 | $state = $state < 0 ? -self::STATEMENT : self::STATEMENT; |
1570 | 1631 | $lineLength = 0; |
1571 | - } elseif ( $lineLength + $end - $pos > self::$maxLineLength && |
|
1632 | + } |
|
1633 | + elseif ( $lineLength + $end - $pos > self::$maxLineLength && |
|
1572 | 1634 | !isset( self::$semicolon[$state][$type] ) && |
1573 | 1635 | $type !== self::TYPE_INCR_OP && |
1574 | 1636 | $type !== self::TYPE_ARROW |
@@ -1580,24 +1642,31 @@ discard block |
||
1580 | 1642 | $pad = "\n"; |
1581 | 1643 | $lineLength = 0; |
1582 | 1644 | // Check, whether we have to separate the token from the last one with whitespace |
1583 | - } elseif ( !isset( self::$opChars[$last] ) && !isset( self::$opChars[$ch] ) ) { |
|
1645 | + } |
|
1646 | + elseif ( !isset( self::$opChars[$last] ) && !isset( self::$opChars[$ch] ) ) |
|
1647 | + { |
|
1584 | 1648 | $pad = ' '; |
1585 | 1649 | $lineLength++; |
1586 | 1650 | // Don't accidentally create ++, -- or // tokens |
1587 | - } elseif ( $last === $ch && ( $ch === '+' || $ch === '-' || $ch === '/' ) ) { |
|
1651 | + } |
|
1652 | + elseif ( $last === $ch && ( $ch === '+' || $ch === '-' || $ch === '/' ) ) |
|
1653 | + { |
|
1588 | 1654 | $pad = ' '; |
1589 | 1655 | $lineLength++; |
1590 | 1656 | // Don't create invalid dot notation after number literal (T303827). |
1591 | 1657 | // Keep whitespace in "42. foo". |
1592 | 1658 | // But keep minifying "foo.bar", "42..foo", and "42.0.foo" per $opChars. |
1593 | - } elseif ( $lastDotlessNum && $type === self::TYPE_DOT ) { |
|
1659 | + } |
|
1660 | + elseif ( $lastDotlessNum && $type === self::TYPE_DOT ) |
|
1661 | + { |
|
1594 | 1662 | $pad = ' '; |
1595 | 1663 | $lineLength++; |
1596 | 1664 | } |
1597 | 1665 | |
1598 | 1666 | // self::debug( $topOfStack, $last, $lastType, $state, $ch, $token, $type, ); |
1599 | 1667 | |
1600 | - if ( $mapGenerator ) { |
|
1668 | + if ( $mapGenerator ) |
|
1669 | + { |
|
1601 | 1670 | $mapGenerator->outputSpace( $pad ); |
1602 | 1671 | $mapGenerator->outputToken( $token ); |
1603 | 1672 | $mapGenerator->consumeSource( $end - $pos ); |
@@ -1621,10 +1690,13 @@ discard block |
||
1621 | 1690 | $topOfStack = $actions[self::ACTION_PUSH]; |
1622 | 1691 | $stack[] = $topOfStack; |
1623 | 1692 | } |
1624 | - if ( $stack && isset( $actions[self::ACTION_POP] ) ) { |
|
1693 | + if ( $stack && isset( $actions[self::ACTION_POP] ) ) |
|
1694 | + { |
|
1625 | 1695 | $state = array_pop( $stack ); |
1626 | 1696 | $topOfStack = end( $stack ); |
1627 | - } elseif ( isset( $actions[self::ACTION_GOTO] ) ) { |
|
1697 | + } |
|
1698 | + elseif ( isset( $actions[self::ACTION_GOTO] ) ) |
|
1699 | + { |
|
1628 | 1700 | $state = $actions[self::ACTION_GOTO]; |
1629 | 1701 | } |
1630 | 1702 | } |
@@ -1637,7 +1709,8 @@ discard block |
||
1637 | 1709 | * @param string $errorMsg |
1638 | 1710 | * @return bool |
1639 | 1711 | */ |
1640 | - public static function parseError( $fullJavascript, $position, $errorMsg ) { |
|
1712 | + public static function parseError( $fullJavascript, $position, $errorMsg ) |
|
1713 | + { |
|
1641 | 1714 | // TODO: Handle the error: trigger_error, throw exception, return false... |
1642 | 1715 | return false; |
1643 | 1716 | } |
@@ -1659,22 +1732,28 @@ discard block |
||
1659 | 1732 | $self = new \ReflectionClass( self::class ); |
1660 | 1733 | $constants = $self->getConstants(); |
1661 | 1734 | |
1662 | - foreach ( $self->getConstants() as $name => $value ) { |
|
1663 | - if ( $value === $top ) { |
|
1735 | + foreach ( $self->getConstants() as $name => $value ) |
|
1736 | + { |
|
1737 | + if ( $value === $top ) |
|
1738 | + { |
|
1664 | 1739 | $top = $name; |
1665 | 1740 | } |
1666 | - if ( $value === $lastType ) { |
|
1741 | + if ( $value === $lastType ) |
|
1742 | + { |
|
1667 | 1743 | $lastType = $name; |
1668 | 1744 | } |
1669 | - if ( $value === $state ) { |
|
1745 | + if ( $value === $state ) |
|
1746 | + { |
|
1670 | 1747 | $state = $name; |
1671 | 1748 | } |
1672 | - if ( $value === $type ) { |
|
1749 | + if ( $value === $type ) |
|
1750 | + { |
|
1673 | 1751 | $type = $name; |
1674 | 1752 | } |
1675 | 1753 | } |
1676 | 1754 | |
1677 | - if ( $first ) { |
|
1755 | + if ( $first ) |
|
1756 | + { |
|
1678 | 1757 | print sprintf( "| %-29s | %-4s | %-29s | %-29s | %-2s | %-10s | %-29s\n", |
1679 | 1758 | 'topOfStack', 'last', 'lastType', 'state', 'ch', 'token', 'type' ); |
1680 | 1759 | print sprintf( "| %'-29s | %'-4s | %'-29s | %'-29s | %'-2s | %'-10s | %'-29s\n", |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | 'limit_posts' => $limit, |
155 | 155 | ] |
156 | 156 | )->fetch_callback( |
157 | - function ($row) use (&$top_posters, &$max_num_posts) { |
|
157 | + function($row) use (&$top_posters, &$max_num_posts) { |
|
158 | 158 | $href = getUrl('profile', ['action' => 'profile', 'u' => $row['id_member'], 'name' => $row['real_name']]); |
159 | 159 | |
160 | 160 | // Build general member information for each top poster |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | 'current_member' => User::$info->id, |
230 | 230 | ] |
231 | 231 | )->fetch_callback( |
232 | - function ($row) use (&$top_boards, &$max_num_posts, $read_status) { |
|
232 | + function($row) use (&$top_boards, &$max_num_posts, $read_status) { |
|
233 | 233 | $href = getUrl('board', ['board' => $row['id_board'], 'start' => '0', 'name' => $row['name']]); |
234 | 234 | |
235 | 235 | // Load the boards info, number of posts, topics etc |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | 'recycle_board' => $modSettings['recycle_board'], |
300 | 300 | ] |
301 | 301 | )->fetch_callback( |
302 | - function ($row) use (&$topic_ids) { |
|
302 | + function($row) use (&$topic_ids) { |
|
303 | 303 | $topic_ids[$row['id_topic']] = $row['num_replies']; |
304 | 304 | } |
305 | 305 | ); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | 'topic_list' => array_keys($topic_ids), |
322 | 322 | ] |
323 | 323 | )->fetch_callback( |
324 | - function ($row) use (&$top_topics_replies, &$max_num_replies) { |
|
324 | + function($row) use (&$top_topics_replies, &$max_num_replies) { |
|
325 | 325 | $href = getUrl('topic', ['topic' => $row['id_topic'], 'start' => '0', 'subject' => $row['subject']]); |
326 | 326 | |
327 | 327 | // Build out this topics details for controller use |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | ); |
340 | 340 | |
341 | 341 | // @todo dedupe this |
342 | - usort($top_topics_replies, static function ($a, $b) { |
|
342 | + usort($top_topics_replies, static function($a, $b) { |
|
343 | 343 | return $b['num_replies'] <=> $a['num_replies']; |
344 | 344 | }); |
345 | 345 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | 'no_views' => 0, |
387 | 387 | ] |
388 | 388 | )->fetch_callback( |
389 | - function ($row) use (&$topic_ids) { |
|
389 | + function($row) use (&$topic_ids) { |
|
390 | 390 | $topic_ids[] = $row['id_topic']; |
391 | 391 | } |
392 | 392 | ); |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | 'topic_views' => $limit, |
414 | 414 | ] |
415 | 415 | )->fetch_callback( |
416 | - function ($row) use (&$top_topics_views, &$max_num_views) { |
|
416 | + function($row) use (&$top_topics_views, &$max_num_views) { |
|
417 | 417 | $board_href = getUrl('board', ['board' => $row['id_board'], 'start' => '0', 'name' => $row['name']]); |
418 | 418 | $topic_href = getUrl('topic', ['topic' => $row['id_topic'], 'start' => '0', 'subject' => $row['subject']]); |
419 | 419 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | 'recycle_board' => $modSettings['recycle_board'], |
481 | 481 | ] |
482 | 482 | )->fetch_callback( |
483 | - function ($row) use (&$members) { |
|
483 | + function($row) use (&$members) { |
|
484 | 484 | if ($row['id_member_started'] !== '0') |
485 | 485 | { |
486 | 486 | $members[(int) $row['id_member_started']] = (int) $row['hits']; |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | 'member_list' => array_keys($members), |
511 | 511 | ] |
512 | 512 | )->fetch_callback( |
513 | - function ($row) use (&$top_starters, $members, $max_num_topics) { |
|
513 | + function($row) use (&$top_starters, $members, $max_num_topics) { |
|
514 | 514 | $href = getUrl('profile', ['action' => 'profile', 'u' => $row['id_member'], 'name' => $row['real_name']]); |
515 | 515 | |
516 | 516 | // Our array of spammers, er topic starters ! |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | ); |
528 | 528 | |
529 | 529 | // Even spammers must be orderly. |
530 | - uksort($top_starters, static function ($a, $b) use ($members) { |
|
530 | + uksort($top_starters, static function($a, $b) use ($members) { |
|
531 | 531 | return $members[$b] <=> $members[$a]; |
532 | 532 | }); |
533 | 533 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | ORDER BY stats_day DESC', |
724 | 724 | $condition_parameters |
725 | 725 | )->fetch_callback( |
726 | - function ($row) { |
|
726 | + function($row) { |
|
727 | 727 | global $context; |
728 | 728 | |
729 | 729 | $context['yearly'][$row['stats_year']]['months'][(int) $row['stats_month']]['days'][] = [ |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | 'limit' => (int) $limit, |
872 | 872 | ] |
873 | 873 | )->fetch_callback( |
874 | - function ($row) use (&$popular_boards, $memID) { |
|
874 | + function($row) use (&$popular_boards, $memID) { |
|
875 | 875 | $href = getUrl('board', ['board' => $row['id_board'], 'start' => '0', 'name' => $row['name']]); |
876 | 876 | $posts = (int) MembersList::get($memID)->posts; |
877 | 877 |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'id_messages' => $messages, |
87 | 87 | ] |
88 | 88 | )->fetch_callback( |
89 | - function ($row) use (&$likes) { |
|
89 | + function($row) use (&$likes) { |
|
90 | 90 | $likes[$row['id_msg']]['member'][$row['id_member']] = $row['real_name']; |
91 | 91 | } |
92 | 92 | ); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | { |
257 | 257 | $db->insert('', |
258 | 258 | '{db_prefix}message_likes', |
259 | - ['id_member' => 'int', 'id_msg' => 'int', 'id_poster' => 'int', 'like_timestamp' => 'int',], |
|
259 | + ['id_member' => 'int', 'id_msg' => 'int', 'id_poster' => 'int', 'like_timestamp' => 'int', ], |
|
260 | 260 | [$id_liker, $liked_message['id_msg'], $liked_message['id_member'], time()], |
261 | 261 | ['id_msg', 'id_member', 'id_poster'] |
262 | 262 | ); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | 'per_page' => $items_per_page, |
407 | 407 | ] |
408 | 408 | )->fetch_callback( |
409 | - function ($row) use ($scripturl, $context) { |
|
409 | + function($row) use ($scripturl, $context) { |
|
410 | 410 | return [ |
411 | 411 | 'subject' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>', |
412 | 412 | 'poster_name' => $row['poster_name'], |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | 'per_page' => $items_per_page, |
459 | 459 | ] |
460 | 460 | )->fetch_callback( |
461 | - function ($row) use ($scripturl) { |
|
461 | + function($row) use ($scripturl) { |
|
462 | 462 | return [ |
463 | 463 | 'subject' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>', |
464 | 464 | 'name' => $row['name'], |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | 'per_page' => $items_per_page, |
515 | 515 | ] |
516 | 516 | )->fetch_callback( |
517 | - function ($row) use ($scripturl, $simple) { |
|
517 | + function($row) use ($scripturl, $simple) { |
|
518 | 518 | $like = [ |
519 | 519 | 'real_name' => $row['real_name'], |
520 | 520 | 'id_member' => $row['id_member'], |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | 'limit' => $limit, |
610 | 610 | ] |
611 | 611 | )->fetch_callback( |
612 | - function ($row) use (&$mostLikedMessages, $bbc_parser) { |
|
612 | + function($row) use (&$mostLikedMessages, $bbc_parser) { |
|
613 | 613 | global $scripturl; |
614 | 614 | |
615 | 615 | // Censor it! |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | 'type_avatar' => 1, |
710 | 710 | ] |
711 | 711 | )->fetch_callback( |
712 | - function ($row) use ($scripturl, $bbc_parser) { |
|
712 | + function($row) use ($scripturl, $bbc_parser) { |
|
713 | 713 | // Censor those naughty words |
714 | 714 | $row['body'] = censor($row['body']); |
715 | 715 | $row['subject'] = censor($row['subject']); |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | 'limit' => $limit * 10, |
791 | 791 | ] |
792 | 792 | )->fetch_callback( |
793 | - function ($row) use (&$mostLikedTopics) { |
|
793 | + function($row) use (&$mostLikedTopics) { |
|
794 | 794 | $row['num_replies'] = (int) $row['num_replies']; |
795 | 795 | $row['like_count'] = (int) $row['like_count']; |
796 | 796 | $row['distinct_likers'] = (int) $row['distinct_likers']; |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | 'limit' => $limit |
937 | 937 | ] |
938 | 938 | )->fetch_callback( |
939 | - function ($row) use (&$mostLikedMembers) { |
|
939 | + function($row) use (&$mostLikedMembers) { |
|
940 | 940 | global $scripturl; |
941 | 941 | |
942 | 942 | $avatar = determineAvatar($row); |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | 'limit' => $limit |
997 | 997 | ] |
998 | 998 | )->fetch_callback( |
999 | - function ($row) use ($bbc_parser) { |
|
999 | + function($row) use ($bbc_parser) { |
|
1000 | 1000 | // Censor those naughty words |
1001 | 1001 | $row['body'] = censor($row['body']); |
1002 | 1002 | $row['subject'] = censor($row['subject']); |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | 'limit' => $limit |
1061 | 1061 | ] |
1062 | 1062 | )->fetch_callback( |
1063 | - function ($row) use (&$mostLikeGivingMembers) { |
|
1063 | + function($row) use (&$mostLikeGivingMembers) { |
|
1064 | 1064 | global $scripturl; |
1065 | 1065 | |
1066 | 1066 | $avatar = determineAvatar($row); |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | 'limit' => $limit |
1119 | 1119 | ] |
1120 | 1120 | )->fetch_callback( |
1121 | - function ($row) use ($bbc_parser) { |
|
1121 | + function($row) use ($bbc_parser) { |
|
1122 | 1122 | // Censor those $%#^&% words |
1123 | 1123 | $row['body'] = censor($row['body']); |
1124 | 1124 | $row['subject'] = censor($row['subject']); |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | 'messages' => $messages, |
1181 | 1181 | ] |
1182 | 1182 | )->fetch_callback( |
1183 | - function ($row) use (&$posters, &$likers) { |
|
1183 | + function($row) use (&$posters, &$likers) { |
|
1184 | 1184 | // Track how many likes each member gave and how many were received |
1185 | 1185 | $posters[$row['id_poster']] = isset($posters[$row['id_poster']]) ? $posters[$row['id_poster']]++ : 1; |
1186 | 1186 | $likers[$row['id_member']] = isset($likers[$row['id_member']]) ? $likers[$row['id_member']]++ : 1; |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | 'members' => array_keys($likers), |
1207 | 1207 | ] |
1208 | 1208 | )->fetch_callback( |
1209 | - function ($row) use (&$update_given, $likers) { |
|
1209 | + function($row) use (&$update_given, $likers) { |
|
1210 | 1210 | // All who liked these messages have their "likes given" reduced |
1211 | 1211 | $update_given[$row['id_member']] = $row['likes'] - $likers[$row['id_member']]; |
1212 | 1212 | } |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | 'members' => array_keys($posters), |
1227 | 1227 | ] |
1228 | 1228 | )->fetch_callback( |
1229 | - function ($row) use (&$update_received, $posters) { |
|
1229 | + function($row) use (&$update_received, $posters) { |
|
1230 | 1230 | // The message posters have their "likes received" reduced |
1231 | 1231 | $update_received[$row['id_poster']] = $row['likes'] - $posters[$row['id_poster']]; |
1232 | 1232 | } |