@@ -2,6 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | 4 | if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
| 5 | +{ |
|
| 5 | 6 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 7 | - exit; |
|
| 8 | 7 | \ No newline at end of file |
| 8 | +} |
|
| 9 | +else { |
|
| 10 | + exit; |
|
| 11 | +} |
|
@@ -2,6 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | 4 | if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
| 5 | +{ |
|
| 5 | 6 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 7 | - exit; |
|
| 8 | 7 | \ No newline at end of file |
| 8 | +} |
|
| 9 | +else { |
|
| 10 | + exit; |
|
| 11 | +} |
|
@@ -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 | } |
@@ -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", |
@@ -2502,7 +2502,8 @@ |
||
| 2502 | 2502 | * |
| 2503 | 2503 | * @return bool Returns true if the email address is unique, false otherwise |
| 2504 | 2504 | */ |
| 2505 | -function isUniqueEmail($memID, $email) { |
|
| 2505 | +function isUniqueEmail($memID, $email) |
|
| 2506 | +{ |
|
| 2506 | 2507 | $db = database(); |
| 2507 | 2508 | |
| 2508 | 2509 | // Email addresses should be and stay unique. |
@@ -1323,10 +1323,13 @@ |
||
| 1323 | 1323 | $fn_total += $this->fn_num; |
| 1324 | 1324 | |
| 1325 | 1325 | // If we have footnotes, add them in at the end of the message |
| 1326 | - if ($this->fn_num !== 0) // Set in callback |
|
| 1326 | + if ($this->fn_num !== 0) |
|
| 1327 | + { |
|
| 1328 | + // Set in callback |
|
| 1327 | 1329 | { |
| 1328 | 1330 | $this->message .= $this->smiley_marker . '<div class="bbc_footnotes">' . implode('', $this->fn_content) . '</div>' . $this->smiley_marker; |
| 1329 | 1331 | } |
| 1332 | + } |
|
| 1330 | 1333 | } |
| 1331 | 1334 | |
| 1332 | 1335 | /** |
@@ -211,7 +211,8 @@ discard block |
||
| 211 | 211 | global $txt; |
| 212 | 212 | |
| 213 | 213 | // An error if not possible to like. |
| 214 | - if (!$this->_doLikePost('+', 'likemsg') && empty($this->_likes_response)) { |
|
| 214 | + if (!$this->_doLikePost('+', 'likemsg') && empty($this->_likes_response)) |
|
| 215 | + { |
|
| 215 | 216 | Txt::load('Errors'); |
| 216 | 217 | $this->_likes_response = array('result' => false, 'data' => $txt['like_unlike_error']); |
| 217 | 218 | } |
@@ -262,7 +263,8 @@ discard block |
||
| 262 | 263 | global $txt; |
| 263 | 264 | |
| 264 | 265 | // An error if not possible to like. |
| 265 | - if (!$this->_doLikePost('-', 'rlikemsg') && empty($this->_likes_response)) { |
|
| 266 | + if (!$this->_doLikePost('-', 'rlikemsg') && empty($this->_likes_response)) |
|
| 267 | + { |
|
| 266 | 268 | Txt::load('Errors'); |
| 267 | 269 | $this->_likes_response = array('result' => false, 'data' => $txt['like_unlike_error']); |
| 268 | 270 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'function' => static function ($rowData) use ($base_type, $base_params) { |
| 147 | 147 | // Since the moderator group has no explicit members, no link is needed. |
| 148 | 148 | if ($rowData['id_group'] == 3) |
| 149 | - { |
|
| 149 | + { |
|
| 150 | 150 | $group_name = $rowData['group_name']; |
| 151 | 151 | } |
| 152 | 152 | else |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | // Add a help option for moderator and administrator. |
| 158 | 158 | if ($rowData['id_group'] == 1) |
| 159 | - { |
|
| 159 | + { |
|
| 160 | 160 | $group_name .= ' (<a href="' . getUrl('action', ['action' => 'quickhelp', 'help' => 'membergroup_administrator']) . '" onclick="return reqOverlayDiv(this.href);" class="helpicon i-help"></a>)'; |
| 161 | 161 | } |
| 162 | 162 | elseif ($rowData['id_group'] == 3) |
@@ -178,10 +178,12 @@ discard block |
||
| 178 | 178 | 'data' => array( |
| 179 | 179 | 'function' => static function ($rowData) { |
| 180 | 180 | global $settings; |
| 181 | - if (empty($rowData['icons'][0])) { |
|
| 181 | + if (empty($rowData['icons'][0])) |
|
| 182 | + { |
|
| 182 | 183 | return ''; |
| 183 | 184 | } |
| 184 | - if (empty($rowData['icons'][1])) { |
|
| 185 | + if (empty($rowData['icons'][1])) |
|
| 186 | + { |
|
| 185 | 187 | return ''; |
| 186 | 188 | } |
| 187 | 189 | return str_repeat('<img src="' . $settings['images_url'] . '/group_icons/' . $rowData['icons'][1] . '" alt="*" />', $rowData['icons'][0]); |
@@ -293,10 +295,12 @@ discard block |
||
| 293 | 295 | 'id' => $id_member, |
| 294 | 296 | 'name' => $name |
| 295 | 297 | ); |
| 296 | - if ($this->user->id != $id_member) { |
|
| 298 | + if ($this->user->id != $id_member) |
|
| 299 | + { |
|
| 297 | 300 | continue; |
| 298 | 301 | } |
| 299 | - if ($context['group']['group_type'] == 1) { |
|
| 302 | + if ($context['group']['group_type'] == 1) |
|
| 303 | + { |
|
| 300 | 304 | continue; |
| 301 | 305 | } |
| 302 | 306 | $context['group']['can_moderate'] = true; |
@@ -112,7 +112,8 @@ |
||
| 112 | 112 | |
| 113 | 113 | // Delete any older items from the log so we can get the go ahead or not |
| 114 | 114 | clearKarma($modSettings['karmaWaitTime']); |
| 115 | - if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum')) { |
|
| 115 | + if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum')) |
|
| 116 | + { |
|
| 116 | 117 | return lastActionOn($this->user->id, $id_target); |
| 117 | 118 | } |
| 118 | 119 | |