Completed
Pull Request — master (#10)
by Tomáš
13:19 queued 08:24
created
src/Sniffs/AbstractPatternSniff.php 1 patch
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -890,26 +890,26 @@
 block discarded – undo
890 890
         $nestedBraces      = 0;
891 891
         for ($start = $from; $start >= 0; $start--) {
892 892
             switch ($pattern[$start]) {
893
-            case '(':
894
-                if ($nestedParenthesis === 0) {
895
-                    $skip['to'] = 'parenthesis_closer';
896
-                }
893
+                case '(':
894
+                    if ($nestedParenthesis === 0) {
895
+                        $skip['to'] = 'parenthesis_closer';
896
+                    }
897 897
 
898
-                $nestedParenthesis--;
899
-                break;
900
-            case '{':
901
-                if ($nestedBraces === 0) {
902
-                    $skip['to'] = 'scope_closer';
903
-                }
898
+                    $nestedParenthesis--;
899
+                    break;
900
+                case '{':
901
+                    if ($nestedBraces === 0) {
902
+                        $skip['to'] = 'scope_closer';
903
+                    }
904 904
 
905
-                $nestedBraces--;
906
-                break;
907
-            case '}':
908
-                $nestedBraces++;
909
-                break;
910
-            case ')':
911
-                $nestedParenthesis++;
912
-                break;
905
+                    $nestedBraces--;
906
+                    break;
907
+                case '}':
908
+                    $nestedBraces++;
909
+                    break;
910
+                case ')':
911
+                    $nestedParenthesis++;
912
+                    break;
913 913
             }//end switch
914 914
 
915 915
             if (isset($skip['to']) === true) {
Please login to merge, or discard this patch.
src/Files/File.php 1 patch
Switch Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -1209,88 +1209,88 @@  discard block
 block discarded – undo
1209 1209
             }
1210 1210
 
1211 1211
             switch ($this->tokens[$i]['code']) {
1212
-            case T_BITWISE_AND:
1213
-                $passByReference = true;
1214
-                break;
1215
-            case T_VARIABLE:
1216
-                $currVar = $i;
1217
-                break;
1218
-            case T_ELLIPSIS:
1219
-                $variableLength = true;
1220
-                break;
1221
-            case T_ARRAY_HINT:
1222
-            case T_CALLABLE:
1223
-                $typeHint = $this->tokens[$i]['content'];
1224
-                break;
1225
-            case T_STRING:
1226
-                // This is a string, so it may be a type hint, but it could
1227
-                // also be a constant used as a default value.
1228
-                $prevComma = false;
1229
-                for ($t = $i; $t >= $opener; $t--) {
1230
-                    if ($this->tokens[$t]['code'] === T_COMMA) {
1231
-                        $prevComma = $t;
1232
-                        break;
1212
+                case T_BITWISE_AND:
1213
+                    $passByReference = true;
1214
+                    break;
1215
+                case T_VARIABLE:
1216
+                    $currVar = $i;
1217
+                    break;
1218
+                case T_ELLIPSIS:
1219
+                    $variableLength = true;
1220
+                    break;
1221
+                case T_ARRAY_HINT:
1222
+                case T_CALLABLE:
1223
+                    $typeHint = $this->tokens[$i]['content'];
1224
+                    break;
1225
+                case T_STRING:
1226
+                    // This is a string, so it may be a type hint, but it could
1227
+                    // also be a constant used as a default value.
1228
+                    $prevComma = false;
1229
+                    for ($t = $i; $t >= $opener; $t--) {
1230
+                        if ($this->tokens[$t]['code'] === T_COMMA) {
1231
+                            $prevComma = $t;
1232
+                            break;
1233
+                        }
1233 1234
                     }
1234
-                }
1235 1235
 
1236
-                if ($prevComma !== false) {
1237
-                    $nextEquals = false;
1238
-                    for ($t = $prevComma; $t < $i; $t++) {
1239
-                        if ($this->tokens[$t]['code'] === T_EQUAL) {
1240
-                            $nextEquals = $t;
1236
+                    if ($prevComma !== false) {
1237
+                        $nextEquals = false;
1238
+                        for ($t = $prevComma; $t < $i; $t++) {
1239
+                            if ($this->tokens[$t]['code'] === T_EQUAL) {
1240
+                                $nextEquals = $t;
1241
+                                break;
1242
+                            }
1243
+                        }
1244
+
1245
+                        if ($nextEquals !== false) {
1241 1246
                             break;
1242 1247
                         }
1243 1248
                     }
1244 1249
 
1245
-                    if ($nextEquals !== false) {
1246
-                        break;
1250
+                    if ($defaultStart === null) {
1251
+                        $typeHint .= $this->tokens[$i]['content'];
1252
+                    }
1253
+                    break;
1254
+                case T_NS_SEPARATOR:
1255
+                    // Part of a type hint or default value.
1256
+                    if ($defaultStart === null) {
1257
+                        $typeHint .= $this->tokens[$i]['content'];
1258
+                    }
1259
+                    break;
1260
+                case T_CLOSE_PARENTHESIS:
1261
+                case T_COMMA:
1262
+                    // If it's null, then there must be no parameters for this
1263
+                    // method.
1264
+                    if ($currVar === null) {
1265
+                        continue;
1247 1266
                     }
1248
-                }
1249
-
1250
-                if ($defaultStart === null) {
1251
-                    $typeHint .= $this->tokens[$i]['content'];
1252
-                }
1253
-                break;
1254
-            case T_NS_SEPARATOR:
1255
-                // Part of a type hint or default value.
1256
-                if ($defaultStart === null) {
1257
-                    $typeHint .= $this->tokens[$i]['content'];
1258
-                }
1259
-                break;
1260
-            case T_CLOSE_PARENTHESIS:
1261
-            case T_COMMA:
1262
-                // If it's null, then there must be no parameters for this
1263
-                // method.
1264
-                if ($currVar === null) {
1265
-                    continue;
1266
-                }
1267 1267
 
1268
-                $vars[$paramCount]         = array();
1269
-                $vars[$paramCount]['name'] = $this->tokens[$currVar]['content'];
1268
+                    $vars[$paramCount]         = array();
1269
+                    $vars[$paramCount]['name'] = $this->tokens[$currVar]['content'];
1270 1270
 
1271
-                if ($defaultStart !== null) {
1272
-                    $vars[$paramCount]['default']
1273
-                        = $this->getTokensAsString(
1274
-                            $defaultStart,
1275
-                            ($i - $defaultStart)
1276
-                        );
1277
-                }
1271
+                    if ($defaultStart !== null) {
1272
+                        $vars[$paramCount]['default']
1273
+                            = $this->getTokensAsString(
1274
+                                $defaultStart,
1275
+                                ($i - $defaultStart)
1276
+                            );
1277
+                    }
1278 1278
 
1279
-                $vars[$paramCount]['pass_by_reference'] = $passByReference;
1280
-                $vars[$paramCount]['variable_length']   = $variableLength;
1281
-                $vars[$paramCount]['type_hint']         = $typeHint;
1279
+                    $vars[$paramCount]['pass_by_reference'] = $passByReference;
1280
+                    $vars[$paramCount]['variable_length']   = $variableLength;
1281
+                    $vars[$paramCount]['type_hint']         = $typeHint;
1282 1282
 
1283
-                // Reset the vars, as we are about to process the next parameter.
1284
-                $defaultStart    = null;
1285
-                $passByReference = false;
1286
-                $variableLength  = false;
1287
-                $typeHint        = '';
1283
+                    // Reset the vars, as we are about to process the next parameter.
1284
+                    $defaultStart    = null;
1285
+                    $passByReference = false;
1286
+                    $variableLength  = false;
1287
+                    $typeHint        = '';
1288 1288
 
1289
-                $paramCount++;
1290
-                break;
1291
-            case T_EQUAL:
1292
-                $defaultStart = ($i + 1);
1293
-                break;
1289
+                    $paramCount++;
1290
+                    break;
1291
+                case T_EQUAL:
1292
+                    $defaultStart = ($i + 1);
1293
+                    break;
1294 1294
             }//end switch
1295 1295
         }//end for
1296 1296
 
@@ -1352,27 +1352,27 @@  discard block
 block discarded – undo
1352 1352
             }
1353 1353
 
1354 1354
             switch ($this->tokens[$i]['code']) {
1355
-            case T_PUBLIC:
1356
-                $scope          = 'public';
1357
-                $scopeSpecified = true;
1358
-                break;
1359
-            case T_PRIVATE:
1360
-                $scope          = 'private';
1361
-                $scopeSpecified = true;
1362
-                break;
1363
-            case T_PROTECTED:
1364
-                $scope          = 'protected';
1365
-                $scopeSpecified = true;
1366
-                break;
1367
-            case T_ABSTRACT:
1368
-                $isAbstract = true;
1369
-                break;
1370
-            case T_FINAL:
1371
-                $isFinal = true;
1372
-                break;
1373
-            case T_STATIC:
1374
-                $isStatic = true;
1375
-                break;
1355
+                case T_PUBLIC:
1356
+                    $scope          = 'public';
1357
+                    $scopeSpecified = true;
1358
+                    break;
1359
+                case T_PRIVATE:
1360
+                    $scope          = 'private';
1361
+                    $scopeSpecified = true;
1362
+                    break;
1363
+                case T_PROTECTED:
1364
+                    $scope          = 'protected';
1365
+                    $scopeSpecified = true;
1366
+                    break;
1367
+                case T_ABSTRACT:
1368
+                    $isAbstract = true;
1369
+                    break;
1370
+                case T_FINAL:
1371
+                    $isFinal = true;
1372
+                    break;
1373
+                case T_STATIC:
1374
+                    $isStatic = true;
1375
+                    break;
1376 1376
             }//end switch
1377 1377
         }//end for
1378 1378
 
@@ -1462,21 +1462,21 @@  discard block
 block discarded – undo
1462 1462
             }
1463 1463
 
1464 1464
             switch ($this->tokens[$i]['code']) {
1465
-            case T_PUBLIC:
1466
-                $scope          = 'public';
1467
-                $scopeSpecified = true;
1468
-                break;
1469
-            case T_PRIVATE:
1470
-                $scope          = 'private';
1471
-                $scopeSpecified = true;
1472
-                break;
1473
-            case T_PROTECTED:
1474
-                $scope          = 'protected';
1475
-                $scopeSpecified = true;
1476
-                break;
1477
-            case T_STATIC:
1478
-                $isStatic = true;
1479
-                break;
1465
+                case T_PUBLIC:
1466
+                    $scope          = 'public';
1467
+                    $scopeSpecified = true;
1468
+                    break;
1469
+                case T_PRIVATE:
1470
+                    $scope          = 'private';
1471
+                    $scopeSpecified = true;
1472
+                    break;
1473
+                case T_PROTECTED:
1474
+                    $scope          = 'protected';
1475
+                    $scopeSpecified = true;
1476
+                    break;
1477
+                case T_STATIC:
1478
+                    $isStatic = true;
1479
+                    break;
1480 1480
             }
1481 1481
         }//end for
1482 1482
 
@@ -1530,13 +1530,13 @@  discard block
 block discarded – undo
1530 1530
             }
