@@ -110,18 +110,18 @@ |
||
110 | 110 | if ($fix === true) { |
111 | 111 | $tokens = $phpcsFile->getTokens(); |
112 | 112 | switch ($this->eolChar) { |
113 | - case '\n': |
|
114 | - $eolChar = "\n"; |
|
115 | - break; |
|
116 | - case '\r': |
|
117 | - $eolChar = "\r"; |
|
118 | - break; |
|
119 | - case '\r\n': |
|
120 | - $eolChar = "\r\n"; |
|
121 | - break; |
|
122 | - default: |
|
123 | - $eolChar = $this->eolChar; |
|
124 | - break; |
|
113 | + case '\n': |
|
114 | + $eolChar = "\n"; |
|
115 | + break; |
|
116 | + case '\r': |
|
117 | + $eolChar = "\r"; |
|
118 | + break; |
|
119 | + case '\r\n': |
|
120 | + $eolChar = "\r\n"; |
|
121 | + break; |
|
122 | + default: |
|
123 | + $eolChar = $this->eolChar; |
|
124 | + break; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | for ($i = 0; $i < $phpcsFile->numTokens; $i++) { |
@@ -80,18 +80,18 @@ |
||
80 | 80 | $prefix = $stackPtr; |
81 | 81 | while (($prefix = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$methodPrefixes, ($prefix - 1), $prev)) !== false) { |
82 | 82 | switch ($tokens[$prefix]['code']) { |
83 | - case T_STATIC: |
|
84 | - $static = $prefix; |
|
85 | - break; |
|
86 | - case T_ABSTRACT: |
|
87 | - $abstract = $prefix; |
|
88 | - break; |
|
89 | - case T_FINAL: |
|
90 | - $final = $prefix; |
|
91 | - break; |
|
92 | - default: |
|
93 | - $visibility = $prefix; |
|
94 | - break; |
|
83 | + case T_STATIC: |
|
84 | + $static = $prefix; |
|
85 | + break; |
|
86 | + case T_ABSTRACT: |
|
87 | + $abstract = $prefix; |
|
88 | + break; |
|
89 | + case T_FINAL: |
|
90 | + $final = $prefix; |
|
91 | + break; |
|
92 | + default: |
|
93 | + $visibility = $prefix; |
|
94 | + break; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 |
@@ -63,17 +63,17 @@ |
||
63 | 63 | $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($stackPtr + 2), null, false, true); |
64 | 64 | $typeName = trim($tokens[$typeName]['content'], " '"); |
65 | 65 | switch (strtolower($tokens[($stackPtr + 1)]['content'])) { |
66 | - case 'includesystem' : |
|
67 | - $included = strtolower($typeName); |
|
68 | - break; |
|
69 | - case 'includeasset' : |
|
70 | - $included = strtolower($typeName).'assettype'; |
|
71 | - break; |
|
72 | - case 'includewidget' : |
|
73 | - $included = strtolower($typeName).'widgettype'; |
|
74 | - break; |
|
75 | - default: |
|
76 | - return; |
|
66 | + case 'includesystem' : |
|
67 | + $included = strtolower($typeName); |
|
68 | + break; |
|
69 | + case 'includeasset' : |
|
70 | + $included = strtolower($typeName).'assettype'; |
|
71 | + break; |
|
72 | + case 'includewidget' : |
|
73 | + $included = strtolower($typeName).'widgettype'; |
|
74 | + break; |
|
75 | + default: |
|
76 | + return; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | if ($included === strtolower($ownClass)) { |
@@ -111,33 +111,33 @@ |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | switch ($tokens[$i]['code']) { |
114 | - case T_DOUBLE_COLON: |
|
115 | - $usedName = strtolower($tokens[($i - 1)]['content']); |
|
116 | - if ($usedName === $systemName) { |
|
117 | - // The included system was used, so it is fine. |
|
118 | - return; |
|
119 | - } |
|
120 | - break; |
|
121 | - case T_EXTENDS: |
|
122 | - $classNameToken = $phpcsFile->findNext(T_STRING, ($i + 1)); |
|
123 | - $className = strtolower($tokens[$classNameToken]['content']); |
|
124 | - if ($className === $systemName) { |
|
125 | - // The included system was used, so it is fine. |
|
126 | - return; |
|
127 | - } |
|
128 | - break; |
|
129 | - case T_IMPLEMENTS: |
|
130 | - $endImplements = $phpcsFile->findNext(array(T_EXTENDS, T_OPEN_CURLY_BRACKET), ($i + 1)); |
|
131 | - for ($x = ($i + 1); $x < $endImplements; $x++) { |
|
132 | - if ($tokens[$x]['code'] === T_STRING) { |
|
133 | - $className = strtolower($tokens[$x]['content']); |
|
134 | - if ($className === $systemName) { |
|
135 | - // The included system was used, so it is fine. |
|
136 | - return; |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
140 | - break; |
|
114 | + case T_DOUBLE_COLON: |
|
115 | + $usedName = strtolower($tokens[($i - 1)]['content']); |
|
116 | + if ($usedName === $systemName) { |
|
117 | + // The included system was used, so it is fine. |
|
118 | + return; |
|
119 | + } |
|
120 | + break; |
|
121 | + case T_EXTENDS: |
|
122 | + $classNameToken = $phpcsFile->findNext(T_STRING, ($i + 1)); |
|
123 | + $className = strtolower($tokens[$classNameToken]['content']); |
|
124 | + if ($className === $systemName) { |
|
125 | + // The included system was used, so it is fine. |
|
126 | + return; |
|
127 | + } |
|
128 | + break; |
|
129 | + case T_IMPLEMENTS: |
|
130 | + $endImplements = $phpcsFile->findNext(array(T_EXTENDS, T_OPEN_CURLY_BRACKET), ($i + 1)); |
|
131 | + for ($x = ($i + 1); $x < $endImplements; $x++) { |
|
132 | + if ($tokens[$x]['code'] === T_STRING) { |
|
133 | + $className = strtolower($tokens[$x]['content']); |
|
134 | + if ($className === $systemName) { |
|
135 | + // The included system was used, so it is fine. |
|
136 | + return; |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | + break; |
|
141 | 141 | }//end switch |
142 | 142 | }//end for |
143 | 143 |
@@ -890,26 +890,26 @@ |
||
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 | - } |
|
897 | - |
|
898 | - $nestedParenthesis--; |
|
899 | - break; |
|
900 | - case '{': |
|
901 | - if ($nestedBraces === 0) { |
|
902 | - $skip['to'] = 'scope_closer'; |
|
903 | - } |
|
904 | - |
|
905 | - $nestedBraces--; |
|
906 | - break; |
|
907 | - case '}': |
|
908 | - $nestedBraces++; |
|
909 | - break; |
|
910 | - case ')': |
|
911 | - $nestedParenthesis++; |
|
912 | - break; |
|
893 | + case '(': |
|
894 | + if ($nestedParenthesis === 0) { |
|
895 | + $skip['to'] = 'parenthesis_closer'; |
|
896 | + } |
|
897 | + |
|
898 | + $nestedParenthesis--; |
|
899 | + break; |
|
900 | + case '{': |
|
901 | + if ($nestedBraces === 0) { |
|
902 | + $skip['to'] = 'scope_closer'; |
|
903 | + } |
|
904 | + |
|
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) { |
@@ -487,72 +487,72 @@ discard block |
||
487 | 487 | public function processShortArgument($arg, $pos) |
488 | 488 | { |
489 | 489 | switch ($arg) { |
490 | - case 'h': |
|
491 | - case '?': |
|
492 | - $this->printUsage(); |
|
493 | - exit(0); |
|
494 | - case 'i' : |
|
495 | - $this->printInstalledStandards(); |
|
496 | - exit(0); |
|
497 | - case 'v' : |
|
498 | - if ($this->values['quiet'] === true) { |
|
499 | - // Ignore when quiet mode is enabled. |
|
500 | - break; |
|
501 | - } |
|
502 | - |
|
503 | - if (isset($this->values['verbosity']) === false) { |
|
504 | - $this->values['verbosity'] = 1; |
|
505 | - } else { |
|
506 | - $this->values['verbosity']++; |
|
507 | - } |
|
508 | - break; |
|
509 | - case 'l' : |
|
510 | - $this->values['local'] = true; |
|
511 | - break; |
|
512 | - case 's' : |
|
513 | - $this->values['showSources'] = true; |
|
514 | - break; |
|
515 | - case 'a' : |
|
516 | - $this->values['interactive'] = true; |
|
517 | - break; |
|
518 | - case 'e': |
|
519 | - $this->values['explain'] = true; |
|
520 | - break; |
|
521 | - case 'p' : |
|
522 | - if ($this->values['quiet'] === true) { |
|
523 | - // Ignore when quiet mode is enabled. |
|
524 | - break; |
|
525 | - } |
|
526 | - |
|
527 | - $this->values['showProgress'] = true; |
|
528 | - break; |
|
529 | - case 'q' : |
|
530 | - // Quiet mode disables a few other settings as well. |
|
531 | - $this->values['quiet'] = true; |
|
532 | - $this->values['showProgress'] = false; |
|
533 | - $this->values['verbosity'] = 0; |
|
534 | - break; |
|
535 | - case 'd' : |
|
536 | - $ini = explode('=', $this->_cliArgs[($pos + 1)]); |
|
537 | - $this->_cliArgs[($pos + 1)] = ''; |
|
538 | - if (isset($ini[1]) === true) { |
|
539 | - ini_set($ini[0], $ini[1]); |
|
540 | - } else { |
|
541 | - ini_set($ini[0], true); |
|
542 | - } |
|
543 | - break; |
|
544 | - case 'n' : |
|
545 | - $this->values['warningSeverity'] = 0; |
|
546 | - break; |
|
547 | - case 'w' : |
|
548 | - $this->values['warningSeverity'] = null; |
|
549 | - break; |
|
550 | - default: |
|
551 | - if ($this->dieOnUnknownArg === false) { |
|
552 | - $this->values[$arg] = $arg; |
|
553 | - } else { |
|
554 | - $this->processUnknownArgument('-'.$arg, $pos); |
|
555 | - } |
|
490 | + case 'h': |
|
491 | + case '?': |
|
492 | + $this->printUsage(); |
|
493 | + exit(0); |
|
494 | + case 'i' : |
|
495 | + $this->printInstalledStandards(); |
|
496 | + exit(0); |
|
497 | + case 'v' : |
|
498 | + if ($this->values['quiet'] === true) { |
|
499 | + // Ignore when quiet mode is enabled. |
|
500 | + break; |
|
501 | + } |
|
502 | + |
|
503 | + if (isset($this->values['verbosity']) === false) { |
|
504 | + $this->values['verbosity'] = 1; |
|
505 | + } else { |
|
506 | + $this->values['verbosity']++; |
|
507 | + } |
|
508 | + break; |
|
509 | + case 'l' : |
|
510 | + $this->values['local'] = true; |
|
511 | + break; |
|
512 | + case 's' : |
|
513 | + $this->values['showSources'] = true; |
|
514 | + break; |
|
515 | + case 'a' : |
|
516 | + $this->values['interactive'] = true; |
|
517 | + break; |
|
518 | + case 'e': |
|
519 | + $this->values['explain'] = true; |
|
520 | + break; |
|
521 | + case 'p' : |
|
522 | + if ($this->values['quiet'] === true) { |
|
523 | + // Ignore when quiet mode is enabled. |
|
524 | + break; |
|
525 | + } |
|
526 | + |
|
527 | + $this->values['showProgress'] = true; |
|
528 | + break; |
|
529 | + case 'q' : |
|
530 | + // Quiet mode disables a few other settings as well. |
|
531 | + $this->values['quiet'] = true; |
|
532 | + $this->values['showProgress'] = false; |
|
533 | + $this->values['verbosity'] = 0; |
|
534 | + break; |
|
535 | + case 'd' : |
|
536 | + $ini = explode('=', $this->_cliArgs[($pos + 1)]); |
|
537 | + $this->_cliArgs[($pos + 1)] = ''; |
|
538 | + if (isset($ini[1]) === true) { |
|
539 | + ini_set($ini[0], $ini[1]); |
|
540 | + } else { |
|
541 | + ini_set($ini[0], true); |
|
542 | + } |
|
543 | + break; |
|
544 | + case 'n' : |
|
545 | + $this->values['warningSeverity'] = 0; |
|
546 | + break; |
|
547 | + case 'w' : |
|
548 | + $this->values['warningSeverity'] = null; |
|
549 | + break; |
|
550 | + default: |
|
551 | + if ($this->dieOnUnknownArg === false) { |
|
552 | + $this->values[$arg] = $arg; |
|
553 | + } else { |
|
554 | + $this->processUnknownArgument('-'.$arg, $pos); |
|
555 | + } |
|
556 | 556 | }//end switch |
557 | 557 | |
558 | 558 | }//end processShortArgument() |
@@ -569,290 +569,290 @@ discard block |
||
569 | 569 | public function processLongArgument($arg, $pos) |
570 | 570 | { |
571 | 571 | switch ($arg) { |
572 | - case 'help': |
|
573 | - $this->printUsage(); |
|
574 | - exit(0); |
|
575 | - case 'version': |
|
576 | - echo 'PHP_CodeSniffer version '.PHP_CodeSniffer::VERSION.' ('.PHP_CodeSniffer::STABILITY.') '; |
|
577 | - echo 'by Squiz (http://www.squiz.net)'.PHP_EOL; |
|
578 | - exit(0); |
|
579 | - case 'colors': |
|
580 | - $this->values['colors'] = true; |
|
581 | - break; |
|
582 | - case 'no-colors': |
|
583 | - $this->values['colors'] = false; |
|
584 | - break; |
|
585 | - case 'config-set': |
|
586 | - if (isset($this->_cliArgs[($pos + 1)]) === false |
|
587 | - || isset($this->_cliArgs[($pos + 2)]) === false |
|
588 | - ) { |
|
589 | - echo 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL; |
|
590 | - $this->printUsage(); |
|
591 | - exit(0); |
|
592 | - } |
|
593 | - |
|
594 | - $key = $this->_cliArgs[($pos + 1)]; |
|
595 | - $value = $this->_cliArgs[($pos + 2)]; |
|
596 | - $current = PHP_CodeSniffer::getConfigData($key); |
|
597 | - |
|
598 | - try { |
|
599 | - PHP_CodeSniffer::setConfigData($key, $value); |
|
600 | - } catch (Exception $e) { |
|
601 | - echo $e->getMessage().PHP_EOL; |
|
602 | - exit(2); |
|
603 | - } |
|
604 | - |
|
605 | - if ($current === null) { |
|
606 | - echo "Config value \"$key\" added successfully".PHP_EOL; |
|
607 | - } else { |
|
608 | - echo "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL; |
|
609 | - } |
|
610 | - exit(0); |
|
611 | - case 'config-delete': |
|
612 | - if (isset($this->_cliArgs[($pos + 1)]) === false) { |
|
613 | - echo 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL; |
|
614 | - $this->printUsage(); |
|
615 | - exit(0); |
|
616 | - } |
|
617 | - |
|
618 | - $key = $this->_cliArgs[($pos + 1)]; |
|
619 | - $current = PHP_CodeSniffer::getConfigData($key); |
|
620 | - if ($current === null) { |
|
621 | - echo "Config value \"$key\" has not been set".PHP_EOL; |
|
622 | - } else { |
|
623 | - try { |
|
624 | - PHP_CodeSniffer::setConfigData($key, null); |
|
625 | - } catch (Exception $e) { |
|
626 | - echo $e->getMessage().PHP_EOL; |
|
627 | - exit(2); |
|
628 | - } |
|
629 | - |
|
630 | - echo "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL; |
|
631 | - } |
|
632 | - exit(0); |
|
633 | - case 'config-show': |
|
634 | - $data = PHP_CodeSniffer::getAllConfigData(); |
|
635 | - $this->printConfigData($data); |
|
636 | - exit(0); |
|
637 | - case 'runtime-set': |
|
638 | - if (isset($this->_cliArgs[($pos + 1)]) === false |
|
639 | - || isset($this->_cliArgs[($pos + 2)]) === false |
|
640 | - ) { |
|
641 | - echo 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL; |
|
642 | - $this->printUsage(); |
|
643 | - exit(0); |
|
644 | - } |
|
645 | - |
|
646 | - $key = $this->_cliArgs[($pos + 1)]; |
|
647 | - $value = $this->_cliArgs[($pos + 2)]; |
|
648 | - $this->_cliArgs[($pos + 1)] = ''; |
|
649 | - $this->_cliArgs[($pos + 2)] = ''; |
|
650 | - PHP_CodeSniffer::setConfigData($key, $value, true); |
|
651 | - break; |
|
652 | - default: |
|
653 | - if (substr($arg, 0, 7) === 'sniffs=') { |
|
654 | - $sniffs = explode(',', substr($arg, 7)); |
|
655 | - foreach ($sniffs as $sniff) { |
|
656 | - if (substr_count($sniff, '.') !== 2) { |
|
657 | - echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
658 | - $this->printUsage(); |
|
659 | - exit(2); |
|
660 | - } |
|
661 | - } |
|
662 | - |
|
663 | - $this->values['sniffs'] = $sniffs; |
|
664 | - } else if (substr($arg, 0, 8) === 'exclude=') { |
|
665 | - $sniffs = explode(',', substr($arg, 8)); |
|
666 | - foreach ($sniffs as $sniff) { |
|
667 | - if (substr_count($sniff, '.') !== 2) { |
|
668 | - echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
669 | - $this->printUsage(); |
|
670 | - exit(2); |
|
671 | - } |
|
672 | - } |
|
673 | - |
|
674 | - $this->values['exclude'] = $sniffs; |
|
675 | - } else if (substr($arg, 0, 10) === 'bootstrap=') { |
|
676 | - $files = explode(',', substr($arg, 10)); |
|
677 | - foreach ($files as $file) { |
|
678 | - $path = PHP_CodeSniffer::realpath($file); |
|
679 | - if ($path === false) { |
|
680 | - echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
681 | - $this->printUsage(); |
|
682 | - exit(2); |
|
683 | - } |
|
684 | - |
|
685 | - $this->values['bootstrap'][] = $path; |
|
686 | - } |
|
687 | - } else if (substr($arg, 0, 10) === 'file-list=') { |
|
688 | - $fileList = substr($arg, 10); |
|
689 | - $path = PHP_CodeSniffer::realpath($fileList); |
|
690 | - if ($path === false) { |
|
691 | - echo 'ERROR: The specified file list "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
692 | - $this->printUsage(); |
|
693 | - exit(2); |
|
694 | - } |
|
695 | - |
|
696 | - $files = file($path); |
|
697 | - foreach ($files as $inputFile) { |
|
698 | - $inputFile = trim($inputFile); |
|
699 | - |
|
700 | - // Skip empty lines. |
|
701 | - if ($inputFile === '') { |
|
702 | - continue; |
|
703 | - } |
|
704 | - |
|
705 | - $realFile = PHP_CodeSniffer::realpath($inputFile); |
|
706 | - if ($realFile === false) { |
|
707 | - echo 'ERROR: The specified file "'.$inputFile.'" does not exist'.PHP_EOL.PHP_EOL; |
|
708 | - $this->printUsage(); |
|
709 | - exit(2); |
|
710 | - } |
|
711 | - |
|
712 | - $this->values['files'][] = $realFile; |
|
713 | - } |
|
714 | - } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
715 | - $this->values['stdinPath'] = PHP_CodeSniffer::realpath(substr($arg, 11)); |
|
716 | - |
|
717 | - // It may not exist and return false instead, so just use whatever they gave us. |
|
718 | - if ($this->values['stdinPath'] === false) { |
|
719 | - $this->values['stdinPath'] = trim(substr($arg, 11)); |
|
720 | - } |
|
721 | - } else if (substr($arg, 0, 12) === 'report-file=') { |
|
722 | - $this->values['reportFile'] = PHP_CodeSniffer::realpath(substr($arg, 12)); |
|
723 | - |
|
724 | - // It may not exist and return false instead. |
|
725 | - if ($this->values['reportFile'] === false) { |
|
726 | - $this->values['reportFile'] = substr($arg, 12); |
|
727 | - |
|
728 | - $dir = dirname($this->values['reportFile']); |
|
729 | - if (is_dir($dir) === false) { |
|
730 | - echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
731 | - $this->printUsage(); |
|
732 | - exit(2); |
|
733 | - } |
|
734 | - |
|
735 | - if ($dir === '.') { |
|
736 | - // Passed report file is a file in the current directory. |
|
737 | - $this->values['reportFile'] = getcwd().'/'.basename($this->values['reportFile']); |
|
738 | - } else { |
|
739 | - if ($dir{0} === '/') { |
|
740 | - // An absolute path. |
|
741 | - $dir = PHP_CodeSniffer::realpath($dir); |
|
742 | - } else { |
|
743 | - $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir); |
|
744 | - } |
|
745 | - |
|
746 | - if ($dir !== false) { |
|
747 | - // Report file path is relative. |
|
748 | - $this->values['reportFile'] = $dir.'/'.basename($this->values['reportFile']); |
|
749 | - } |
|
750 | - } |
|
751 | - }//end if |
|
752 | - |
|
753 | - if (is_dir($this->values['reportFile']) === true) { |
|
754 | - echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" is a directory'.PHP_EOL.PHP_EOL; |
|
755 | - $this->printUsage(); |
|
756 | - exit(2); |
|
757 | - } |
|
758 | - } else if (substr($arg, 0, 13) === 'report-width=') { |
|
759 | - $this->values['reportWidth'] = $this->_validateReportWidth(substr($arg, 13)); |
|
760 | - } else if (substr($arg, 0, 7) === 'report=' |
|
761 | - || substr($arg, 0, 7) === 'report-' |
|
762 | - ) { |
|
763 | - if ($arg[6] === '-') { |
|
764 | - // This is a report with file output. |
|
765 | - $split = strpos($arg, '='); |
|
766 | - if ($split === false) { |
|
767 | - $report = substr($arg, 7); |
|
768 | - $output = null; |
|
769 | - } else { |
|
770 | - $report = substr($arg, 7, ($split - 7)); |
|
771 | - $output = substr($arg, ($split + 1)); |
|
772 | - if ($output === false) { |
|
773 | - $output = null; |
|
774 | - } else { |
|
775 | - $dir = dirname($output); |
|
776 | - if ($dir === '.') { |
|
777 | - // Passed report file is a filename in the current directory. |
|
778 | - $output = getcwd().'/'.basename($output); |
|
779 | - } else { |
|
780 | - if ($dir{0} === '/') { |
|
781 | - // An absolute path. |
|
782 | - $dir = PHP_CodeSniffer::realpath($dir); |
|
783 | - } else { |
|
784 | - $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir); |
|
785 | - } |
|
786 | - |
|
787 | - if ($dir !== false) { |
|
788 | - // Report file path is relative. |
|
789 | - $output = $dir.'/'.basename($output); |
|
790 | - } |
|
791 | - } |
|
792 | - }//end if |
|
793 | - }//end if |
|
794 | - } else { |
|
795 | - // This is a single report. |
|
796 | - $report = substr($arg, 7); |
|
797 | - $output = null; |
|
798 | - }//end if |
|
799 | - |
|
800 | - $this->values['reports'][$report] = $output; |
|
801 | - } else if (substr($arg, 0, 9) === 'standard=') { |
|
802 | - $standards = trim(substr($arg, 9)); |
|
803 | - if ($standards !== '') { |
|
804 | - $this->values['standard'] = explode(',', $standards); |
|
805 | - } |
|
806 | - } else if (substr($arg, 0, 11) === 'extensions=') { |
|
807 | - if (isset($this->values['extensions']) === false) { |
|
808 | - $this->values['extensions'] = array(); |
|
809 | - } |
|
810 | - |
|
811 | - $this->values['extensions'] = array_merge($this->values['extensions'], explode(',', substr($arg, 11))); |
|
812 | - } else if (substr($arg, 0, 9) === 'severity=') { |
|
813 | - $this->values['errorSeverity'] = (int) substr($arg, 9); |
|
814 | - $this->values['warningSeverity'] = $this->values['errorSeverity']; |
|
815 | - } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
816 | - $this->values['errorSeverity'] = (int) substr($arg, 15); |
|
817 | - } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
818 | - $this->values['warningSeverity'] = (int) substr($arg, 17); |
|
819 | - } else if (substr($arg, 0, 7) === 'ignore=') { |
|
820 | - // Split the ignore string on commas, unless the comma is escaped |
|
821 | - // using 1 or 3 slashes (\, or \\\,). |
|
822 | - $ignored = preg_split( |
|
823 | - '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
824 | - substr($arg, 7) |
|
825 | - ); |
|
826 | - foreach ($ignored as $pattern) { |
|
827 | - $pattern = trim($pattern); |
|
828 | - if ($pattern === '') { |
|
829 | - continue; |
|
830 | - } |
|
831 | - |
|
832 | - $this->values['ignored'][$pattern] = 'absolute'; |
|
833 | - } |
|
834 | - } else if (substr($arg, 0, 10) === 'generator=') { |
|
835 | - $this->values['generator'] = substr($arg, 10); |
|
836 | - } else if (substr($arg, 0, 9) === 'encoding=') { |
|
837 | - $this->values['encoding'] = strtolower(substr($arg, 9)); |
|
838 | - } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
839 | - $this->values['tabWidth'] = (int) substr($arg, 10); |
|
840 | - } else { |
|
841 | - if ($this->dieOnUnknownArg === false) { |
|
842 | - $eqPos = strpos($arg, '='); |
|
843 | - if ($eqPos === false) { |
|
844 | - $this->values[$arg] = $arg; |
|
845 | - } else { |
|
846 | - $value = substr($arg, ($eqPos + 1)); |
|
847 | - $arg = substr($arg, 0, $eqPos); |
|
848 | - $this->values[$arg] = $value; |
|
849 | - } |
|
850 | - } else { |
|
851 | - $this->processUnknownArgument('--'.$arg, $pos); |
|
852 | - } |
|
853 | - }//end if |
|
854 | - |
|
855 | - break; |
|
572 | + case 'help': |
|
573 | + $this->printUsage(); |
|
574 | + exit(0); |
|
575 | + case 'version': |
|
576 | + echo 'PHP_CodeSniffer version '.PHP_CodeSniffer::VERSION.' ('.PHP_CodeSniffer::STABILITY.') '; |
|
577 | + echo 'by Squiz (http://www.squiz.net)'.PHP_EOL; |
|
578 | + exit(0); |
|
579 | + case 'colors': |
|
580 | + $this->values['colors'] = true; |
|
581 | + break; |
|
582 | + case 'no-colors': |
|
583 | + $this->values['colors'] = false; |
|
584 | + break; |
|
585 | + case 'config-set': |
|
586 | + if (isset($this->_cliArgs[($pos + 1)]) === false |
|
587 | + || isset($this->_cliArgs[($pos + 2)]) === false |
|
588 | + ) { |
|
589 | + echo 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL; |
|
590 | + $this->printUsage(); |
|
591 | + exit(0); |
|
592 | + } |
|
593 | + |
|
594 | + $key = $this->_cliArgs[($pos + 1)]; |
|
595 | + $value = $this->_cliArgs[($pos + 2)]; |
|
596 | + $current = PHP_CodeSniffer::getConfigData($key); |
|
597 | + |
|
598 | + try { |
|
599 | + PHP_CodeSniffer::setConfigData($key, $value); |
|
600 | + } catch (Exception $e) { |
|
601 | + echo $e->getMessage().PHP_EOL; |
|
602 | + exit(2); |
|
603 | + } |
|
604 | + |
|
605 | + if ($current === null) { |
|
606 | + echo "Config value \"$key\" added successfully".PHP_EOL; |
|
607 | + } else { |
|
608 | + echo "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL; |
|
609 | + } |
|
610 | + exit(0); |
|
611 | + case 'config-delete': |
|
612 | + if (isset($this->_cliArgs[($pos + 1)]) === false) { |
|
613 | + echo 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL; |
|
614 | + $this->printUsage(); |
|
615 | + exit(0); |
|
616 | + } |
|
617 | + |
|
618 | + $key = $this->_cliArgs[($pos + 1)]; |
|
619 | + $current = PHP_CodeSniffer::getConfigData($key); |
|
620 | + if ($current === null) { |
|
621 | + echo "Config value \"$key\" has not been set".PHP_EOL; |
|
622 | + } else { |
|
623 | + try { |
|
624 | + PHP_CodeSniffer::setConfigData($key, null); |
|
625 | + } catch (Exception $e) { |
|
626 | + echo $e->getMessage().PHP_EOL; |
|
627 | + exit(2); |
|
628 | + } |
|
629 | + |
|
630 | + echo "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL; |
|
631 | + } |
|
632 | + exit(0); |
|
633 | + case 'config-show': |
|
634 | + $data = PHP_CodeSniffer::getAllConfigData(); |
|
635 | + $this->printConfigData($data); |
|
636 | + exit(0); |
|
637 | + case 'runtime-set': |
|
638 | + if (isset($this->_cliArgs[($pos + 1)]) === false |
|
639 | + || isset($this->_cliArgs[($pos + 2)]) === false |
|
640 | + ) { |
|
641 | + echo 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL; |
|
642 | + $this->printUsage(); |
|
643 | + exit(0); |
|
644 | + } |
|
645 | + |
|
646 | + $key = $this->_cliArgs[($pos + 1)]; |
|
647 | + $value = $this->_cliArgs[($pos + 2)]; |
|
648 | + $this->_cliArgs[($pos + 1)] = ''; |
|
649 | + $this->_cliArgs[($pos + 2)] = ''; |
|
650 | + PHP_CodeSniffer::setConfigData($key, $value, true); |
|
651 | + break; |
|
652 | + default: |
|
653 | + if (substr($arg, 0, 7) === 'sniffs=') { |
|
654 | + $sniffs = explode(',', substr($arg, 7)); |
|
655 | + foreach ($sniffs as $sniff) { |
|
656 | + if (substr_count($sniff, '.') !== 2) { |
|
657 | + echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
658 | + $this->printUsage(); |
|
659 | + exit(2); |
|
660 | + } |
|
661 | + } |
|
662 | + |
|
663 | + $this->values['sniffs'] = $sniffs; |
|
664 | + } else if (substr($arg, 0, 8) === 'exclude=') { |
|
665 | + $sniffs = explode(',', substr($arg, 8)); |
|
666 | + foreach ($sniffs as $sniff) { |
|
667 | + if (substr_count($sniff, '.') !== 2) { |
|
668 | + echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
669 | + $this->printUsage(); |
|
670 | + exit(2); |
|
671 | + } |
|
672 | + } |
|
673 | + |
|
674 | + $this->values['exclude'] = $sniffs; |
|
675 | + } else if (substr($arg, 0, 10) === 'bootstrap=') { |
|
676 | + $files = explode(',', substr($arg, 10)); |
|
677 | + foreach ($files as $file) { |
|
678 | + $path = PHP_CodeSniffer::realpath($file); |
|
679 | + if ($path === false) { |
|
680 | + echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
681 | + $this->printUsage(); |
|
682 | + exit(2); |
|
683 | + } |
|
684 | + |
|
685 | + $this->values['bootstrap'][] = $path; |
|
686 | + } |
|
687 | + } else if (substr($arg, 0, 10) === 'file-list=') { |
|
688 | + $fileList = substr($arg, 10); |
|
689 | + $path = PHP_CodeSniffer::realpath($fileList); |
|
690 | + if ($path === false) { |
|
691 | + echo 'ERROR: The specified file list "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
692 | + $this->printUsage(); |
|
693 | + exit(2); |
|
694 | + } |
|
695 | + |
|
696 | + $files = file($path); |
|
697 | + foreach ($files as $inputFile) { |
|
698 | + $inputFile = trim($inputFile); |
|
699 | + |
|
700 | + // Skip empty lines. |
|
701 | + if ($inputFile === '') { |
|
702 | + continue; |
|
703 | + } |
|
704 | + |
|
705 | + $realFile = PHP_CodeSniffer::realpath($inputFile); |
|
706 | + if ($realFile === false) { |
|
707 | + echo 'ERROR: The specified file "'.$inputFile.'" does not exist'.PHP_EOL.PHP_EOL; |
|
708 | + $this->printUsage(); |
|
709 | + exit(2); |
|
710 | + } |
|
711 | + |
|
712 | + $this->values['files'][] = $realFile; |
|
713 | + } |
|
714 | + } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
715 | + $this->values['stdinPath'] = PHP_CodeSniffer::realpath(substr($arg, 11)); |
|
716 | + |
|
717 | + // It may not exist and return false instead, so just use whatever they gave us. |
|
718 | + if ($this->values['stdinPath'] === false) { |
|
719 | + $this->values['stdinPath'] = trim(substr($arg, 11)); |
|
720 | + } |
|
721 | + } else if (substr($arg, 0, 12) === 'report-file=') { |
|
722 | + $this->values['reportFile'] = PHP_CodeSniffer::realpath(substr($arg, 12)); |
|
723 | + |
|
724 | + // It may not exist and return false instead. |
|
725 | + if ($this->values['reportFile'] === false) { |
|
726 | + $this->values['reportFile'] = substr($arg, 12); |
|
727 | + |
|
728 | + $dir = dirname($this->values['reportFile']); |
|
729 | + if (is_dir($dir) === false) { |
|
730 | + echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
731 | + $this->printUsage(); |
|
732 | + exit(2); |
|
733 | + } |
|
734 | + |
|
735 | + if ($dir === '.') { |
|
736 | + // Passed report file is a file in the current directory. |
|
737 | + $this->values['reportFile'] = getcwd().'/'.basename($this->values['reportFile']); |
|
738 | + } else { |
|
739 | + if ($dir{0} === '/') { |
|
740 | + // An absolute path. |
|
741 | + $dir = PHP_CodeSniffer::realpath($dir); |
|
742 | + } else { |
|
743 | + $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir); |
|
744 | + } |
|
745 | + |
|
746 | + if ($dir !== false) { |
|
747 | + // Report file path is relative. |
|
748 | + $this->values['reportFile'] = $dir.'/'.basename($this->values['reportFile']); |
|
749 | + } |
|
750 | + } |
|
751 | + }//end if |
|
752 | + |
|
753 | + if (is_dir($this->values['reportFile']) === true) { |
|
754 | + echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" is a directory'.PHP_EOL.PHP_EOL; |
|
755 | + $this->printUsage(); |
|
756 | + exit(2); |
|
757 | + } |
|
758 | + } else if (substr($arg, 0, 13) === 'report-width=') { |
|
759 | + $this->values['reportWidth'] = $this->_validateReportWidth(substr($arg, 13)); |
|
760 | + } else if (substr($arg, 0, 7) === 'report=' |
|
761 | + || substr($arg, 0, 7) === 'report-' |
|
762 | + ) { |
|
763 | + if ($arg[6] === '-') { |
|
764 | + // This is a report with file output. |
|
765 | + $split = strpos($arg, '='); |
|
766 | + if ($split === false) { |
|
767 | + $report = substr($arg, 7); |
|
768 | + $output = null; |
|
769 | + } else { |
|
770 | + $report = substr($arg, 7, ($split - 7)); |
|
771 | + $output = substr($arg, ($split + 1)); |
|
772 | + if ($output === false) { |
|
773 | + $output = null; |
|
774 | + } else { |
|
775 | + $dir = dirname($output); |
|
776 | + if ($dir === '.') { |
|
777 | + // Passed report file is a filename in the current directory. |
|
778 | + $output = getcwd().'/'.basename($output); |
|
779 | + } else { |
|
780 | + if ($dir{0} === '/') { |
|
781 | + // An absolute path. |
|
782 | + $dir = PHP_CodeSniffer::realpath($dir); |
|
783 | + } else { |
|
784 | + $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir); |
|
785 | + } |
|
786 | + |
|
787 | + if ($dir !== false) { |
|
788 | + // Report file path is relative. |
|
789 | + $output = $dir.'/'.basename($output); |
|
790 | + } |
|
791 | + } |
|
792 | + }//end if |
|
793 | + }//end if |
|
794 | + } else { |
|
795 | + // This is a single report. |
|
796 | + $report = substr($arg, 7); |
|
797 | + $output = null; |
|
798 | + }//end if |
|
799 | + |
|
800 | + $this->values['reports'][$report] = $output; |
|
801 | + } else if (substr($arg, 0, 9) === 'standard=') { |
|
802 | + $standards = trim(substr($arg, 9)); |
|
803 | + if ($standards !== '') { |
|
804 | + $this->values['standard'] = explode(',', $standards); |
|
805 | + } |
|
806 | + } else if (substr($arg, 0, 11) === 'extensions=') { |
|
807 | + if (isset($this->values['extensions']) === false) { |
|
808 | + $this->values['extensions'] = array(); |
|
809 | + } |
|
810 | + |
|
811 | + $this->values['extensions'] = array_merge($this->values['extensions'], explode(',', substr($arg, 11))); |
|
812 | + } else if (substr($arg, 0, 9) === 'severity=') { |
|
813 | + $this->values['errorSeverity'] = (int) substr($arg, 9); |
|
814 | + $this->values['warningSeverity'] = $this->values['errorSeverity']; |
|
815 | + } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
816 | + $this->values['errorSeverity'] = (int) substr($arg, 15); |
|
817 | + } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
818 | + $this->values['warningSeverity'] = (int) substr($arg, 17); |
|
819 | + } else if (substr($arg, 0, 7) === 'ignore=') { |
|
820 | + // Split the ignore string on commas, unless the comma is escaped |
|
821 | + // using 1 or 3 slashes (\, or \\\,). |
|
822 | + $ignored = preg_split( |
|
823 | + '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
824 | + substr($arg, 7) |
|
825 | + ); |
|
826 | + foreach ($ignored as $pattern) { |
|
827 | + $pattern = trim($pattern); |
|
828 | + if ($pattern === '') { |
|
829 | + continue; |
|
830 | + } |
|
831 | + |
|
832 | + $this->values['ignored'][$pattern] = 'absolute'; |
|
833 | + } |
|
834 | + } else if (substr($arg, 0, 10) === 'generator=') { |
|
835 | + $this->values['generator'] = substr($arg, 10); |
|
836 | + } else if (substr($arg, 0, 9) === 'encoding=') { |
|
837 | + $this->values['encoding'] = strtolower(substr($arg, 9)); |
|
838 | + } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
839 | + $this->values['tabWidth'] = (int) substr($arg, 10); |
|
840 | + } else { |
|
841 | + if ($this->dieOnUnknownArg === false) { |
|
842 | + $eqPos = strpos($arg, '='); |
|
843 | + if ($eqPos === false) { |
|
844 | + $this->values[$arg] = $arg; |
|
845 | + } else { |
|
846 | + $value = substr($arg, ($eqPos + 1)); |
|
847 | + $arg = substr($arg, 0, $eqPos); |
|
848 | + $this->values[$arg] = $value; |
|
849 | + } |
|
850 | + } else { |
|
851 | + $this->processUnknownArgument('--'.$arg, $pos); |
|
852 | + } |
|
853 | + }//end if |
|
854 | + |
|
855 | + break; |
|
856 | 856 | }//end switch |
857 | 857 | |
858 | 858 | }//end processLongArgument() |
@@ -1707,60 +1707,60 @@ discard block |
||
1707 | 1707 | */ |
1708 | 1708 | |
1709 | 1709 | switch ($tokens[$i]['code']) { |
1710 | - case T_OPEN_SQUARE_BRACKET: |
|
1711 | - $squareOpeners[] = $i; |
|
1712 | - |
|
1713 | - if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
1714 | - echo str_repeat("\t", count($squareOpeners)); |
|
1715 | - echo str_repeat("\t", count($curlyOpeners)); |
|
1716 | - echo "=> Found square bracket opener at $i".PHP_EOL; |
|
1717 | - } |
|
1718 | - break; |
|
1719 | - case T_OPEN_CURLY_BRACKET: |
|
1720 | - if (isset($tokens[$i]['scope_closer']) === false) { |
|
1721 | - $curlyOpeners[] = $i; |
|
1722 | - |
|
1723 | - if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
1724 | - echo str_repeat("\t", count($squareOpeners)); |
|
1725 | - echo str_repeat("\t", count($curlyOpeners)); |
|
1726 | - echo "=> Found curly bracket opener at $i".PHP_EOL; |
|
1727 | - } |
|
1728 | - } |
|
1729 | - break; |
|
1730 | - case T_CLOSE_SQUARE_BRACKET: |
|
1731 | - if (empty($squareOpeners) === false) { |
|
1732 | - $opener = array_pop($squareOpeners); |
|
1733 | - $tokens[$i]['bracket_opener'] = $opener; |
|
1734 | - $tokens[$i]['bracket_closer'] = $i; |
|
1735 | - $tokens[$opener]['bracket_opener'] = $opener; |
|
1736 | - $tokens[$opener]['bracket_closer'] = $i; |
|
1737 | - |
|
1738 | - if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
1739 | - echo str_repeat("\t", count($squareOpeners)); |
|
1740 | - echo str_repeat("\t", count($curlyOpeners)); |
|
1741 | - echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL; |
|
1742 | - } |
|
1743 | - } |
|
1744 | - break; |
|
1745 | - case T_CLOSE_CURLY_BRACKET: |
|
1746 | - if (empty($curlyOpeners) === false |
|
1747 | - && isset($tokens[$i]['scope_opener']) === false |
|
1748 | - ) { |
|
1749 | - $opener = array_pop($curlyOpeners); |
|
1750 | - $tokens[$i]['bracket_opener'] = $opener; |
|
1751 | - $tokens[$i]['bracket_closer'] = $i; |
|
1752 | - $tokens[$opener]['bracket_opener'] = $opener; |
|
1753 | - $tokens[$opener]['bracket_closer'] = $i; |
|
1754 | - |
|
1755 | - if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
1756 | - echo str_repeat("\t", count($squareOpeners)); |
|
1757 | - echo str_repeat("\t", count($curlyOpeners)); |
|
1758 | - echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL; |
|
1759 | - } |
|
1760 | - } |
|
1761 | - break; |
|
1762 | - default: |
|
1763 | - continue; |
|
1710 | + case T_OPEN_SQUARE_BRACKET: |
|
1711 | + $squareOpeners[] = $i; |
|
1712 | + |
|
1713 | + if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
1714 | + echo str_repeat("\t", count($squareOpeners)); |
|
1715 | + echo str_repeat("\t", count($curlyOpeners)); |
|
1716 | + echo "=> Found square bracket opener at $i".PHP_EOL; |
|
1717 | + } |
|
1718 | + break; |
|
1719 | + case T_OPEN_CURLY_BRACKET: |
|
1720 | + if (isset($tokens[$i]['scope_closer']) === false) { |
|
1721 | + $curlyOpeners[] = $i; |
|
1722 | + |
|
1723 | + if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
1724 | + echo str_repeat("\t", count($squareOpeners)); |
|
1725 | + echo str_repeat("\t", count($curlyOpeners)); |
|
1726 | + echo "=> Found curly bracket opener at $i".PHP_EOL; |
|
1727 | + } |
|
1728 | + } |
|
1729 | + break; |
|
1730 | + case T_CLOSE_SQUARE_BRACKET: |
|
1731 | + if (empty($squareOpeners) === false) { |
|
1732 | + $opener = array_pop($squareOpeners); |
|
1733 | + $tokens[$i]['bracket_opener'] = $opener; |
|
1734 | + $tokens[$i]['bracket_closer'] = $i; |
|
1735 | + $tokens[$opener]['bracket_opener'] = $opener; |
|
1736 | + $tokens[$opener]['bracket_closer'] = $i; |
|
1737 | + |
|
1738 | + if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
1739 | + echo str_repeat("\t", count($squareOpeners)); |
|
1740 | + echo str_repeat("\t", count($curlyOpeners)); |
|
1741 | + echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL; |
|
1742 | + } |
|
1743 | + } |
|
1744 | + break; |
|
1745 | + case T_CLOSE_CURLY_BRACKET: |
|
1746 | + if (empty($curlyOpeners) === false |
|
1747 | + && isset($tokens[$i]['scope_opener']) === false |
|
1748 | + ) { |
|
1749 | + $opener = array_pop($curlyOpeners); |
|
1750 | + $tokens[$i]['bracket_opener'] = $opener; |
|
1751 | + $tokens[$i]['bracket_closer'] = $i; |
|
1752 | + $tokens[$opener]['bracket_opener'] = $opener; |
|
1753 | + $tokens[$opener]['bracket_closer'] = $i; |
|
1754 | + |
|
1755 | + if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
1756 | + echo str_repeat("\t", count($squareOpeners)); |
|
1757 | + echo str_repeat("\t", count($curlyOpeners)); |
|
1758 | + echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL; |
|
1759 | + } |
|
1760 | + } |
|
1761 | + break; |
|
1762 | + default: |
|
1763 | + continue; |
|
1764 | 1764 | }//end switch |
1765 | 1765 | }//end for |
1766 | 1766 | |
@@ -2790,88 +2790,88 @@ discard block |
||
2790 | 2790 | } |
2791 | 2791 | |
2792 | 2792 | switch ($this->_tokens[$i]['code']) { |
2793 | - case T_BITWISE_AND: |
|
2794 | - $passByReference = true; |
|
2795 | - break; |
|
2796 | - case T_VARIABLE: |
|
2797 | - $currVar = $i; |
|
2798 | - break; |
|
2799 | - case T_ELLIPSIS: |
|
2800 | - $variableLength = true; |
|
2801 | - break; |
|
2802 | - case T_ARRAY_HINT: |
|
2803 | - case T_CALLABLE: |
|
2804 | - $typeHint = $this->_tokens[$i]['content']; |
|
2805 | - break; |
|
2806 | - case T_STRING: |
|
2807 | - // This is a string, so it may be a type hint, but it could |
|
2808 | - // also be a constant used as a default value. |
|
2809 | - $prevComma = false; |
|
2810 | - for ($t = $i; $t >= $opener; $t--) { |
|
2811 | - if ($this->_tokens[$t]['code'] === T_COMMA) { |
|
2812 | - $prevComma = $t; |
|
2813 | - break; |
|
2814 | - } |
|
2815 | - } |
|
2816 | - |
|
2817 | - if ($prevComma !== false) { |
|
2818 | - $nextEquals = false; |
|
2819 | - for ($t = $prevComma; $t < $i; $t++) { |
|
2820 | - if ($this->_tokens[$t]['code'] === T_EQUAL) { |
|
2821 | - $nextEquals = $t; |
|
2822 | - break; |
|
2823 | - } |
|
2824 | - } |
|
2825 | - |
|
2826 | - if ($nextEquals !== false) { |
|
2827 | - break; |
|
2828 | - } |
|
2829 | - } |
|
2830 | - |
|
2831 | - if ($defaultStart === null) { |
|
2832 | - $typeHint .= $this->_tokens[$i]['content']; |
|
2833 | - } |
|
2834 | - break; |
|
2835 | - case T_NS_SEPARATOR: |
|
2836 | - // Part of a type hint or default value. |
|
2837 | - if ($defaultStart === null) { |
|
2838 | - $typeHint .= $this->_tokens[$i]['content']; |
|
2839 | - } |
|
2840 | - break; |
|
2841 | - case T_CLOSE_PARENTHESIS: |
|
2842 | - case T_COMMA: |
|
2843 | - // If it's null, then there must be no parameters for this |
|
2844 | - // method. |
|
2845 | - if ($currVar === null) { |
|
2846 | - continue; |
|
2847 | - } |
|
2848 | - |
|
2849 | - $vars[$paramCount] = array(); |
|
2850 | - $vars[$paramCount]['name'] = $this->_tokens[$currVar]['content']; |
|
2851 | - |
|
2852 | - if ($defaultStart !== null) { |
|
2853 | - $vars[$paramCount]['default'] |
|
2854 | - = $this->getTokensAsString( |
|
2855 | - $defaultStart, |
|
2856 | - ($i - $defaultStart) |
|
2857 | - ); |
|
2858 | - } |
|
2859 | - |
|
2860 | - $vars[$paramCount]['pass_by_reference'] = $passByReference; |
|
2861 | - $vars[$paramCount]['variable_length'] = $variableLength; |
|
2862 | - $vars[$paramCount]['type_hint'] = $typeHint; |
|
2863 | - |
|
2864 | - // Reset the vars, as we are about to process the next parameter. |
|
2865 | - $defaultStart = null; |
|
2866 | - $passByReference = false; |
|
2867 | - $variableLength = false; |
|
2868 | - $typeHint = ''; |
|
2869 | - |
|
2870 | - $paramCount++; |
|
2871 | - break; |
|
2872 | - case T_EQUAL: |
|
2873 | - $defaultStart = ($i + 1); |
|
2874 | - break; |
|
2793 | + case T_BITWISE_AND: |
|
2794 | + $passByReference = true; |
|
2795 | + break; |
|
2796 | + case T_VARIABLE: |
|
2797 | + $currVar = $i; |
|
2798 | + break; |
|
2799 | + case T_ELLIPSIS: |
|
2800 | + $variableLength = true; |
|
2801 | + break; |
|
2802 | + case T_ARRAY_HINT: |
|
2803 | + case T_CALLABLE: |
|
2804 | + $typeHint = $this->_tokens[$i]['content']; |
|
2805 | + break; |
|
2806 | + case T_STRING: |
|
2807 | + // This is a string, so it may be a type hint, but it could |
|
2808 | + // also be a constant used as a default value. |
|
2809 | + $prevComma = false; |
|
2810 | + for ($t = $i; $t >= $opener; $t--) { |
|
2811 | + if ($this->_tokens[$t]['code'] === T_COMMA) { |
|
2812 | + $prevComma = $t; |
|
2813 | + break; |
|
2814 | + } |
|
2815 | + } |
|
2816 | + |
|
2817 | + if ($prevComma !== false) { |
|
2818 | + $nextEquals = false; |
|
2819 | + for ($t = $prevComma; $t < $i; $t++) { |
|
2820 | + if ($this->_tokens[$t]['code'] === T_EQUAL) { |
|
2821 | + $nextEquals = $t; |
|
2822 | + break; |
|
2823 | + } |
|
2824 | + } |
|
2825 | + |
|
2826 | + if ($nextEquals !== false) { |
|
2827 | + break; |
|
2828 | + } |
|
2829 | + } |
|
2830 | + |
|
2831 | + if ($defaultStart === null) { |
|
2832 | + $typeHint .= $this->_tokens[$i]['content']; |
|
2833 | + } |
|
2834 | + break; |
|
2835 | + case T_NS_SEPARATOR: |
|
2836 | + // Part of a type hint or default value. |
|
2837 | + if ($defaultStart === null) { |
|
2838 | + $typeHint .= $this->_tokens[$i]['content']; |
|
2839 | + } |
|
2840 | + break; |
|
2841 | + case T_CLOSE_PARENTHESIS: |
|
2842 | + case T_COMMA: |
|
2843 | + // If it's null, then there must be no parameters for this |
|
2844 | + // method. |
|
2845 | + if ($currVar === null) { |
|
2846 | + continue; |
|
2847 | + } |
|
2848 | + |
|
2849 | + $vars[$paramCount] = array(); |
|
2850 | + $vars[$paramCount]['name'] = $this->_tokens[$currVar]['content']; |
|
2851 | + |
|
2852 | + if ($defaultStart !== null) { |
|
2853 | + $vars[$paramCount]['default'] |
|
2854 | + = $this->getTokensAsString( |
|
2855 | + $defaultStart, |
|
2856 | + ($i - $defaultStart) |
|
2857 | + ); |
|
2858 | + } |
|
2859 | + |
|
2860 | + $vars[$paramCount]['pass_by_reference'] = $passByReference; |
|
2861 | + $vars[$paramCount]['variable_length'] = $variableLength; |
|
2862 | + $vars[$paramCount]['type_hint'] = $typeHint; |
|
2863 | + |
|
2864 | + // Reset the vars, as we are about to process the next parameter. |
|
2865 | + $defaultStart = null; |
|
2866 | + $passByReference = false; |
|
2867 | + $variableLength = false; |
|
2868 | + $typeHint = ''; |
|
2869 | + |
|
2870 | + $paramCount++; |
|
2871 | + break; |
|
2872 | + case T_EQUAL: |
|
2873 | + $defaultStart = ($i + 1); |
|
2874 | + break; |
|
2875 | 2875 | }//end switch |
2876 | 2876 | }//end for |
2877 | 2877 | |
@@ -2933,27 +2933,27 @@ discard block |
||
2933 | 2933 | } |
2934 | 2934 | |
2935 | 2935 | switch ($this->_tokens[$i]['code']) { |
2936 | - case T_PUBLIC: |
|
2937 | - $scope = 'public'; |
|
2938 | - $scopeSpecified = true; |
|
2939 | - break; |
|
2940 | - case T_PRIVATE: |
|
2941 | - $scope = 'private'; |
|
2942 | - $scopeSpecified = true; |
|
2943 | - break; |
|
2944 | - case T_PROTECTED: |
|
2945 | - $scope = 'protected'; |
|
2946 | - $scopeSpecified = true; |
|
2947 | - break; |
|
2948 | - case T_ABSTRACT: |
|
2949 | - $isAbstract = true; |
|
2950 | - break; |
|
2951 | - case T_FINAL: |
|
2952 | - $isFinal = true; |
|
2953 | - break; |
|
2954 | - case T_STATIC: |
|
2955 | - $isStatic = true; |
|
2956 | - break; |
|
2936 | + case T_PUBLIC: |
|
2937 | + $scope = 'public'; |
|
2938 | + $scopeSpecified = true; |
|
2939 | + break; |
|
2940 | + case T_PRIVATE: |
|
2941 | + $scope = 'private'; |
|
2942 | + $scopeSpecified = true; |
|
2943 | + break; |
|
2944 | + case T_PROTECTED: |
|
2945 | + $scope = 'protected'; |
|
2946 | + $scopeSpecified = true; |
|
2947 | + break; |
|
2948 | + case T_ABSTRACT: |
|
2949 | + $isAbstract = true; |
|
2950 | + break; |
|
2951 | + case T_FINAL: |
|
2952 | + $isFinal = true; |
|
2953 | + break; |
|
2954 | + case T_STATIC: |
|
2955 | + $isStatic = true; |
|
2956 | + break; |
|
2957 | 2957 | }//end switch |
2958 | 2958 | }//end for |
2959 | 2959 | |
@@ -3043,21 +3043,21 @@ discard block |
||
3043 | 3043 | } |
3044 | 3044 | |
3045 | 3045 | switch ($this->_tokens[$i]['code']) { |
3046 | - case T_PUBLIC: |
|
3047 | - $scope = 'public'; |
|
3048 | - $scopeSpecified = true; |
|
3049 | - break; |
|
3050 | - case T_PRIVATE: |
|
3051 | - $scope = 'private'; |
|
3052 | - $scopeSpecified = true; |
|
3053 | - break; |
|
3054 | - case T_PROTECTED: |
|
3055 | - $scope = 'protected'; |
|
3056 | - $scopeSpecified = true; |
|
3057 | - break; |
|
3058 | - case T_STATIC: |
|
3059 | - $isStatic = true; |
|
3060 | - break; |
|
3046 | + case T_PUBLIC: |
|
3047 | + $scope = 'public'; |
|
3048 | + $scopeSpecified = true; |
|
3049 | + break; |
|
3050 | + case T_PRIVATE: |
|
3051 | + $scope = 'private'; |
|
3052 | + $scopeSpecified = true; |
|
3053 | + break; |
|
3054 | + case T_PROTECTED: |
|
3055 | + $scope = 'protected'; |
|
3056 | + $scopeSpecified = true; |
|
3057 | + break; |
|
3058 | + case T_STATIC: |
|
3059 | + $isStatic = true; |
|
3060 | + break; |
|
3061 | 3061 | } |
3062 | 3062 | }//end for |
3063 | 3063 | |
@@ -3111,13 +3111,13 @@ discard block |
||
3111 | 3111 | } |
3112 | 3112 | |
3113 | 3113 | switch ($this->_tokens[$i]['code']) { |
3114 | - case T_ABSTRACT: |
|
3115 | - $isAbstract = true; |
|
3116 | - break; |
|
3114 | + case T_ABSTRACT: |
|
3115 | + $isAbstract = true; |
|
3116 | + break; |
|
3117 | 3117 | |
3118 | - case T_FINAL: |
|
3119 | - $isFinal = true; |
|
3120 | - break; |
|
3118 | + case T_FINAL: |
|
3119 | + $isFinal = true; |
|
3120 | + break; |
|
3121 | 3121 | } |
3122 | 3122 | }//end for |
3123 | 3123 |
@@ -283,14 +283,14 @@ |
||
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 | } |
@@ -1456,24 +1456,24 @@ discard block |
||
1456 | 1456 | |
1457 | 1457 | if ($token[0] === T_STRING) { |
1458 | 1458 | switch ($cacheKey) { |
1459 | - case 'false': |
|
1460 | - $newToken['type'] = 'T_FALSE'; |
|
1461 | - break; |
|
1462 | - case 'true': |
|
1463 | - $newToken['type'] = 'T_TRUE'; |
|
1464 | - break; |
|
1465 | - case 'null': |
|
1466 | - $newToken['type'] = 'T_NULL'; |
|
1467 | - break; |
|
1468 | - case 'self': |
|
1469 | - $newToken['type'] = 'T_SELF'; |
|
1470 | - break; |
|
1471 | - case 'parent': |
|
1472 | - $newToken['type'] = 'T_PARENT'; |
|
1473 | - break; |
|
1474 | - default: |
|
1475 | - $newToken['type'] = 'T_STRING'; |
|
1476 | - break; |
|
1459 | + case 'false': |
|
1460 | + $newToken['type'] = 'T_FALSE'; |
|
1461 | + break; |
|
1462 | + case 'true': |
|
1463 | + $newToken['type'] = 'T_TRUE'; |
|
1464 | + break; |
|
1465 | + case 'null': |
|
1466 | + $newToken['type'] = 'T_NULL'; |
|
1467 | + break; |
|
1468 | + case 'self': |
|
1469 | + $newToken['type'] = 'T_SELF'; |
|
1470 | + break; |
|
1471 | + case 'parent': |
|
1472 | + $newToken['type'] = 'T_PARENT'; |
|
1473 | + break; |
|
1474 | + default: |
|
1475 | + $newToken['type'] = 'T_STRING'; |
|
1476 | + break; |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | $newToken['code'] = constant($newToken['type']); |
@@ -1515,87 +1515,87 @@ discard block |
||
1515 | 1515 | $newToken = array(); |
1516 | 1516 | |
1517 | 1517 | switch ($token) { |
1518 | - case '{': |
|
1519 | - $newToken['type'] = 'T_OPEN_CURLY_BRACKET'; |
|
1520 | - break; |
|
1521 | - case '}': |
|
1522 | - $newToken['type'] = 'T_CLOSE_CURLY_BRACKET'; |
|
1523 | - break; |
|
1524 | - case '[': |
|
1525 | - $newToken['type'] = 'T_OPEN_SQUARE_BRACKET'; |
|
1526 | - break; |
|
1527 | - case ']': |
|
1528 | - $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET'; |
|
1529 | - break; |
|
1530 | - case '(': |
|
1531 | - $newToken['type'] = 'T_OPEN_PARENTHESIS'; |
|
1532 | - break; |
|
1533 | - case ')': |
|
1534 | - $newToken['type'] = 'T_CLOSE_PARENTHESIS'; |
|
1535 | - break; |
|
1536 | - case ':': |
|
1537 | - $newToken['type'] = 'T_COLON'; |
|
1538 | - break; |
|
1539 | - case '.': |
|
1540 | - $newToken['type'] = 'T_STRING_CONCAT'; |
|
1541 | - break; |
|
1542 | - case '?': |
|
1543 | - $newToken['type'] = 'T_INLINE_THEN'; |
|
1544 | - break; |
|
1545 | - case ';': |
|
1546 | - $newToken['type'] = 'T_SEMICOLON'; |
|
1547 | - break; |
|
1548 | - case '=': |
|
1549 | - $newToken['type'] = 'T_EQUAL'; |
|
1550 | - break; |
|
1551 | - case '*': |
|
1552 | - $newToken['type'] = 'T_MULTIPLY'; |
|
1553 | - break; |
|
1554 | - case '/': |
|
1555 | - $newToken['type'] = 'T_DIVIDE'; |
|
1556 | - break; |
|
1557 | - case '+': |
|
1558 | - $newToken['type'] = 'T_PLUS'; |
|
1559 | - break; |
|
1560 | - case '-': |
|
1561 | - $newToken['type'] = 'T_MINUS'; |
|
1562 | - break; |
|
1563 | - case '%': |
|
1564 | - $newToken['type'] = 'T_MODULUS'; |
|
1565 | - break; |
|
1566 | - case '^': |
|
1567 | - $newToken['type'] = 'T_BITWISE_XOR'; |
|
1568 | - break; |
|
1569 | - case '&': |
|
1570 | - $newToken['type'] = 'T_BITWISE_AND'; |
|
1571 | - break; |
|
1572 | - case '|': |
|
1573 | - $newToken['type'] = 'T_BITWISE_OR'; |
|
1574 | - break; |
|
1575 | - case '<': |
|
1576 | - $newToken['type'] = 'T_LESS_THAN'; |
|
1577 | - break; |
|
1578 | - case '>': |
|
1579 | - $newToken['type'] = 'T_GREATER_THAN'; |
|
1580 | - break; |
|
1581 | - case '!': |
|
1582 | - $newToken['type'] = 'T_BOOLEAN_NOT'; |
|
1583 | - break; |
|
1584 | - case ',': |
|
1585 | - $newToken['type'] = 'T_COMMA'; |
|
1586 | - break; |
|
1587 | - case '@': |
|
1588 | - $newToken['type'] = 'T_ASPERAND'; |
|
1589 | - break; |
|
1590 | - case '$': |
|
1591 | - $newToken['type'] = 'T_DOLLAR'; |
|
1592 | - break; |
|
1593 | - case '`': |
|
1594 | - $newToken['type'] = 'T_BACKTICK'; |
|
1595 | - break; |
|
1596 | - default: |
|
1597 | - $newToken['type'] = 'T_NONE'; |
|
1598 | - break; |
|
1518 | + case '{': |
|
1519 | + $newToken['type'] = 'T_OPEN_CURLY_BRACKET'; |
|
1520 | + break; |
|
1521 | + case '}': |
|
1522 | + $newToken['type'] = 'T_CLOSE_CURLY_BRACKET'; |
|
1523 | + break; |
|
1524 | + case '[': |
|
1525 | + $newToken['type'] = 'T_OPEN_SQUARE_BRACKET'; |
|
1526 | + break; |
|
1527 | + case ']': |
|
1528 | + $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET'; |
|
1529 | + break; |
|
1530 | + case '(': |
|
1531 | + $newToken['type'] = 'T_OPEN_PARENTHESIS'; |
|
1532 | + break; |
|
1533 | + case ')': |
|
1534 | + $newToken['type'] = 'T_CLOSE_PARENTHESIS'; |
|
1535 | + break; |
|
1536 | + case ':': |
|
1537 | + $newToken['type'] = 'T_COLON'; |
|
1538 | + break; |
|
1539 | + case '.': |
|
1540 | + $newToken['type'] = 'T_STRING_CONCAT'; |
|
1541 | + break; |
|
1542 | + case '?': |
|
1543 | + $newToken['type'] = 'T_INLINE_THEN'; |
|
1544 | + break; |
|
1545 | + case ';': |
|
1546 | + $newToken['type'] = 'T_SEMICOLON'; |
|
1547 | + break; |
|
1548 | + case '=': |
|
1549 | + $newToken['type'] = 'T_EQUAL'; |
|
1550 | + break; |
|
1551 | + case '*': |
|
1552 | + $newToken['type'] = 'T_MULTIPLY'; |
|
1553 | + break; |
|
1554 | + case '/': |
|
1555 | + $newToken['type'] = 'T_DIVIDE'; |
|
1556 | + break; |
|
1557 | + case '+': |
|
1558 | + $newToken['type'] = 'T_PLUS'; |
|
1559 | + break; |
|
1560 | + case '-': |
|
1561 | + $newToken['type'] = 'T_MINUS'; |
|
1562 | + break; |
|
1563 | + case '%': |
|
1564 | + $newToken['type'] = 'T_MODULUS'; |
|
1565 | + break; |
|
1566 | + case '^': |
|
1567 | + $newToken['type'] = 'T_BITWISE_XOR'; |
|
1568 | + break; |
|
1569 | + case '&': |
|
1570 | + $newToken['type'] = 'T_BITWISE_AND'; |
|
1571 | + break; |
|
1572 | + case '|': |
|
1573 | + $newToken['type'] = 'T_BITWISE_OR'; |
|
1574 | + break; |
|
1575 | + case '<': |
|
1576 | + $newToken['type'] = 'T_LESS_THAN'; |
|
1577 | + break; |
|
1578 | + case '>': |
|
1579 | + $newToken['type'] = 'T_GREATER_THAN'; |
|
1580 | + break; |
|
1581 | + case '!': |
|
1582 | + $newToken['type'] = 'T_BOOLEAN_NOT'; |
|
1583 | + break; |
|
1584 | + case ',': |
|
1585 | + $newToken['type'] = 'T_COMMA'; |
|
1586 | + break; |
|
1587 | + case '@': |
|
1588 | + $newToken['type'] = 'T_ASPERAND'; |
|
1589 | + break; |
|
1590 | + case '$': |
|
1591 | + $newToken['type'] = 'T_DOLLAR'; |
|
1592 | + break; |
|
1593 | + case '`': |
|
1594 | + $newToken['type'] = 'T_BACKTICK'; |
|
1595 | + break; |
|
1596 | + default: |
|
1597 | + $newToken['type'] = 'T_NONE'; |
|
1598 | + break; |
|
1599 | 1599 | }//end switch |
1600 | 1600 | |
1601 | 1601 | $newToken['code'] = constant($newToken['type']); |