1531 1531
 
1532 1532
             switch ($this->tokens[$i]['code']) {
1533
-            case T_ABSTRACT:
1534
-                $isAbstract = true;
1535
-                break;
1533
+                case T_ABSTRACT:
1534
+                    $isAbstract = true;
1535
+                    break;
1536 1536
 
1537
-            case T_FINAL:
1538
-                $isFinal = true;
1539
-                break;
1537
+                case T_FINAL:
1538
+                    $isFinal = true;
1539
+                    break;
1540 1540
             }
1541 1541
         }//end for
1542 1542
 
Please login to merge, or discard this patch.
src/Runner.php 1 patch
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -607,19 +607,19 @@
 block discarded – undo
607 607
                 $input = trim($input);
608 608
 
609 609
                 switch ($input) {
610
-                case 's':
611
-                    break(2);
612
-                case 'q':
613
-                    exit(0);
614
-                default:
615
-                    // Repopulate the sniffs because some of them save their state
616
-                    // and only clear it when the file changes, but we are rechecking
617
-                    // the same file.
618
-                    $file->ruleset->populateTokenListeners();
619
-                    $file->reloadContent();
620
-                    $file->process();
621
-                    $this->reporter->cacheFileReport($file, $this->config);
622
-                    break;
610
+                    case 's':
611
+                        break(2);
612
+                    case 'q':
613
+                        exit(0);
614
+                    default:
615
+                        // Repopulate the sniffs because some of them save their state
616
+                        // and only clear it when the file changes, but we are rechecking
617
+                        // the same file.
618
+                        $file->ruleset->populateTokenListeners();
619
+                        $file->reloadContent();
620
+                        $file->process();
621
+                        $this->reporter->cacheFileReport($file, $this->config);
622
+                        break;
623 623
                 }
624 624
             }//end while
625 625
         }//end if
Please login to merge, or discard this patch.
src/Util/Common.php 1 patch
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -343,15 +343,15 @@
 block discarded – undo
343 343
         } else {
344 344
             $lowerVarType = strtolower($varType);
345 345
             switch ($lowerVarType) {
346
-            case 'bool':
347
-                return 'boolean';
348
-            case 'double':
349
-            case 'real':
350
-                return 'float';
351
-            case 'int':
352
-                return 'integer';
353
-            case 'array()':
354
-                return 'array';
346
+                case 'bool':
347
+                    return 'boolean';
348
+                case 'double':
349
+                case 'real':
350
+                    return 'float';
351
+                case 'int':
352
+                    return 'integer';
353
+                case 'array()':
354
+                    return 'array';
355 355
             }//end switch
356 356
 
357 357
             if (strpos($lowerVarType, 'array(') !== false) {
Please login to merge, or discard this patch.
src/Fixer.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -283,14 +283,14 @@
 block discarded – undo
283 283
         foreach ($diffLines as $line) {
284 284
             if (isset($line[0]) === true) {
285 285
                 switch ($line[0]) {
286
-                case '-':
287
-                    $diff[] = "\033[31m$line\033[0m";
288
-                    break;
289
-                case '+':
290
-                    $diff[] = "\033[32m$line\033[0m";
291
-                    break;
292
-                default:
293
-                    $diff[] = $line;
286
+                    case '-':
287
+                        $diff[] = "\033[31m$line\033[0m";
288
+                        break;
289
+                    case '+':
290
+                        $diff[] = "\033[32m$line\033[0m";
291
+                        break;
292
+                    default:
293
+                        $diff[] = $line;
294 294
                 }
295 295
             }
296 296
         }
Please login to merge, or discard this patch.
src/Tokenizers/PHP.php 1 patch
Switch Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -1450,24 +1450,24 @@  discard block
 block discarded – undo
1450 1450
 
1451 1451
         if ($token[0] === T_STRING) {
1452 1452
             switch ($cacheKey) {
1453
-            case 'false':
1454
-                $newToken['type'] = 'T_FALSE';
1455
-                break;
1456
-            case 'true':
1457
-                $newToken['type'] = 'T_TRUE';
1458
-                break;
1459
-            case 'null':
1460
-                $newToken['type'] = 'T_NULL';
1461
-                break;
1462
-            case 'self':
1463
-                $newToken['type'] = 'T_SELF';
1464
-                break;
1465
-            case 'parent':
1466
-                $newToken['type'] = 'T_PARENT';
1467
-                break;
1468
-            default:
1469
-                $newToken['type'] = 'T_STRING';
1470
-                break;
1453
+                case 'false':
1454
+                    $newToken['type'] = 'T_FALSE';
1455
+                    break;
1456
+                case 'true':
1457
+                    $newToken['type'] = 'T_TRUE';
1458
+                    break;
1459
+                case 'null':
1460
+                    $newToken['type'] = 'T_NULL';
1461
+                    break;
1462
+                case 'self':
1463
+                    $newToken['type'] = 'T_SELF';
1464
+                    break;
1465
+                case 'parent':
1466
+                    $newToken['type'] = 'T_PARENT';
1467
+                    break;
1468
+                default:
1469
+                    $newToken['type'] = 'T_STRING';
1470
+                    break;
1471 1471
             }
1472 1472
 
1473 1473
             $newToken['code'] = constant($newToken['type']);
@@ -1509,87 +1509,87 @@  discard block
 block discarded – undo
1509 1509
         $newToken = array();
1510 1510
 
1511 1511
         switch ($token) {
1512
-        case '{':
1513
-            $newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1514
-            break;
1515
-        case '}':
1516
-            $newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1517
-            break;
1518
-        case '[':
1519
-            $newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1520
-            break;
1521
-        case ']':
1522
-            $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1523
-            break;
1524
-        case '(':
1525
-            $newToken['type'] = 'T_OPEN_PARENTHESIS';
1526
-            break;
1527
-        case ')':
1528
-            $newToken['type'] = 'T_CLOSE_PARENTHESIS';
1529
-            break;
1530
-        case ':':
1531
-            $newToken['type'] = 'T_COLON';
1532
-            break;
1533
-        case '.':
1534
-            $newToken['type'] = 'T_STRING_CONCAT';
1535
-            break;
1536
-        case '?':
1537
-            $newToken['type'] = 'T_INLINE_THEN';
1538
-            break;
1539
-        case ';':
1540
-            $newToken['type'] = 'T_SEMICOLON';
1541
-            break;
1542
-        case '=':
1543
-            $newToken['type'] = 'T_EQUAL';
1544
-            break;
1545
-        case '*':
1546
-            $newToken['type'] = 'T_MULTIPLY';
1547
-            break;
1548
-        case '/':
1549
-            $newToken['type'] = 'T_DIVIDE';
1550
-            break;
1551
-        case '+':
1552
-            $newToken['type'] = 'T_PLUS';
1553
-            break;
1554
-        case '-':
1555
-            $newToken['type'] = 'T_MINUS';
1556
-            break;
1557
-        case '%':
1558
-            $newToken['type'] = 'T_MODULUS';
1559
-            break;
1560
-        case '^':
1561
-            $newToken['type'] = 'T_BITWISE_XOR';
1562
-            break;
1563
-        case '&':
1564
-            $newToken['type'] = 'T_BITWISE_AND';
1565
-            break;
1566
-        case '|':
1567
-            $newToken['type'] = 'T_BITWISE_OR';
1568
-            break;
1569
-        case '<':
1570
-            $newToken['type'] = 'T_LESS_THAN';
1571
-            break;
1572
-        case '>':
1573
-            $newToken['type'] = 'T_GREATER_THAN';
1574
-            break;
1575
-        case '!':
1576
-            $newToken['type'] = 'T_BOOLEAN_NOT';
1577
-            break;
1578
-        case ',':
1579
-            $newToken['type'] = 'T_COMMA';
1580
-            break;
1581
-        case '@':
1582
-            $newToken['type'] = 'T_ASPERAND';
1583
-            break;
1584
-        case '$':
1585
-            $newToken['type'] = 'T_DOLLAR';
1586
-            break;
1587
-        case '`':
1588
-            $newToken['type'] = 'T_BACKTICK';
1589
-            break;
1590
-        default:
1591
-            $newToken['type'] = 'T_NONE';
1592
-            break;
1512
+            case '{':
1513
+                $newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1514
+                break;
1515
+            case '}':
1516
+                $newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1517
+                break;
1518
+            case '[':
1519
+                $newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1520
+                break;
1521
+            case ']':
1522
+                $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1523
+                break;
1524
+            case '(':
1525
+                $newToken['type'] = 'T_OPEN_PARENTHESIS';
1526
+                break;
1527
+            case ')':
1528
+                $newToken['type'] = 'T_CLOSE_PARENTHESIS';
1529
+                break;
1530
+            case ':':
1531
+                $newToken['type'] = 'T_COLON';
1532
+                break;
1533
+            case '.':
1534
+                $newToken['type'] = 'T_STRING_CONCAT';
1535
+                break;
1536
+            case '?':
1537
+                $newToken['type'] = 'T_INLINE_THEN';
1538
+                break;
1539
+            case ';':
1540
+                $newToken['type'] = 'T_SEMICOLON';
1541
+                break;
1542
+            case '=':
1543
+                $newToken['type'] = 'T_EQUAL';
1544
+                break;
1545
+            case '*':
1546
+                $newToken['type'] = 'T_MULTIPLY';
1547
+                break;
1548
+            case '/':
1549
+                $newToken['type'] = 'T_DIVIDE';
1550
+                break;
1551
+            case '+':
1552
+                $newToken['type'] = 'T_PLUS';
1553
+                break;
1554
+            case '-':
1555
+                $newToken['type'] = 'T_MINUS';
1556
+                break;
1557
+            case '%':
1558
+                $newToken['type'] = 'T_MODULUS';
1559
+                break;
1560
+            case '^':
1561
+                $newToken['type'] = 'T_BITWISE_XOR';
1562
+                break;
1563
+            case '&':
1564
+                $newToken['type'] = 'T_BITWISE_AND';
1565
+                break;
1566
+            case '|':
1567
+                $newToken['type'] = 'T_BITWISE_OR';
1568
+                break;
1569
+            case '<':
1570
+                $newToken['type'] = 'T_LESS_THAN';
1571
+                break;
1572
+            case '>':
1573
+                $newToken['type'] = 'T_GREATER_THAN';
1574
+                break;
1575
+            case '!':
1576
+                $newToken['type'] = 'T_BOOLEAN_NOT';
1577
+                break;
1578
+            case ',':
1579
+                $newToken['type'] = 'T_COMMA';
1580
+                break;
1581
+            case '@':
1582
+                $newToken['type'] = 'T_ASPERAND';
1583
+                break;
1584
+            case '$':
1585
+                $newToken['type'] = 'T_DOLLAR';
1586
+                break;
1587
+            case '`':
1588
+                $newToken['type'] = 'T_BACKTICK';
1589
+                break;
1590
+            default:
1591
+                $newToken['type'] = 'T_NONE';
1592
+                break;
1593 1593
         }//end switch
1594 1594
 
1595 1595
         $newToken['code']    = constant($newToken['type']);
Please login to merge, or discard this patch.
src/Reports/VersionControl.php 1 patch
Switch Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -173,37 +173,37 @@
 block discarded – undo
173 173
         foreach ($lines as $line) {
174 174
             $parts = explode('>>', $line);
175 175
             switch ($parts[0]) {
176
-            case 'AUTHOR':
177
-                if (isset($authorCache[$parts[1]]) === false) {
178
-                    $authorCache[$parts[1]] = $parts[2];
179
-                } else {
180
-                    $authorCache[$parts[1]] += $parts[2];
181
-                }
182
-                break;
183
-            case 'PRAISE':
184
-                if (isset($praiseCache[$parts[1]]) === false) {
185
-                    $praiseCache[$parts[1]] = array(
186
-                                               'good' => $parts[2],
187
-                                               'bad'  => $parts[3],
188
-                                              );
189
-                } else {
190
-                    $praiseCache[$parts[1]]['good'] += $parts[2];
191
-                    $praiseCache[$parts[1]]['bad']  += $parts[3];
192
-                }
193
-                break;
194
-            case 'SOURCE':
195
-                if (isset($praiseCache[$parts[1]]) === false) {
196
-                    $praiseCache[$parts[1]] = array();
197
-                }
176
+                case 'AUTHOR':
177
+                    if (isset($authorCache[$parts[1]]) === false) {
178
+                        $authorCache[$parts[1]] = $parts[2];
179
+                    } else {
180
+                        $authorCache[$parts[1]] += $parts[2];
181
+                    }
182
+                    break;
183
+                case 'PRAISE':
184
+                    if (isset($praiseCache[$parts[1]]) === false) {
185
+                        $praiseCache[$parts[1]] = array(
186
+                                                   'good' => $parts[2],
187
+                                                   'bad'  => $parts[3],
188
+                                                  );
189
+                    } else {
190
+                        $praiseCache[$parts[1]]['good'] += $parts[2];
191
+                        $praiseCache[$parts[1]]['bad']  += $parts[3];
192
+                    }
193
+                    break;
194
+                case 'SOURCE':
195
+                    if (isset($praiseCache[$parts[1]]) === false) {
196
+                        $praiseCache[$parts[1]] = array();
197
+                    }
198 198
 
199
-                if (isset($sourceCache[$parts[1]][$parts[2]]) === false) {
200
-                    $sourceCache[$parts[1]][$parts[2]] = $parts[3];
201
-                } else {
202
-                    $sourceCache[$parts[1]][$parts[2]] += $parts[3];
203
-                }
204
-                break;
205
-            default:
206
-                break;
199
+                    if (isset($sourceCache[$parts[1]][$parts[2]]) === false) {
200
+                        $sourceCache[$parts[1]][$parts[2]] = $parts[3];
201
+                    } else {
202
+                        $sourceCache[$parts[1]][$parts[2]] += $parts[3];
203
+                    }
204
+                    break;
205
+                default:
206
+                    break;
207 207
             }//end switch
208 208
         }//end foreach
209 209
 
Please login to merge, or discard this patch.
src/Tokenizers/Tokenizer.php 1 patch
Switch Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -406,60 +406,60 @@
 block discarded – undo
406 406
             */
407 407
 
408 408
             switch ($this->tokens[$i]['code']) {
409
-            case T_OPEN_SQUARE_BRACKET:
410
-                $squareOpeners[] = $i;
411
-
412
-                if (PHP_CodeSniffer_VERBOSITY > 1) {
413
-                    echo str_repeat("\t", count($squareOpeners));
414
-                    echo str_repeat("\t", count($curlyOpeners));
415
-                    echo "=> Found square bracket opener at $i".PHP_EOL;
416
-                }
417
-                break;
418
-            case T_OPEN_CURLY_BRACKET:
419
-                if (isset($this->tokens[$i]['scope_closer']) === false) {
420
-                    $curlyOpeners[] = $i;
409
+                case T_OPEN_SQUARE_BRACKET:
410
+                    $squareOpeners[] = $i;
421 411
 
422 412
                     if (PHP_CodeSniffer_VERBOSITY > 1) {
423 413
                         echo str_repeat("\t", count($squareOpeners));
424 414
                         echo str_repeat("\t", count($curlyOpeners));
425
-                        echo "=> Found curly bracket opener at $i".PHP_EOL;
415
+                        echo "=> Found square bracket opener at $i".PHP_EOL;
426 416
                     }
427
-                }
428
-                break;
429
-            case T_CLOSE_SQUARE_BRACKET:
430
-                if (empty($squareOpeners) === false) {
431
-                    $opener = array_pop($squareOpeners);
432
-                    $this->tokens[$i]['bracket_opener']      = $opener;
433
-                    $this->tokens[$i]['bracket_closer']      = $i;
434
-                    $this->tokens[$opener]['bracket_opener'] = $opener;
435
-                    $this->tokens[$opener]['bracket_closer'] = $i;
417
+                    break;
418
+                case T_OPEN_CURLY_BRACKET:
419
+                    if (isset($this->tokens[$i]['scope_closer']) === false) {
420
+                        $curlyOpeners[] = $i;
436 421
 
437
-                    if (PHP_CodeSniffer_VERBOSITY > 1) {
438
-                        echo str_repeat("\t", count($squareOpeners));
439
-                        echo str_repeat("\t", count($curlyOpeners));
440
-                        echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL;
422
+                        if (PHP_CodeSniffer_VERBOSITY > 1) {
423
+                            echo str_repeat("\t", count($squareOpeners));
424
+                            echo str_repeat("\t", count($curlyOpeners));
425
+                            echo "=> Found curly bracket opener at $i".PHP_EOL;
426
+                        }
441 427
                     }
442
-                }
443
-                break;
444
-            case T_CLOSE_CURLY_BRACKET:
445
-                if (empty($curlyOpeners) === false
446
-                    && isset($this->tokens[$i]['scope_opener']) === false
447
-                ) {
448
-                    $opener = array_pop($curlyOpeners);
449
-                    $this->tokens[$i]['bracket_opener']      = $opener;
450
-                    $this->tokens[$i]['bracket_closer']      = $i;
451
-                    $this->tokens[$opener]['bracket_opener'] = $opener;
452
-                    $this->tokens[$opener]['bracket_closer'] = $i;
428
+                    break;
429
+                case T_CLOSE_SQUARE_BRACKET:
430
+                    if (empty($squareOpeners) === false) {
431
+                        $opener = array_pop($squareOpeners);
432
+                        $this->tokens[$i]['bracket_opener']      = $opener;
433
+                        $this->tokens[$i]['bracket_closer']      = $i;
434
+                        $this->tokens[$opener]['bracket_opener'] = $opener;
435
+                        $this->tokens[$opener]['bracket_closer'] = $i;
453 436
 
454
-                    if (PHP_CodeSniffer_VERBOSITY > 1) {
455
-                        echo str_repeat("\t", count($squareOpeners));
456
-                        echo str_repeat("\t", count($curlyOpeners));
457
-                        echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL;
437
+                        if (PHP_CodeSniffer_VERBOSITY > 1) {
438
+                            echo str_repeat("\t", count($squareOpeners));
439
+                            echo str_repeat("\t", count($curlyOpeners));
440
+                            echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL;
441
+                        }
458 442
                     }
459
-                }
460
-                break;
461
-            default:
462
-                continue;
443
+                    break;
444
+                case T_CLOSE_CURLY_BRACKET:
445
+                    if (empty($curlyOpeners) === false
446
+                        && isset($this->tokens[$i]['scope_opener']) === false
447
+                    ) {
448
+                        $opener = array_pop($curlyOpeners);
449
+                        $this->tokens[$i]['bracket_opener']      = $opener;
450
+                        $this->tokens[$i]['bracket_closer']      = $i;
451
+                        $this->tokens[$opener]['bracket_opener'] = $opener;
452
+                        $this->tokens[$opener]['bracket_closer'] = $i;
453
+
454
+                        if (PHP_CodeSniffer_VERBOSITY > 1) {
455
+                            echo str_repeat("\t", count($squareOpeners));
456
+                            echo str_repeat("\t", count($curlyOpeners));
457
+                            echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL;
458
+                        }
459
+                    }
460
+                    break;
461
+                default:
462
+                    continue;
463 463
             }//end switch
464 464
         }//end for
465 465
 
Please login to merge, or discard this patch.
src/Tokenizers/CSS.php 1 patch
Switch Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -284,12 +284,32 @@  discard block
 block discarded – undo
284 284
             }
285 285
 
286 286
             switch ($token['code']) {
287
-            case T_OPEN_CURLY_BRACKET:
288
-                // Opening curly brackets for an At-rule do not start a style
289
-                // definition. We also reset the asperand flag here because the next
290
-                // opening curly bracket could be indeed the start of a style
291
-                // definition.
292
-                if ($asperandStart === true) {
287
+                case T_OPEN_CURLY_BRACKET:
288
+                    // Opening curly brackets for an At-rule do not start a style
289
+                    // definition. We also reset the asperand flag here because the next
290
+                    // opening curly bracket could be indeed the start of a style
291
+                    // definition.
292
+                    if ($asperandStart === true) {
293
+                        if (PHP_CodeSniffer_VERBOSITY > 1) {
294
+                            if ($inStyleDef === true) {
295
+                                echo "\t\t* style definition closed *".PHP_EOL;
296
+                            }
297
+
298
+                            if ($asperandStart === true) {
299
+                                echo "\t\t* at-rule definition closed *".PHP_EOL;
300
+                            }
301
+                        }
302
+
303
+                        $inStyleDef    = false;
304
+                        $asperandStart = false;
305
+                    } else {
306
+                        $inStyleDef = true;
307
+                        if (PHP_CodeSniffer_VERBOSITY > 1) {
308
+                            echo "\t\t* style definition opened *".PHP_EOL;
309
+                        }
310
+                    }
311
+                    break;
312
+                case T_CLOSE_CURLY_BRACKET:
293 313
                     if (PHP_CodeSniffer_VERBOSITY > 1) {
294 314
                         if ($inStyleDef === true) {
295 315
                             echo "\t\t* style definition closed *".PHP_EOL;
@@ -302,162 +322,142 @@  discard block
 block discarded – undo
302 322
 
303 323
                     $inStyleDef    = false;
304 324
                     $asperandStart = false;
305
-                } else {
306
-                    $inStyleDef = true;
307
-                    if (PHP_CodeSniffer_VERBOSITY > 1) {
308
-                        echo "\t\t* style definition opened *".PHP_EOL;
309
-                    }
310
-                }
311
-                break;
312
-            case T_CLOSE_CURLY_BRACKET:
313
-                if (PHP_CodeSniffer_VERBOSITY > 1) {
314
-                    if ($inStyleDef === true) {
315
-                        echo "\t\t* style definition closed *".PHP_EOL;
316
-                    }
317
-
318
-                    if ($asperandStart === true) {
319
-                        echo "\t\t* at-rule definition closed *".PHP_EOL;
320
-                    }
321
-                }
322
-
323
-                $inStyleDef    = false;
324
-                $asperandStart = false;
325
-                break;
326
-            case T_MINUS:
327
-                // Minus signs are often used instead of spaces inside
328
-                // class names, IDs and styles.
329
-                if ($finalTokens[($stackPtr + 1)]['code'] === T_STRING) {
330
-                    if ($finalTokens[($stackPtr - 1)]['code'] === T_STRING) {
331
-                        $newContent = $finalTokens[($stackPtr - 1)]['content'].'-'.$finalTokens[($stackPtr + 1)]['content'];
332
-
325
+                    break;
326
+                case T_MINUS:
327
+                    // Minus signs are often used instead of spaces inside
328
+                    // class names, IDs and styles.
329
+                    if ($finalTokens[($stackPtr + 1)]['code'] === T_STRING) {
330
+                        if ($finalTokens[($stackPtr - 1)]['code'] === T_STRING) {
331
+                            $newContent = $finalTokens[($stackPtr - 1)]['content'].'-'.$finalTokens[($stackPtr + 1)]['content'];
332
+
333
+                            if (PHP_CodeSniffer_VERBOSITY > 1) {
334
+                                echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL;
335
+                                $old = Util\Common::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
336
+                                $new = Util\Common::prepareForOutput($newContent);
337
+                                echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL;
338
+                            }
339
+
340
+                            $finalTokens[($stackPtr + 1)]['content'] = $newContent;
341
+                            unset($finalTokens[$stackPtr]);
342
+                            unset($finalTokens[($stackPtr - 1)]);
343
+                        } else {
344
+                            $newContent = '-'.$finalTokens[($stackPtr + 1)]['content'];
345
+
346
+                            $finalTokens[($stackPtr + 1)]['content'] = $newContent;
347
+                            unset($finalTokens[$stackPtr]);
348
+                        }
349
+                    } else if ($finalTokens[($stackPtr + 1)]['code'] === T_LNUMBER) {
350
+                        // They can also be used to provide negative numbers.
333 351
                         if (PHP_CodeSniffer_VERBOSITY > 1) {
334
-                            echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL;
335
-                            $old = Util\Common::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
336
-                            $new = Util\Common::prepareForOutput($newContent);
337
-                            echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL;
352
+                            echo "\t\t* token is part of a negative number; adding content to next token and ignoring *".PHP_EOL;
353
+                            $content = Util\Common::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
354
+                            echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$content\" to \"-$content\"".PHP_EOL;
338 355
                         }
339 356
 
340
-                        $finalTokens[($stackPtr + 1)]['content'] = $newContent;
357
+                        $finalTokens[($stackPtr + 1)]['content'] = '-'.$finalTokens[($stackPtr + 1)]['content'];
341 358
                         unset($finalTokens[$stackPtr]);
342
-                        unset($finalTokens[($stackPtr - 1)]);
343
-                    } else {
344
-                        $newContent = '-'.$finalTokens[($stackPtr + 1)]['content'];
359
+                    }//end if
345 360
 
346
-                        $finalTokens[($stackPtr + 1)]['content'] = $newContent;
347
-                        unset($finalTokens[$stackPtr]);
348
-                    }
349
-                } else if ($finalTokens[($stackPtr + 1)]['code'] === T_LNUMBER) {
350
-                    // They can also be used to provide negative numbers.
351
-                    if (PHP_CodeSniffer_VERBOSITY > 1) {
352
-                        echo "\t\t* token is part of a negative number; adding content to next token and ignoring *".PHP_EOL;
353
-                        $content = Util\Common::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
354
-                        echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$content\" to \"-$content\"".PHP_EOL;
355
-                    }
356
-
357
-                    $finalTokens[($stackPtr + 1)]['content'] = '-'.$finalTokens[($stackPtr + 1)]['content'];
358
-                    unset($finalTokens[$stackPtr]);
359
-                }//end if
360
-
361
-                break;
362
-            case T_COLON:
363
-                // Only interested in colons that are defining styles.
364
-                if ($inStyleDef === false) {
365 361
                     break;
366
-                }
367
-
368
-                for ($x = ($stackPtr - 1); $x >= 0; $x--) {
369
-                    if (isset(Util\Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) {
362
+                case T_COLON:
363
+                    // Only interested in colons that are defining styles.
364
+                    if ($inStyleDef === false) {
370 365
                         break;
371 366
                     }
372
-                }
373 367
 
374
-                if (PHP_CodeSniffer_VERBOSITY > 1) {
375
-                    $type = $finalTokens[$x]['type'];
376
-                    echo "\t\t=> token $x changed from $type to T_STYLE".PHP_EOL;
377
-                }
378
-
379
-                $finalTokens[$x]['type'] = 'T_STYLE';
380
-                $finalTokens[$x]['code'] = T_STYLE;
381
-                break;
382
-            case T_STRING:
383
-                if (strtolower($token['content']) === 'url') {
384
-                    // Find the next content.
385
-                    for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
368
+                    for ($x = ($stackPtr - 1); $x >= 0; $x--) {
386 369
                         if (isset(Util\Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) {
387 370
                             break;
388 371
                         }
389 372
                     }
390 373
 
391
-                    // Needs to be in the format "url(" for it to be a URL.
392
-                    if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) {
393
-                        continue;
374
+                    if (PHP_CodeSniffer_VERBOSITY > 1) {
375
+                        $type = $finalTokens[$x]['type'];
376
+                        echo "\t\t=> token $x changed from $type to T_STYLE".PHP_EOL;
394 377
                     }
395 378
 
396
-                    // Make sure the content isn't empty.
397
-                    for ($y = ($x + 1); $y < $numTokens; $y++) {
398
-                        if (isset(Util\Tokens::$emptyTokens[$finalTokens[$y]['code']]) === false) {
399
-                            break;
379
+                    $finalTokens[$x]['type'] = 'T_STYLE';
380
+                    $finalTokens[$x]['code'] = T_STYLE;
381
+                    break;
382
+                case T_STRING:
383
+                    if (strtolower($token['content']) === 'url') {
384
+                        // Find the next content.
385
+                        for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
386
+                            if (isset(Util\Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) {
387
+                                break;
388
+                            }
400 389
                         }
401
-                    }
402 390
 
403
-                    if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) {
404
-                        continue;
405
-                    }
406
-
407
-                    if (PHP_CodeSniffer_VERBOSITY > 1) {
408
-                        for ($i = ($stackPtr + 1); $i <= $y; $i++) {
409
-                            $type    = $finalTokens[$i]['type'];
410
-                            $content = Util\Common::prepareForOutput($finalTokens[$i]['content']);
411
-                            echo "\tProcess token $i: $type => $content".PHP_EOL;
391
+                        // Needs to be in the format "url(" for it to be a URL.
392
+                        if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) {
393
+                            continue;
412 394
                         }
413 395
 
414
-                        echo "\t\t* token starts a URL *".PHP_EOL;
415
-                    }
396
+                        // Make sure the content isn't empty.
397
+                        for ($y = ($x + 1); $y < $numTokens; $y++) {
398
+                            if (isset(Util\Tokens::$emptyTokens[$finalTokens[$y]['code']]) === false) {
399
+                                break;
400
+                            }
401
+                        }
416 402
 
417
-                    // Join all the content together inside the url() statement.
418
-                    $newContent = '';
419
-                    for ($i = ($x + 2); $i < $numTokens; $i++) {
420
-                        if ($finalTokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
421
-                            break;
403
+                        if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) {
404
+                            continue;
422 405
                         }
423 406
 
424
-                        $newContent .= $finalTokens[$i]['content'];
425 407
                         if (PHP_CodeSniffer_VERBOSITY > 1) {
426
-                            $content = Util\Common::prepareForOutput($finalTokens[$i]['content']);
427
-                            echo "\t\t=> token $i added to URL string and ignored: $content".PHP_EOL;
408
+                            for ($i = ($stackPtr + 1); $i <= $y; $i++) {
409
+                                $type    = $finalTokens[$i]['type'];
410
+                                $content = Util\Common::prepareForOutput($finalTokens[$i]['content']);
411
+                                echo "\tProcess token $i: $type => $content".PHP_EOL;
412
+                            }
413
+
414
+                            echo "\t\t* token starts a URL *".PHP_EOL;
428 415
                         }
429 416
 
430
-                        unset($finalTokens[$i]);
431
-                    }
417
+                        // Join all the content together inside the url() statement.
418
+                        $newContent = '';
419
+                        for ($i = ($x + 2); $i < $numTokens; $i++) {
420
+                            if ($finalTokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
421
+                                break;
422
+                            }
432 423
 
433
-                    $stackPtr = $i;
424
+                            $newContent .= $finalTokens[$i]['content'];
425
+                            if (PHP_CodeSniffer_VERBOSITY > 1) {
426
+                                $content = Util\Common::prepareForOutput($finalTokens[$i]['content']);
427
+                                echo "\t\t=> token $i added to URL string and ignored: $content".PHP_EOL;
428
+                            }
434 429
 
435
-                    // If the content inside the "url()" is in double quotes
436
-                    // there will only be one token and so we don't have to do
437
-                    // anything except change its type. If it is not empty,
438
-                    // we need to do some token merging.
439
-                    $finalTokens[($x + 1)]['type'] = 'T_URL';
440
-                    $finalTokens[($x + 1)]['code'] = T_URL;
430
+                            unset($finalTokens[$i]);
431
+                        }
441 432
 
442
-                    if ($newContent !== '') {
443
-                        $finalTokens[($x + 1)]['content'] .= $newContent;
444
-                        if (PHP_CodeSniffer_VERBOSITY > 1) {
445
-                            $content = Util\Common::prepareForOutput($finalTokens[($x + 1)]['content']);
446
-                            echo "\t\t=> token content changed to: $content".PHP_EOL;
433
+                        $stackPtr = $i;
434
+
435
+                        // If the content inside the "url()" is in double quotes
436
+                        // there will only be one token and so we don't have to do
437
+                        // anything except change its type. If it is not empty,
438
+                        // we need to do some token merging.
439
+                        $finalTokens[($x + 1)]['type'] = 'T_URL';
440
+                        $finalTokens[($x + 1)]['code'] = T_URL;
441
+
442
+                        if ($newContent !== '') {
443
+                            $finalTokens[($x + 1)]['content'] .= $newContent;
444
+                            if (PHP_CodeSniffer_VERBOSITY > 1) {
445
+                                $content = Util\Common::prepareForOutput($finalTokens[($x + 1)]['content']);
446
+                                echo "\t\t=> token content changed to: $content".PHP_EOL;
447
+                            }
447 448
                         }
448
-                    }
449
-                }//end if
449
+                    }//end if
450 450
 
451
-                break;
452
-            case T_ASPERAND:
453
-                $asperandStart = true;
454
-                if (PHP_CodeSniffer_VERBOSITY > 1) {
455
-                    echo "\t\t* at-rule definition opened *".PHP_EOL;
456
-                }
457
-                break;
458
-            default:
459
-                // Nothing special to be done with this token.
460
-                break;
451
+                    break;
452
+                case T_ASPERAND:
453
+                    $asperandStart = true;
454
+                    if (PHP_CodeSniffer_VERBOSITY > 1) {
455
+                        echo "\t\t* at-rule definition opened *".PHP_EOL;
456
+                    }
457
+                    break;
458
+                default:
459
+                    // Nothing special to be done with this token.
460
+                    break;
461 461
             }//end switch
462 462
         }//end for
463 463
 
Please login to merge, or discard this patch.