@@ -1,3 +1,1 @@ |
||
1 | 1 | <?php |
2 | -/** Why me? |
|
3 | - |
@@ -28,18 +28,18 @@ |
||
28 | 28 | public function getErrorList($testFile='') |
29 | 29 | { |
30 | 30 | switch ($testFile) { |
31 | - case 'ClosingTagUnitTest.1.inc': |
|
32 | - return [11 => 1]; |
|
31 | + case 'ClosingTagUnitTest.1.inc': |
|
32 | + return [11 => 1]; |
|
33 | 33 | |
34 | - case 'ClosingTagUnitTest.4.inc': |
|
35 | - case 'ClosingTagUnitTest.5.inc': |
|
36 | - return [1 => 1]; |
|
34 | + case 'ClosingTagUnitTest.4.inc': |
|
35 | + case 'ClosingTagUnitTest.5.inc': |
|
36 | + return [1 => 1]; |
|
37 | 37 | |
38 | - case 'ClosingTagUnitTest.6.inc': |
|
39 | - return [5 => 1]; |
|
38 | + case 'ClosingTagUnitTest.6.inc': |
|
39 | + return [5 => 1]; |
|
40 | 40 | |
41 | - default: |
|
42 | - return []; |
|
41 | + default: |
|
42 | + return []; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | }//end getErrorList() |
@@ -1,2 +1,1 @@ |
||
1 | 1 | <?php |
2 | -/** Why me? |
@@ -1,2 +1,1 @@ |
||
1 | 1 | <?php |
2 | -/** Why me? |
|
3 | 2 | \ No newline at end of file |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | switch ($foo) { |
37 | - case'Foo': { |
|
38 | - echo 'foo'; |
|
39 | - break; |
|
40 | - } |
|
37 | + case'Foo': { |
|
38 | + echo 'foo'; |
|
39 | + break; |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | while ($i < 10) { |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | switch (true) { |
55 | - case is_resource($value): |
|
56 | - throw new Exception('foo'); |
|
57 | - case is_object($value): |
|
58 | - return 'object'; |
|
55 | + case is_resource($value): |
|
56 | + throw new Exception('foo'); |
|
57 | + case is_object($value): |
|
58 | + return 'object'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | switch (0) { |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | switch ($foo) { |
108 | - case 1: $bar = 1; break; |
|
109 | - case 2: |
|
108 | + case 1: $bar = 1; break; |
|
109 | + case 2: |
|
110 | 110 | |
111 | - $bar = 2; break; |
|
112 | - case 21: |
|
113 | - case 3: return 3; |
|
114 | - default: $bar = 0; |
|
111 | + $bar = 2; break; |
|
112 | + case 21: |
|
113 | + case 3: return 3; |
|
114 | + default: $bar = 0; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | switch ($foo) { |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | switch ($foo) { |
149 | - case Foo::INTERFACE: |
|
150 | - return self::INTERFACE; |
|
151 | - case Foo::NAMESPACE: |
|
152 | - return self::MODULE; |
|
153 | - case Foo::TRAIT: |
|
154 | - case Foo::ARRAY: |
|
155 | - return self::VALUE; |
|
149 | + case Foo::INTERFACE: |
|
150 | + return self::INTERFACE; |
|
151 | + case Foo::NAMESPACE: |
|
152 | + return self::MODULE; |
|
153 | + case Foo::TRAIT: |
|
154 | + case Foo::ARRAY: |
|
155 | + return self::VALUE; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // OK: Every clause terminates |
@@ -217,38 +217,38 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | switch ($name) { |
220 | - case 'reportWidth' : |
|
221 | - // Support auto terminal width. |
|
222 | - if ($value === 'auto' |
|
223 | - && function_exists('shell_exec') === true |
|
224 | - && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1 |
|
225 | - ) { |
|
226 | - $value = (int) $matches[1]; |
|
227 | - } else { |
|
228 | - $value = (int) $value; |
|
229 | - } |
|
230 | - break; |
|
231 | - case 'standards' : |
|
232 | - $cleaned = []; |
|
233 | - |
|
234 | - // Check if the standard name is valid, or if the case is invalid. |
|
235 | - $installedStandards = Util\Standards::getInstalledStandards(); |
|
236 | - foreach ($value as $standard) { |
|
237 | - foreach ($installedStandards as $validStandard) { |
|
238 | - if (strtolower($standard) === strtolower($validStandard)) { |
|
239 | - $standard = $validStandard; |
|
240 | - break; |
|
241 | - } |
|
220 | + case 'reportWidth' : |
|
221 | + // Support auto terminal width. |
|
222 | + if ($value === 'auto' |
|
223 | + && function_exists('shell_exec') === true |
|
224 | + && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1 |
|
225 | + ) { |
|
226 | + $value = (int) $matches[1]; |
|
227 | + } else { |
|
228 | + $value = (int) $value; |
|
242 | 229 | } |
230 | + break; |
|
231 | + case 'standards' : |
|
232 | + $cleaned = []; |
|
233 | + |
|
234 | + // Check if the standard name is valid, or if the case is invalid. |
|
235 | + $installedStandards = Util\Standards::getInstalledStandards(); |
|
236 | + foreach ($value as $standard) { |
|
237 | + foreach ($installedStandards as $validStandard) { |
|
238 | + if (strtolower($standard) === strtolower($validStandard)) { |
|
239 | + $standard = $validStandard; |
|
240 | + break; |
|
241 | + } |
|
242 | + } |
|
243 | 243 | |
244 | - $cleaned[] = $standard; |
|
245 | - } |
|
244 | + $cleaned[] = $standard; |
|
245 | + } |
|
246 | 246 | |
247 | - $value = $cleaned; |
|
248 | - break; |
|
249 | - default : |
|
250 | - // No validation required. |
|
251 | - break; |
|
247 | + $value = $cleaned; |
|
248 | + break; |
|
249 | + default : |
|
250 | + // No validation required. |
|
251 | + break; |
|
252 | 252 | }//end switch |
253 | 253 | |
254 | 254 | $this->settings[$name] = $value; |
@@ -592,94 +592,94 @@ discard block |
||
592 | 592 | public function processShortArgument($arg, $pos) |
593 | 593 | { |
594 | 594 | switch ($arg) { |
595 | - case 'h': |
|
596 | - case '?': |
|
597 | - ob_start(); |
|
598 | - $this->printUsage(); |
|
599 | - $output = ob_get_contents(); |
|
600 | - ob_end_clean(); |
|
601 | - throw new DeepExitException($output, 0); |
|
602 | - case 'i' : |
|
603 | - ob_start(); |
|
604 | - Util\Standards::printInstalledStandards(); |
|
605 | - $output = ob_get_contents(); |
|
606 | - ob_end_clean(); |
|
607 | - throw new DeepExitException($output, 0); |
|
608 | - case 'v' : |
|
609 | - if ($this->quiet === true) { |
|
610 | - // Ignore when quiet mode is enabled. |
|
595 | + case 'h': |
|
596 | + case '?': |
|
597 | + ob_start(); |
|
598 | + $this->printUsage(); |
|
599 | + $output = ob_get_contents(); |
|
600 | + ob_end_clean(); |
|
601 | + throw new DeepExitException($output, 0); |
|
602 | + case 'i' : |
|
603 | + ob_start(); |
|
604 | + Util\Standards::printInstalledStandards(); |
|
605 | + $output = ob_get_contents(); |
|
606 | + ob_end_clean(); |
|
607 | + throw new DeepExitException($output, 0); |
|
608 | + case 'v' : |
|
609 | + if ($this->quiet === true) { |
|
610 | + // Ignore when quiet mode is enabled. |
|
611 | + break; |
|
612 | + } |
|
613 | + |
|
614 | + $this->verbosity++; |
|
615 | + self::$overriddenDefaults['verbosity'] = true; |
|
611 | 616 | break; |
612 | - } |
|
617 | + case 'l' : |
|
618 | + $this->local = true; |
|
619 | + self::$overriddenDefaults['local'] = true; |
|
620 | + break; |
|
621 | + case 's' : |
|
622 | + $this->showSources = true; |
|
623 | + self::$overriddenDefaults['showSources'] = true; |
|
624 | + break; |
|
625 | + case 'a' : |
|
626 | + $this->interactive = true; |
|
627 | + self::$overriddenDefaults['interactive'] = true; |
|
628 | + break; |
|
629 | + case 'e': |
|
630 | + $this->explain = true; |
|
631 | + self::$overriddenDefaults['explain'] = true; |
|
632 | + break; |
|
633 | + case 'p' : |
|
634 | + if ($this->quiet === true) { |
|
635 | + // Ignore when quiet mode is enabled. |
|
636 | + break; |
|
637 | + } |
|
613 | 638 | |
614 | - $this->verbosity++; |
|
615 | - self::$overriddenDefaults['verbosity'] = true; |
|
616 | - break; |
|
617 | - case 'l' : |
|
618 | - $this->local = true; |
|
619 | - self::$overriddenDefaults['local'] = true; |
|
620 | - break; |
|
621 | - case 's' : |
|
622 | - $this->showSources = true; |
|
623 | - self::$overriddenDefaults['showSources'] = true; |
|
624 | - break; |
|
625 | - case 'a' : |
|
626 | - $this->interactive = true; |
|
627 | - self::$overriddenDefaults['interactive'] = true; |
|
628 | - break; |
|
629 | - case 'e': |
|
630 | - $this->explain = true; |
|
631 | - self::$overriddenDefaults['explain'] = true; |
|
632 | - break; |
|
633 | - case 'p' : |
|
634 | - if ($this->quiet === true) { |
|
635 | - // Ignore when quiet mode is enabled. |
|
639 | + $this->showProgress = true; |
|
640 | + self::$overriddenDefaults['showProgress'] = true; |
|
636 | 641 | break; |
637 | - } |
|
642 | + case 'q' : |
|
643 | + // Quiet mode disables a few other settings as well. |
|
644 | + $this->quiet = true; |
|
645 | + $this->showProgress = false; |
|
646 | + $this->verbosity = 0; |
|
638 | 647 | |
639 | - $this->showProgress = true; |
|
640 | - self::$overriddenDefaults['showProgress'] = true; |
|
641 | - break; |
|
642 | - case 'q' : |
|
643 | - // Quiet mode disables a few other settings as well. |
|
644 | - $this->quiet = true; |
|
645 | - $this->showProgress = false; |
|
646 | - $this->verbosity = 0; |
|
647 | - |
|
648 | - self::$overriddenDefaults['quiet'] = true; |
|
649 | - break; |
|
650 | - case 'm' : |
|
651 | - $this->recordErrors = false; |
|
652 | - self::$overriddenDefaults['recordErrors'] = true; |
|
653 | - break; |
|
654 | - case 'd' : |
|
655 | - $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
656 | - $this->cliArgs[($pos + 1)] = ''; |
|
657 | - if (isset($ini[1]) === true) { |
|
658 | - ini_set($ini[0], $ini[1]); |
|
659 | - } else { |
|
660 | - ini_set($ini[0], true); |
|
661 | - } |
|
662 | - break; |
|
663 | - case 'n' : |
|
664 | - if (isset(self::$overriddenDefaults['warningSeverity']) === false) { |
|
665 | - $this->warningSeverity = 0; |
|
666 | - self::$overriddenDefaults['warningSeverity'] = true; |
|
667 | - } |
|
668 | - break; |
|
669 | - case 'w' : |
|
670 | - if (isset(self::$overriddenDefaults['warningSeverity']) === false) { |
|
671 | - $this->warningSeverity = $this->errorSeverity; |
|
672 | - self::$overriddenDefaults['warningSeverity'] = true; |
|
673 | - } |
|
674 | - break; |
|
675 | - default: |
|
676 | - if ($this->dieOnUnknownArg === false) { |
|
677 | - $unknown = $this->unknown; |
|
678 | - $unknown[] = $arg; |
|
679 | - $this->unknown = $unknown; |
|
680 | - } else { |
|
681 | - $this->processUnknownArgument('-'.$arg, $pos); |
|
682 | - } |
|
648 | + self::$overriddenDefaults['quiet'] = true; |
|
649 | + break; |
|
650 | + case 'm' : |
|
651 | + $this->recordErrors = false; |
|
652 | + self::$overriddenDefaults['recordErrors'] = true; |
|
653 | + break; |
|
654 | + case 'd' : |
|
655 | + $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
656 | + $this->cliArgs[($pos + 1)] = ''; |
|
657 | + if (isset($ini[1]) === true) { |
|
658 | + ini_set($ini[0], $ini[1]); |
|
659 | + } else { |
|
660 | + ini_set($ini[0], true); |
|
661 | + } |
|
662 | + break; |
|
663 | + case 'n' : |
|
664 | + if (isset(self::$overriddenDefaults['warningSeverity']) === false) { |
|
665 | + $this->warningSeverity = 0; |
|
666 | + self::$overriddenDefaults['warningSeverity'] = true; |
|
667 | + } |
|
668 | + break; |
|
669 | + case 'w' : |
|
670 | + if (isset(self::$overriddenDefaults['warningSeverity']) === false) { |
|
671 | + $this->warningSeverity = $this->errorSeverity; |
|
672 | + self::$overriddenDefaults['warningSeverity'] = true; |
|
673 | + } |
|
674 | + break; |
|
675 | + default: |
|
676 | + if ($this->dieOnUnknownArg === false) { |
|
677 | + $unknown = $this->unknown; |
|
678 | + $unknown[] = $arg; |
|
679 | + $this->unknown = $unknown; |
|
680 | + } else { |
|
681 | + $this->processUnknownArgument('-'.$arg, $pos); |
|
682 | + } |
|
683 | 683 | }//end switch |
684 | 684 | |
685 | 685 | }//end processShortArgument() |
@@ -697,525 +697,525 @@ discard block |
||
697 | 697 | public function processLongArgument($arg, $pos) |
698 | 698 | { |
699 | 699 | switch ($arg) { |
700 | - case 'help': |
|
701 | - ob_start(); |
|
702 | - $this->printUsage(); |
|
703 | - $output = ob_get_contents(); |
|
704 | - ob_end_clean(); |
|
705 | - throw new DeepExitException($output, 0); |
|
706 | - case 'version': |
|
707 | - $output = 'PHP_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') '; |
|
708 | - $output .= 'by Squiz (http://www.squiz.net)'.PHP_EOL; |
|
709 | - throw new DeepExitException($output, 0); |
|
710 | - case 'colors': |
|
711 | - if (isset(self::$overriddenDefaults['colors']) === true) { |
|
700 | + case 'help': |
|
701 | + ob_start(); |
|
702 | + $this->printUsage(); |
|
703 | + $output = ob_get_contents(); |
|
704 | + ob_end_clean(); |
|
705 | + throw new DeepExitException($output, 0); |
|
706 | + case 'version': |
|
707 | + $output = 'PHP_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') '; |
|
708 | + $output .= 'by Squiz (http://www.squiz.net)'.PHP_EOL; |
|
709 | + throw new DeepExitException($output, 0); |
|
710 | + case 'colors': |
|
711 | + if (isset(self::$overriddenDefaults['colors']) === true) { |
|
712 | + break; |
|
713 | + } |
|
714 | + |
|
715 | + $this->colors = true; |
|
716 | + self::$overriddenDefaults['colors'] = true; |
|
712 | 717 | break; |
713 | - } |
|
718 | + case 'no-colors': |
|
719 | + if (isset(self::$overriddenDefaults['colors']) === true) { |
|
720 | + break; |
|
721 | + } |
|
714 | 722 | |
715 | - $this->colors = true; |
|
716 | - self::$overriddenDefaults['colors'] = true; |
|
717 | - break; |
|
718 | - case 'no-colors': |
|
719 | - if (isset(self::$overriddenDefaults['colors']) === true) { |
|
723 | + $this->colors = false; |
|
724 | + self::$overriddenDefaults['colors'] = true; |
|
720 | 725 | break; |
721 | - } |
|
726 | + case 'cache': |
|
727 | + if (isset(self::$overriddenDefaults['cache']) === true) { |
|
728 | + break; |
|
729 | + } |
|
722 | 730 | |
723 | - $this->colors = false; |
|
724 | - self::$overriddenDefaults['colors'] = true; |
|
725 | - break; |
|
726 | - case 'cache': |
|
727 | - if (isset(self::$overriddenDefaults['cache']) === true) { |
|
731 | + if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { |
|
732 | + $this->cache = true; |
|
733 | + self::$overriddenDefaults['cache'] = true; |
|
734 | + } |
|
728 | 735 | break; |
729 | - } |
|
736 | + case 'no-cache': |
|
737 | + if (isset(self::$overriddenDefaults['cache']) === true) { |
|
738 | + break; |
|
739 | + } |
|
730 | 740 | |
731 | - if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { |
|
732 | - $this->cache = true; |
|
741 | + $this->cache = false; |
|
733 | 742 | self::$overriddenDefaults['cache'] = true; |
734 | - } |
|
735 | - break; |
|
736 | - case 'no-cache': |
|
737 | - if (isset(self::$overriddenDefaults['cache']) === true) { |
|
738 | 743 | break; |
739 | - } |
|
744 | + case 'ignore-annotations': |
|
745 | + if (isset(self::$overriddenDefaults['annotations']) === true) { |
|
746 | + break; |
|
747 | + } |
|
740 | 748 | |
741 | - $this->cache = false; |
|
742 | - self::$overriddenDefaults['cache'] = true; |
|
743 | - break; |
|
744 | - case 'ignore-annotations': |
|
745 | - if (isset(self::$overriddenDefaults['annotations']) === true) { |
|
749 | + $this->annotations = false; |
|
750 | + self::$overriddenDefaults['annotations'] = true; |
|
746 | 751 | break; |
747 | - } |
|
748 | - |
|
749 | - $this->annotations = false; |
|
750 | - self::$overriddenDefaults['annotations'] = true; |
|
751 | - break; |
|
752 | - case 'config-set': |
|
753 | - if (isset($this->cliArgs[($pos + 1)]) === false |
|
754 | - || isset($this->cliArgs[($pos + 2)]) === false |
|
755 | - ) { |
|
756 | - $error = 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL; |
|
757 | - $error .= $this->printShortUsage(true); |
|
758 | - throw new DeepExitException($error, 3); |
|
759 | - } |
|
760 | - |
|
761 | - $key = $this->cliArgs[($pos + 1)]; |
|
762 | - $value = $this->cliArgs[($pos + 2)]; |
|
763 | - $current = self::getConfigData($key); |
|
764 | - |
|
765 | - try { |
|
766 | - $this->setConfigData($key, $value); |
|
767 | - } catch (\Exception $e) { |
|
768 | - throw new DeepExitException($e->getMessage().PHP_EOL, 3); |
|
769 | - } |
|
770 | - |
|
771 | - $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL; |
|
772 | - |
|
773 | - if ($current === null) { |
|
774 | - $output .= "Config value \"$key\" added successfully".PHP_EOL; |
|
775 | - } else { |
|
776 | - $output .= "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL; |
|
777 | - } |
|
778 | - throw new DeepExitException($output, 0); |
|
779 | - case 'config-delete': |
|
780 | - if (isset($this->cliArgs[($pos + 1)]) === false) { |
|
781 | - $error = 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL; |
|
782 | - $error .= $this->printShortUsage(true); |
|
783 | - throw new DeepExitException($error, 3); |
|
784 | - } |
|
752 | + case 'config-set': |
|
753 | + if (isset($this->cliArgs[($pos + 1)]) === false |
|
754 | + || isset($this->cliArgs[($pos + 2)]) === false |
|
755 | + ) { |
|
756 | + $error = 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL; |
|
757 | + $error .= $this->printShortUsage(true); |
|
758 | + throw new DeepExitException($error, 3); |
|
759 | + } |
|
785 | 760 | |
786 | - $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL; |
|
761 | + $key = $this->cliArgs[($pos + 1)]; |
|
762 | + $value = $this->cliArgs[($pos + 2)]; |
|
763 | + $current = self::getConfigData($key); |
|
787 | 764 | |
788 | - $key = $this->cliArgs[($pos + 1)]; |
|
789 | - $current = self::getConfigData($key); |
|
790 | - if ($current === null) { |
|
791 | - $output .= "Config value \"$key\" has not been set".PHP_EOL; |
|
792 | - } else { |
|
793 | 765 | try { |
794 | - $this->setConfigData($key, null); |
|
766 | + $this->setConfigData($key, $value); |
|
795 | 767 | } catch (\Exception $e) { |
796 | 768 | throw new DeepExitException($e->getMessage().PHP_EOL, 3); |
797 | 769 | } |
798 | 770 | |
799 | - $output .= "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL; |
|
800 | - } |
|
801 | - throw new DeepExitException($output, 0); |
|
802 | - case 'config-show': |
|
803 | - ob_start(); |
|
804 | - $data = self::getAllConfigData(); |
|
805 | - echo 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL; |
|
806 | - $this->printConfigData($data); |
|
807 | - $output = ob_get_contents(); |
|
808 | - ob_end_clean(); |
|
809 | - throw new DeepExitException($output, 0); |
|
810 | - case 'runtime-set': |
|
811 | - if (isset($this->cliArgs[($pos + 1)]) === false |
|
812 | - || isset($this->cliArgs[($pos + 2)]) === false |
|
813 | - ) { |
|
814 | - $error = 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL; |
|
815 | - $error .= $this->printShortUsage(true); |
|
816 | - throw new DeepExitException($error, 3); |
|
817 | - } |
|
818 | - |
|
819 | - $key = $this->cliArgs[($pos + 1)]; |
|
820 | - $value = $this->cliArgs[($pos + 2)]; |
|
821 | - $this->cliArgs[($pos + 1)] = ''; |
|
822 | - $this->cliArgs[($pos + 2)] = ''; |
|
823 | - self::setConfigData($key, $value, true); |
|
824 | - if (isset(self::$overriddenDefaults['runtime-set']) === false) { |
|
825 | - self::$overriddenDefaults['runtime-set'] = []; |
|
826 | - } |
|
771 | + $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL; |
|
827 | 772 | |
828 | - self::$overriddenDefaults['runtime-set'][$key] = true; |
|
829 | - break; |
|
830 | - default: |
|
831 | - if (substr($arg, 0, 7) === 'sniffs=') { |
|
832 | - if (isset(self::$overriddenDefaults['sniffs']) === true) { |
|
833 | - break; |
|
773 | + if ($current === null) { |
|
774 | + $output .= "Config value \"$key\" added successfully".PHP_EOL; |
|
775 | + } else { |
|
776 | + $output .= "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL; |
|
777 | + } |
|
778 | + throw new DeepExitException($output, 0); |
|
779 | + case 'config-delete': |
|
780 | + if (isset($this->cliArgs[($pos + 1)]) === false) { |
|
781 | + $error = 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL; |
|
782 | + $error .= $this->printShortUsage(true); |
|
783 | + throw new DeepExitException($error, 3); |
|
834 | 784 | } |
835 | 785 | |
836 | - $sniffs = explode(',', substr($arg, 7)); |
|
837 | - foreach ($sniffs as $sniff) { |
|
838 | - if (substr_count($sniff, '.') !== 2) { |
|
839 | - $error = 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
840 | - $error .= $this->printShortUsage(true); |
|
841 | - throw new DeepExitException($error, 3); |
|
786 | + $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL; |
|
787 | + |
|
788 | + $key = $this->cliArgs[($pos + 1)]; |
|
789 | + $current = self::getConfigData($key); |
|
790 | + if ($current === null) { |
|
791 | + $output .= "Config value \"$key\" has not been set".PHP_EOL; |
|
792 | + } else { |
|
793 | + try { |
|
794 | + $this->setConfigData($key, null); |
|
795 | + } catch (\Exception $e) { |
|
796 | + throw new DeepExitException($e->getMessage().PHP_EOL, 3); |
|
842 | 797 | } |
798 | + |
|
799 | + $output .= "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL; |
|
800 | + } |
|
801 | + throw new DeepExitException($output, 0); |
|
802 | + case 'config-show': |
|
803 | + ob_start(); |
|
804 | + $data = self::getAllConfigData(); |
|
805 | + echo 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL; |
|
806 | + $this->printConfigData($data); |
|
807 | + $output = ob_get_contents(); |
|
808 | + ob_end_clean(); |
|
809 | + throw new DeepExitException($output, 0); |
|
810 | + case 'runtime-set': |
|
811 | + if (isset($this->cliArgs[($pos + 1)]) === false |
|
812 | + || isset($this->cliArgs[($pos + 2)]) === false |
|
813 | + ) { |
|
814 | + $error = 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL; |
|
815 | + $error .= $this->printShortUsage(true); |
|
816 | + throw new DeepExitException($error, 3); |
|
843 | 817 | } |
844 | 818 | |
845 | - $this->sniffs = $sniffs; |
|
846 | - self::$overriddenDefaults['sniffs'] = true; |
|
847 | - } else if (substr($arg, 0, 8) === 'exclude=') { |
|
848 | - if (isset(self::$overriddenDefaults['exclude']) === true) { |
|
849 | - break; |
|
819 | + $key = $this->cliArgs[($pos + 1)]; |
|
820 | + $value = $this->cliArgs[($pos + 2)]; |
|
821 | + $this->cliArgs[($pos + 1)] = ''; |
|
822 | + $this->cliArgs[($pos + 2)] = ''; |
|
823 | + self::setConfigData($key, $value, true); |
|
824 | + if (isset(self::$overriddenDefaults['runtime-set']) === false) { |
|
825 | + self::$overriddenDefaults['runtime-set'] = []; |
|
850 | 826 | } |
851 | 827 | |
852 | - $sniffs = explode(',', substr($arg, 8)); |
|
853 | - foreach ($sniffs as $sniff) { |
|
854 | - if (substr_count($sniff, '.') !== 2) { |
|
855 | - $error = 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
856 | - $error .= $this->printShortUsage(true); |
|
857 | - throw new DeepExitException($error, 3); |
|
828 | + self::$overriddenDefaults['runtime-set'][$key] = true; |
|
829 | + break; |
|
830 | + default: |
|
831 | + if (substr($arg, 0, 7) === 'sniffs=') { |
|
832 | + if (isset(self::$overriddenDefaults['sniffs']) === true) { |
|
833 | + break; |
|
858 | 834 | } |
859 | - } |
|
860 | 835 | |
861 | - $this->exclude = $sniffs; |
|
862 | - self::$overriddenDefaults['exclude'] = true; |
|
863 | - } else if (defined('PHP_CODESNIFFER_IN_TESTS') === false |
|
864 | - && substr($arg, 0, 6) === 'cache=' |
|
865 | - ) { |
|
866 | - if ((isset(self::$overriddenDefaults['cache']) === true |
|
867 | - && $this->cache === false) |
|
868 | - || isset(self::$overriddenDefaults['cacheFile']) === true |
|
836 | + $sniffs = explode(',', substr($arg, 7)); |
|
837 | + foreach ($sniffs as $sniff) { |
|
838 | + if (substr_count($sniff, '.') !== 2) { |
|
839 | + $error = 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
840 | + $error .= $this->printShortUsage(true); |
|
841 | + throw new DeepExitException($error, 3); |
|
842 | + } |
|
843 | + } |
|
844 | + |
|
845 | + $this->sniffs = $sniffs; |
|
846 | + self::$overriddenDefaults['sniffs'] = true; |
|
847 | + } else if (substr($arg, 0, 8) === 'exclude=') { |
|
848 | + if (isset(self::$overriddenDefaults['exclude']) === true) { |
|
849 | + break; |
|
850 | + } |
|
851 | + |
|
852 | + $sniffs = explode(',', substr($arg, 8)); |
|
853 | + foreach ($sniffs as $sniff) { |
|
854 | + if (substr_count($sniff, '.') !== 2) { |
|
855 | + $error = 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
856 | + $error .= $this->printShortUsage(true); |
|
857 | + throw new DeepExitException($error, 3); |
|
858 | + } |
|
859 | + } |
|
860 | + |
|
861 | + $this->exclude = $sniffs; |
|
862 | + self::$overriddenDefaults['exclude'] = true; |
|
863 | + } else if (defined('PHP_CODESNIFFER_IN_TESTS') === false |
|
864 | + && substr($arg, 0, 6) === 'cache=' |
|
869 | 865 | ) { |
870 | - break; |
|
871 | - } |
|
866 | + if ((isset(self::$overriddenDefaults['cache']) === true |
|
867 | + && $this->cache === false) |
|
868 | + || isset(self::$overriddenDefaults['cacheFile']) === true |
|
869 | + ) { |
|
870 | + break; |
|
871 | + } |
|
872 | 872 | |
873 | - // Turn caching on. |
|
874 | - $this->cache = true; |
|
875 | - self::$overriddenDefaults['cache'] = true; |
|
873 | + // Turn caching on. |
|
874 | + $this->cache = true; |
|
875 | + self::$overriddenDefaults['cache'] = true; |
|
876 | 876 | |
877 | - $this->cacheFile = Util\Common::realpath(substr($arg, 6)); |
|
877 | + $this->cacheFile = Util\Common::realpath(substr($arg, 6)); |
|
878 | 878 | |
879 | - // It may not exist and return false instead. |
|
880 | - if ($this->cacheFile === false) { |
|
881 | - $this->cacheFile = substr($arg, 6); |
|
879 | + // It may not exist and return false instead. |
|
880 | + if ($this->cacheFile === false) { |
|
881 | + $this->cacheFile = substr($arg, 6); |
|
882 | 882 | |
883 | - $dir = dirname($this->cacheFile); |
|
884 | - if (is_dir($dir) === false) { |
|
885 | - $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
886 | - $error .= $this->printShortUsage(true); |
|
887 | - throw new DeepExitException($error, 3); |
|
888 | - } |
|
883 | + $dir = dirname($this->cacheFile); |
|
884 | + if (is_dir($dir) === false) { |
|
885 | + $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
886 | + $error .= $this->printShortUsage(true); |
|
887 | + throw new DeepExitException($error, 3); |
|
888 | + } |
|
889 | 889 | |
890 | - if ($dir === '.') { |
|
891 | - // Passed cache file is a file in the current directory. |
|
892 | - $this->cacheFile = getcwd().'/'.basename($this->cacheFile); |
|
893 | - } else { |
|
894 | - if ($dir[0] === '/') { |
|
895 | - // An absolute path. |
|
896 | - $dir = Util\Common::realpath($dir); |
|
890 | + if ($dir === '.') { |
|
891 | + // Passed cache file is a file in the current directory. |
|
892 | + $this->cacheFile = getcwd().'/'.basename($this->cacheFile); |
|
897 | 893 | } else { |
898 | - $dir = Util\Common::realpath(getcwd().'/'.$dir); |
|
899 | - } |
|
894 | + if ($dir[0] === '/') { |
|
895 | + // An absolute path. |
|
896 | + $dir = Util\Common::realpath($dir); |
|
897 | + } else { |
|
898 | + $dir = Util\Common::realpath(getcwd().'/'.$dir); |
|
899 | + } |
|
900 | 900 | |
901 | - if ($dir !== false) { |
|
902 | - // Cache file path is relative. |
|
903 | - $this->cacheFile = $dir.'/'.basename($this->cacheFile); |
|
901 | + if ($dir !== false) { |
|
902 | + // Cache file path is relative. |
|
903 | + $this->cacheFile = $dir.'/'.basename($this->cacheFile); |
|
904 | + } |
|
904 | 905 | } |
906 | + }//end if |
|
907 | + |
|
908 | + self::$overriddenDefaults['cacheFile'] = true; |
|
909 | + |
|
910 | + if (is_dir($this->cacheFile) === true) { |
|
911 | + $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" is a directory'.PHP_EOL.PHP_EOL; |
|
912 | + $error .= $this->printShortUsage(true); |
|
913 | + throw new DeepExitException($error, 3); |
|
905 | 914 | } |
906 | - }//end if |
|
915 | + } else if (substr($arg, 0, 10) === 'bootstrap=') { |
|
916 | + $files = explode(',', substr($arg, 10)); |
|
917 | + $bootstrap = []; |
|
918 | + foreach ($files as $file) { |
|
919 | + $path = Util\Common::realpath($file); |
|
920 | + if ($path === false) { |
|
921 | + $error = 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
922 | + $error .= $this->printShortUsage(true); |
|
923 | + throw new DeepExitException($error, 3); |
|
924 | + } |
|
907 | 925 | |
908 | - self::$overriddenDefaults['cacheFile'] = true; |
|
926 | + $bootstrap[] = $path; |
|
927 | + } |
|
909 | 928 | |
910 | - if (is_dir($this->cacheFile) === true) { |
|
911 | - $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" is a directory'.PHP_EOL.PHP_EOL; |
|
912 | - $error .= $this->printShortUsage(true); |
|
913 | - throw new DeepExitException($error, 3); |
|
914 | - } |
|
915 | - } else if (substr($arg, 0, 10) === 'bootstrap=') { |
|
916 | - $files = explode(',', substr($arg, 10)); |
|
917 | - $bootstrap = []; |
|
918 | - foreach ($files as $file) { |
|
919 | - $path = Util\Common::realpath($file); |
|
929 | + $this->bootstrap = array_merge($this->bootstrap, $bootstrap); |
|
930 | + self::$overriddenDefaults['bootstrap'] = true; |
|
931 | + } else if (substr($arg, 0, 10) === 'file-list=') { |
|
932 | + $fileList = substr($arg, 10); |
|
933 | + $path = Util\Common::realpath($fileList); |
|
920 | 934 | if ($path === false) { |
921 | - $error = 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
935 | + $error = 'ERROR: The specified file list "'.$fileList.'" does not exist'.PHP_EOL.PHP_EOL; |
|
922 | 936 | $error .= $this->printShortUsage(true); |
923 | 937 | throw new DeepExitException($error, 3); |
924 | 938 | } |
925 | 939 | |
926 | - $bootstrap[] = $path; |
|
927 | - } |
|
940 | + $files = file($path); |
|
941 | + foreach ($files as $inputFile) { |
|
942 | + $inputFile = trim($inputFile); |
|
928 | 943 | |
929 | - $this->bootstrap = array_merge($this->bootstrap, $bootstrap); |
|
930 | - self::$overriddenDefaults['bootstrap'] = true; |
|
931 | - } else if (substr($arg, 0, 10) === 'file-list=') { |
|
932 | - $fileList = substr($arg, 10); |
|
933 | - $path = Util\Common::realpath($fileList); |
|
934 | - if ($path === false) { |
|
935 | - $error = 'ERROR: The specified file list "'.$fileList.'" does not exist'.PHP_EOL.PHP_EOL; |
|
936 | - $error .= $this->printShortUsage(true); |
|
937 | - throw new DeepExitException($error, 3); |
|
938 | - } |
|
944 | + // Skip empty lines. |
|
945 | + if ($inputFile === '') { |
|
946 | + continue; |
|
947 | + } |
|
939 | 948 | |
940 | - $files = file($path); |
|
941 | - foreach ($files as $inputFile) { |
|
942 | - $inputFile = trim($inputFile); |
|
949 | + $this->processFilePath($inputFile); |
|
950 | + } |
|
951 | + } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
952 | + if (isset(self::$overriddenDefaults['stdinPath']) === true) { |
|
953 | + break; |
|
954 | + } |
|
943 | 955 | |
944 | - // Skip empty lines. |
|
945 | - if ($inputFile === '') { |
|
946 | - continue; |
|
956 | + $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
957 | + |
|
958 | + // It may not exist and return false instead, so use whatever they gave us. |
|
959 | + if ($this->stdinPath === false) { |
|
960 | + $this->stdinPath = trim(substr($arg, 11)); |
|
947 | 961 | } |
948 | 962 | |
949 | - $this->processFilePath($inputFile); |
|
950 | - } |
|
951 | - } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
952 | - if (isset(self::$overriddenDefaults['stdinPath']) === true) { |
|
953 | - break; |
|
954 | - } |
|
963 | + self::$overriddenDefaults['stdinPath'] = true; |
|
964 | + } else if (PHP_CODESNIFFER_CBF === false && substr($arg, 0, 12) === 'report-file=') { |
|
965 | + if (isset(self::$overriddenDefaults['reportFile']) === true) { |
|
966 | + break; |
|
967 | + } |
|
955 | 968 | |
956 | - $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
969 | + $this->reportFile = Util\Common::realpath(substr($arg, 12)); |
|
957 | 970 | |
958 | - // It may not exist and return false instead, so use whatever they gave us. |
|
959 | - if ($this->stdinPath === false) { |
|
960 | - $this->stdinPath = trim(substr($arg, 11)); |
|
961 | - } |
|
971 | + // It may not exist and return false instead. |
|
972 | + if ($this->reportFile === false) { |
|
973 | + $this->reportFile = substr($arg, 12); |
|
962 | 974 | |
963 | - self::$overriddenDefaults['stdinPath'] = true; |
|
964 | - } else if (PHP_CODESNIFFER_CBF === false && substr($arg, 0, 12) === 'report-file=') { |
|
965 | - if (isset(self::$overriddenDefaults['reportFile']) === true) { |
|
966 | - break; |
|
967 | - } |
|
975 | + $dir = Util\Common::realpath(dirname($this->reportFile)); |
|
976 | + if (is_dir($dir) === false) { |
|
977 | + $error = 'ERROR: The specified report file path "'.$this->reportFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
978 | + $error .= $this->printShortUsage(true); |
|
979 | + throw new DeepExitException($error, 3); |
|
980 | + } |
|
968 | 981 | |
969 | - $this->reportFile = Util\Common::realpath(substr($arg, 12)); |
|
982 | + $this->reportFile = $dir.'/'.basename($this->reportFile); |
|
983 | + }//end if |
|
970 | 984 | |
971 | - // It may not exist and return false instead. |
|
972 | - if ($this->reportFile === false) { |
|
973 | - $this->reportFile = substr($arg, 12); |
|
985 | + self::$overriddenDefaults['reportFile'] = true; |
|
974 | 986 | |
975 | - $dir = Util\Common::realpath(dirname($this->reportFile)); |
|
976 | - if (is_dir($dir) === false) { |
|
977 | - $error = 'ERROR: The specified report file path "'.$this->reportFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
987 | + if (is_dir($this->reportFile) === true) { |
|
988 | + $error = 'ERROR: The specified report file path "'.$this->reportFile.'" is a directory'.PHP_EOL.PHP_EOL; |
|
978 | 989 | $error .= $this->printShortUsage(true); |
979 | 990 | throw new DeepExitException($error, 3); |
980 | 991 | } |
992 | + } else if (substr($arg, 0, 13) === 'report-width=') { |
|
993 | + if (isset(self::$overriddenDefaults['reportWidth']) === true) { |
|
994 | + break; |
|
995 | + } |
|
981 | 996 | |
982 | - $this->reportFile = $dir.'/'.basename($this->reportFile); |
|
983 | - }//end if |
|
984 | - |
|
985 | - self::$overriddenDefaults['reportFile'] = true; |
|
986 | - |
|
987 | - if (is_dir($this->reportFile) === true) { |
|
988 | - $error = 'ERROR: The specified report file path "'.$this->reportFile.'" is a directory'.PHP_EOL.PHP_EOL; |
|
989 | - $error .= $this->printShortUsage(true); |
|
990 | - throw new DeepExitException($error, 3); |
|
991 | - } |
|
992 | - } else if (substr($arg, 0, 13) === 'report-width=') { |
|
993 | - if (isset(self::$overriddenDefaults['reportWidth']) === true) { |
|
994 | - break; |
|
995 | - } |
|
996 | - |
|
997 | - $this->reportWidth = substr($arg, 13); |
|
998 | - self::$overriddenDefaults['reportWidth'] = true; |
|
999 | - } else if (substr($arg, 0, 9) === 'basepath=') { |
|
1000 | - if (isset(self::$overriddenDefaults['basepath']) === true) { |
|
1001 | - break; |
|
1002 | - } |
|
997 | + $this->reportWidth = substr($arg, 13); |
|
998 | + self::$overriddenDefaults['reportWidth'] = true; |
|
999 | + } else if (substr($arg, 0, 9) === 'basepath=') { |
|
1000 | + if (isset(self::$overriddenDefaults['basepath']) === true) { |
|
1001 | + break; |
|
1002 | + } |
|
1003 | 1003 | |
1004 | - self::$overriddenDefaults['basepath'] = true; |
|
1004 | + self::$overriddenDefaults['basepath'] = true; |
|
1005 | 1005 | |
1006 | - if (substr($arg, 9) === '') { |
|
1007 | - $this->basepath = null; |
|
1008 | - break; |
|
1009 | - } |
|
1006 | + if (substr($arg, 9) === '') { |
|
1007 | + $this->basepath = null; |
|
1008 | + break; |
|
1009 | + } |
|
1010 | 1010 | |
1011 | - $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
1011 | + $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
1012 | 1012 | |
1013 | - // It may not exist and return false instead. |
|
1014 | - if ($this->basepath === false) { |
|
1015 | - $this->basepath = substr($arg, 9); |
|
1016 | - } |
|
1013 | + // It may not exist and return false instead. |
|
1014 | + if ($this->basepath === false) { |
|
1015 | + $this->basepath = substr($arg, 9); |
|
1016 | + } |
|
1017 | 1017 | |
1018 | - if (is_dir($this->basepath) === false) { |
|
1019 | - $error = 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
1020 | - $error .= $this->printShortUsage(true); |
|
1021 | - throw new DeepExitException($error, 3); |
|
1022 | - } |
|
1023 | - } else if ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) { |
|
1024 | - $reports = []; |
|
1025 | - |
|
1026 | - if ($arg[6] === '-') { |
|
1027 | - // This is a report with file output. |
|
1028 | - $split = strpos($arg, '='); |
|
1029 | - if ($split === false) { |
|
1030 | - $report = substr($arg, 7); |
|
1031 | - $output = null; |
|
1032 | - } else { |
|
1033 | - $report = substr($arg, 7, ($split - 7)); |
|
1034 | - $output = substr($arg, ($split + 1)); |
|
1035 | - if ($output === false) { |
|
1018 | + if (is_dir($this->basepath) === false) { |
|
1019 | + $error = 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
1020 | + $error .= $this->printShortUsage(true); |
|
1021 | + throw new DeepExitException($error, 3); |
|
1022 | + } |
|
1023 | + } else if ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) { |
|
1024 | + $reports = []; |
|
1025 | + |
|
1026 | + if ($arg[6] === '-') { |
|
1027 | + // This is a report with file output. |
|
1028 | + $split = strpos($arg, '='); |
|
1029 | + if ($split === false) { |
|
1030 | + $report = substr($arg, 7); |
|
1036 | 1031 | $output = null; |
1037 | 1032 | } else { |
1038 | - $dir = Util\Common::realpath(dirname($output)); |
|
1039 | - if (is_dir($dir) === false) { |
|
1040 | - $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
1041 | - $error .= $this->printShortUsage(true); |
|
1042 | - throw new DeepExitException($error, 3); |
|
1043 | - } |
|
1033 | + $report = substr($arg, 7, ($split - 7)); |
|
1034 | + $output = substr($arg, ($split + 1)); |
|
1035 | + if ($output === false) { |
|
1036 | + $output = null; |
|
1037 | + } else { |
|
1038 | + $dir = Util\Common::realpath(dirname($output)); |
|
1039 | + if (is_dir($dir) === false) { |
|
1040 | + $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
1041 | + $error .= $this->printShortUsage(true); |
|
1042 | + throw new DeepExitException($error, 3); |
|
1043 | + } |
|
1044 | + |
|
1045 | + $output = $dir.'/'.basename($output); |
|
1046 | + |
|
1047 | + if (is_dir($output) === true) { |
|
1048 | + $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" is a directory'.PHP_EOL.PHP_EOL; |
|
1049 | + $error .= $this->printShortUsage(true); |
|
1050 | + throw new DeepExitException($error, 3); |
|
1051 | + } |
|
1052 | + }//end if |
|
1053 | + }//end if |
|
1044 | 1054 | |
1045 | - $output = $dir.'/'.basename($output); |
|
1055 | + $reports[$report] = $output; |
|
1056 | + } else { |
|
1057 | + // This is a single report. |
|
1058 | + if (isset(self::$overriddenDefaults['reports']) === true) { |
|
1059 | + break; |
|
1060 | + } |
|
1046 | 1061 | |
1047 | - if (is_dir($output) === true) { |
|
1048 | - $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" is a directory'.PHP_EOL.PHP_EOL; |
|
1049 | - $error .= $this->printShortUsage(true); |
|
1050 | - throw new DeepExitException($error, 3); |
|
1051 | - } |
|
1052 | - }//end if |
|
1062 | + $reportNames = explode(',', substr($arg, 7)); |
|
1063 | + foreach ($reportNames as $report) { |
|
1064 | + $reports[$report] = null; |
|
1065 | + } |
|
1053 | 1066 | }//end if |
1054 | 1067 | |
1055 | - $reports[$report] = $output; |
|
1056 | - } else { |
|
1057 | - // This is a single report. |
|
1058 | - if (isset(self::$overriddenDefaults['reports']) === true) { |
|
1059 | - break; |
|
1068 | + // Remove the default value so the CLI value overrides it. |
|
1069 | + if (isset(self::$overriddenDefaults['reports']) === false) { |
|
1070 | + $this->reports = $reports; |
|
1071 | + } else { |
|
1072 | + $this->reports = array_merge($this->reports, $reports); |
|
1060 | 1073 | } |
1061 | 1074 | |
1062 | - $reportNames = explode(',', substr($arg, 7)); |
|
1063 | - foreach ($reportNames as $report) { |
|
1064 | - $reports[$report] = null; |
|
1075 | + self::$overriddenDefaults['reports'] = true; |
|
1076 | + } else if (substr($arg, 0, 7) === 'filter=') { |
|
1077 | + if (isset(self::$overriddenDefaults['filter']) === true) { |
|
1078 | + break; |
|
1065 | 1079 | } |
1066 | - }//end if |
|
1067 | 1080 | |
1068 | - // Remove the default value so the CLI value overrides it. |
|
1069 | - if (isset(self::$overriddenDefaults['reports']) === false) { |
|
1070 | - $this->reports = $reports; |
|
1071 | - } else { |
|
1072 | - $this->reports = array_merge($this->reports, $reports); |
|
1073 | - } |
|
1081 | + $this->filter = substr($arg, 7); |
|
1082 | + self::$overriddenDefaults['filter'] = true; |
|
1083 | + } else if (substr($arg, 0, 9) === 'standard=') { |
|
1084 | + $standards = trim(substr($arg, 9)); |
|
1085 | + if ($standards !== '') { |
|
1086 | + $this->standards = explode(',', $standards); |
|
1087 | + } |
|
1074 | 1088 | |
1075 | - self::$overriddenDefaults['reports'] = true; |
|
1076 | - } else if (substr($arg, 0, 7) === 'filter=') { |
|
1077 | - if (isset(self::$overriddenDefaults['filter']) === true) { |
|
1078 | - break; |
|
1079 | - } |
|
1089 | + self::$overriddenDefaults['standards'] = true; |
|
1090 | + } else if (substr($arg, 0, 11) === 'extensions=') { |
|
1091 | + if (isset(self::$overriddenDefaults['extensions']) === true) { |
|
1092 | + break; |
|
1093 | + } |
|
1080 | 1094 | |
1081 | - $this->filter = substr($arg, 7); |
|
1082 | - self::$overriddenDefaults['filter'] = true; |
|
1083 | - } else if (substr($arg, 0, 9) === 'standard=') { |
|
1084 | - $standards = trim(substr($arg, 9)); |
|
1085 | - if ($standards !== '') { |
|
1086 | - $this->standards = explode(',', $standards); |
|
1087 | - } |
|
1095 | + $extensions = explode(',', substr($arg, 11)); |
|
1096 | + $newExtensions = []; |
|
1097 | + foreach ($extensions as $ext) { |
|
1098 | + $slash = strpos($ext, '/'); |
|
1099 | + if ($slash !== false) { |
|
1100 | + // They specified the tokenizer too. |
|
1101 | + list($ext, $tokenizer) = explode('/', $ext); |
|
1102 | + $newExtensions[$ext] = strtoupper($tokenizer); |
|
1103 | + continue; |
|
1104 | + } |
|
1088 | 1105 | |
1089 | - self::$overriddenDefaults['standards'] = true; |
|
1090 | - } else if (substr($arg, 0, 11) === 'extensions=') { |
|
1091 | - if (isset(self::$overriddenDefaults['extensions']) === true) { |
|
1092 | - break; |
|
1093 | - } |
|
1106 | + if (isset($this->extensions[$ext]) === true) { |
|
1107 | + $newExtensions[$ext] = $this->extensions[$ext]; |
|
1108 | + } else { |
|
1109 | + $newExtensions[$ext] = 'PHP'; |
|
1110 | + } |
|
1111 | + } |
|
1094 | 1112 | |
1095 | - $extensions = explode(',', substr($arg, 11)); |
|
1096 | - $newExtensions = []; |
|
1097 | - foreach ($extensions as $ext) { |
|
1098 | - $slash = strpos($ext, '/'); |
|
1099 | - if ($slash !== false) { |
|
1100 | - // They specified the tokenizer too. |
|
1101 | - list($ext, $tokenizer) = explode('/', $ext); |
|
1102 | - $newExtensions[$ext] = strtoupper($tokenizer); |
|
1103 | - continue; |
|
1113 | + $this->extensions = $newExtensions; |
|
1114 | + self::$overriddenDefaults['extensions'] = true; |
|
1115 | + } else if (substr($arg, 0, 7) === 'suffix=') { |
|
1116 | + if (isset(self::$overriddenDefaults['suffix']) === true) { |
|
1117 | + break; |
|
1104 | 1118 | } |
1105 | 1119 | |
1106 | - if (isset($this->extensions[$ext]) === true) { |
|
1107 | - $newExtensions[$ext] = $this->extensions[$ext]; |
|
1108 | - } else { |
|
1109 | - $newExtensions[$ext] = 'PHP'; |
|
1120 | + $this->suffix = substr($arg, 7); |
|
1121 | + self::$overriddenDefaults['suffix'] = true; |
|
1122 | + } else if (substr($arg, 0, 9) === 'parallel=') { |
|
1123 | + if (isset(self::$overriddenDefaults['parallel']) === true) { |
|
1124 | + break; |
|
1110 | 1125 | } |
1111 | - } |
|
1112 | 1126 | |
1113 | - $this->extensions = $newExtensions; |
|
1114 | - self::$overriddenDefaults['extensions'] = true; |
|
1115 | - } else if (substr($arg, 0, 7) === 'suffix=') { |
|
1116 | - if (isset(self::$overriddenDefaults['suffix']) === true) { |
|
1117 | - break; |
|
1118 | - } |
|
1127 | + $this->parallel = max((int) substr($arg, 9), 1); |
|
1128 | + self::$overriddenDefaults['parallel'] = true; |
|
1129 | + } else if (substr($arg, 0, 9) === 'severity=') { |
|
1130 | + $this->errorSeverity = (int) substr($arg, 9); |
|
1131 | + $this->warningSeverity = $this->errorSeverity; |
|
1132 | + if (isset(self::$overriddenDefaults['errorSeverity']) === false) { |
|
1133 | + self::$overriddenDefaults['errorSeverity'] = true; |
|
1134 | + } |
|
1119 | 1135 | |
1120 | - $this->suffix = substr($arg, 7); |
|
1121 | - self::$overriddenDefaults['suffix'] = true; |
|
1122 | - } else if (substr($arg, 0, 9) === 'parallel=') { |
|
1123 | - if (isset(self::$overriddenDefaults['parallel']) === true) { |
|
1124 | - break; |
|
1125 | - } |
|
1136 | + if (isset(self::$overriddenDefaults['warningSeverity']) === false) { |
|
1137 | + self::$overriddenDefaults['warningSeverity'] = true; |
|
1138 | + } |
|
1139 | + } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
1140 | + if (isset(self::$overriddenDefaults['errorSeverity']) === true) { |
|
1141 | + break; |
|
1142 | + } |
|
1126 | 1143 | |
1127 | - $this->parallel = max((int) substr($arg, 9), 1); |
|
1128 | - self::$overriddenDefaults['parallel'] = true; |
|
1129 | - } else if (substr($arg, 0, 9) === 'severity=') { |
|
1130 | - $this->errorSeverity = (int) substr($arg, 9); |
|
1131 | - $this->warningSeverity = $this->errorSeverity; |
|
1132 | - if (isset(self::$overriddenDefaults['errorSeverity']) === false) { |
|
1144 | + $this->errorSeverity = (int) substr($arg, 15); |
|
1133 | 1145 | self::$overriddenDefaults['errorSeverity'] = true; |
1134 | - } |
|
1146 | + } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
1147 | + if (isset(self::$overriddenDefaults['warningSeverity']) === true) { |
|
1148 | + break; |
|
1149 | + } |
|
1135 | 1150 | |
1136 | - if (isset(self::$overriddenDefaults['warningSeverity']) === false) { |
|
1151 | + $this->warningSeverity = (int) substr($arg, 17); |
|
1137 | 1152 | self::$overriddenDefaults['warningSeverity'] = true; |
1138 | - } |
|
1139 | - } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
1140 | - if (isset(self::$overriddenDefaults['errorSeverity']) === true) { |
|
1141 | - break; |
|
1142 | - } |
|
1143 | - |
|
1144 | - $this->errorSeverity = (int) substr($arg, 15); |
|
1145 | - self::$overriddenDefaults['errorSeverity'] = true; |
|
1146 | - } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
1147 | - if (isset(self::$overriddenDefaults['warningSeverity']) === true) { |
|
1148 | - break; |
|
1149 | - } |
|
1153 | + } else if (substr($arg, 0, 7) === 'ignore=') { |
|
1154 | + if (isset(self::$overriddenDefaults['ignored']) === true) { |
|
1155 | + break; |
|
1156 | + } |
|
1150 | 1157 | |
1151 | - $this->warningSeverity = (int) substr($arg, 17); |
|
1152 | - self::$overriddenDefaults['warningSeverity'] = true; |
|
1153 | - } else if (substr($arg, 0, 7) === 'ignore=') { |
|
1154 | - if (isset(self::$overriddenDefaults['ignored']) === true) { |
|
1155 | - break; |
|
1156 | - } |
|
1158 | + // Split the ignore string on commas, unless the comma is escaped |
|
1159 | + // using 1 or 3 slashes (\, or \\\,). |
|
1160 | + $patterns = preg_split( |
|
1161 | + '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
1162 | + substr($arg, 7) |
|
1163 | + ); |
|
1164 | + |
|
1165 | + $ignored = []; |
|
1166 | + foreach ($patterns as $pattern) { |
|
1167 | + $pattern = trim($pattern); |
|
1168 | + if ($pattern === '') { |
|
1169 | + continue; |
|
1170 | + } |
|
1157 | 1171 | |
1158 | - // Split the ignore string on commas, unless the comma is escaped |
|
1159 | - // using 1 or 3 slashes (\, or \\\,). |
|
1160 | - $patterns = preg_split( |
|
1161 | - '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
1162 | - substr($arg, 7) |
|
1163 | - ); |
|
1164 | - |
|
1165 | - $ignored = []; |
|
1166 | - foreach ($patterns as $pattern) { |
|
1167 | - $pattern = trim($pattern); |
|
1168 | - if ($pattern === '') { |
|
1169 | - continue; |
|
1172 | + $ignored[$pattern] = 'absolute'; |
|
1170 | 1173 | } |
1171 | 1174 | |
1172 | - $ignored[$pattern] = 'absolute'; |
|
1173 | - } |
|
1174 | - |
|
1175 | - $this->ignored = $ignored; |
|
1176 | - self::$overriddenDefaults['ignored'] = true; |
|
1177 | - } else if (substr($arg, 0, 10) === 'generator=' |
|
1178 | - && PHP_CODESNIFFER_CBF === false |
|
1179 | - ) { |
|
1180 | - if (isset(self::$overriddenDefaults['generator']) === true) { |
|
1181 | - break; |
|
1182 | - } |
|
1175 | + $this->ignored = $ignored; |
|
1176 | + self::$overriddenDefaults['ignored'] = true; |
|
1177 | + } else if (substr($arg, 0, 10) === 'generator=' |
|
1178 | + && PHP_CODESNIFFER_CBF === false |
|
1179 | + ) { |
|
1180 | + if (isset(self::$overriddenDefaults['generator']) === true) { |
|
1181 | + break; |
|
1182 | + } |
|
1183 | 1183 | |
1184 | - $this->generator = substr($arg, 10); |
|
1185 | - self::$overriddenDefaults['generator'] = true; |
|
1186 | - } else if (substr($arg, 0, 9) === 'encoding=') { |
|
1187 | - if (isset(self::$overriddenDefaults['encoding']) === true) { |
|
1188 | - break; |
|
1189 | - } |
|
1184 | + $this->generator = substr($arg, 10); |
|
1185 | + self::$overriddenDefaults['generator'] = true; |
|
1186 | + } else if (substr($arg, 0, 9) === 'encoding=') { |
|
1187 | + if (isset(self::$overriddenDefaults['encoding']) === true) { |
|
1188 | + break; |
|
1189 | + } |
|
1190 | 1190 | |
1191 | - $this->encoding = strtolower(substr($arg, 9)); |
|
1192 | - self::$overriddenDefaults['encoding'] = true; |
|
1193 | - } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
1194 | - if (isset(self::$overriddenDefaults['tabWidth']) === true) { |
|
1195 | - break; |
|
1196 | - } |
|
1191 | + $this->encoding = strtolower(substr($arg, 9)); |
|
1192 | + self::$overriddenDefaults['encoding'] = true; |
|
1193 | + } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
1194 | + if (isset(self::$overriddenDefaults['tabWidth']) === true) { |
|
1195 | + break; |
|
1196 | + } |
|
1197 | 1197 | |
1198 | - $this->tabWidth = (int) substr($arg, 10); |
|
1199 | - self::$overriddenDefaults['tabWidth'] = true; |
|
1200 | - } else { |
|
1201 | - if ($this->dieOnUnknownArg === false) { |
|
1202 | - $eqPos = strpos($arg, '='); |
|
1203 | - try { |
|
1204 | - if ($eqPos === false) { |
|
1205 | - $this->values[$arg] = $arg; |
|
1206 | - } else { |
|
1207 | - $value = substr($arg, ($eqPos + 1)); |
|
1208 | - $arg = substr($arg, 0, $eqPos); |
|
1209 | - $this->values[$arg] = $value; |
|
1198 | + $this->tabWidth = (int) substr($arg, 10); |
|
1199 | + self::$overriddenDefaults['tabWidth'] = true; |
|
1200 | + } else { |
|
1201 | + if ($this->dieOnUnknownArg === false) { |
|
1202 | + $eqPos = strpos($arg, '='); |
|
1203 | + try { |
|
1204 | + if ($eqPos === false) { |
|
1205 | + $this->values[$arg] = $arg; |
|
1206 | + } else { |
|
1207 | + $value = substr($arg, ($eqPos + 1)); |
|
1208 | + $arg = substr($arg, 0, $eqPos); |
|
1209 | + $this->values[$arg] = $value; |
|
1210 | + } |
|
1211 | + } catch (RuntimeException $e) { |
|
1212 | + // Value is not valid, so just ignore it. |
|
1210 | 1213 | } |
1211 | - } catch (RuntimeException $e) { |
|
1212 | - // Value is not valid, so just ignore it. |
|
1214 | + } else { |
|
1215 | + $this->processUnknownArgument('--'.$arg, $pos); |
|
1213 | 1216 | } |
1214 | - } else { |
|
1215 | - $this->processUnknownArgument('--'.$arg, $pos); |
|
1216 | - } |
|
1217 | - }//end if |
|
1218 | - break; |
|
1217 | + }//end if |
|
1218 | + break; |
|
1219 | 1219 | }//end switch |
1220 | 1220 | |
1221 | 1221 | }//end processLongArgument() |
@@ -1375,146 +1375,146 @@ discard block |
||
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | switch ($this->tokens[$i]['code']) { |
1378 | - case T_BITWISE_AND: |
|
1379 | - if ($defaultStart === null) { |
|
1380 | - $passByReference = true; |
|
1381 | - $referenceToken = $i; |
|
1382 | - } |
|
1383 | - break; |
|
1384 | - case T_VARIABLE: |
|
1385 | - $currVar = $i; |
|
1386 | - break; |
|
1387 | - case T_ELLIPSIS: |
|
1388 | - $variableLength = true; |
|
1389 | - $variadicToken = $i; |
|
1390 | - break; |
|
1391 | - case T_CALLABLE: |
|
1392 | - if ($typeHintToken === false) { |
|
1393 | - $typeHintToken = $i; |
|
1394 | - } |
|
1395 | - |
|
1396 | - $typeHint .= $this->tokens[$i]['content']; |
|
1397 | - $typeHintEndToken = $i; |
|
1398 | - break; |
|
1399 | - case T_SELF: |
|
1400 | - case T_PARENT: |
|
1401 | - case T_STATIC: |
|
1402 | - // Self and parent are valid, static invalid, but was probably intended as type hint. |
|
1403 | - if (isset($defaultStart) === false) { |
|
1378 | + case T_BITWISE_AND: |
|
1379 | + if ($defaultStart === null) { |
|
1380 | + $passByReference = true; |
|
1381 | + $referenceToken = $i; |
|
1382 | + } |
|
1383 | + break; |
|
1384 | + case T_VARIABLE: |
|
1385 | + $currVar = $i; |
|
1386 | + break; |
|
1387 | + case T_ELLIPSIS: |
|
1388 | + $variableLength = true; |
|
1389 | + $variadicToken = $i; |
|
1390 | + break; |
|
1391 | + case T_CALLABLE: |
|
1404 | 1392 | if ($typeHintToken === false) { |
1405 | 1393 | $typeHintToken = $i; |
1406 | 1394 | } |
1407 | 1395 | |
1408 | 1396 | $typeHint .= $this->tokens[$i]['content']; |
1409 | 1397 | $typeHintEndToken = $i; |
1410 | - } |
|
1411 | - break; |
|
1412 | - case T_STRING: |
|
1413 | - // This is a string, so it may be a type hint, but it could |
|
1414 | - // also be a constant used as a default value. |
|
1415 | - $prevComma = false; |
|
1416 | - for ($t = $i; $t >= $opener; $t--) { |
|
1417 | - if ($this->tokens[$t]['code'] === T_COMMA) { |
|
1418 | - $prevComma = $t; |
|
1419 | - break; |
|
1420 | - } |
|
1421 | - } |
|
1398 | + break; |
|
1399 | + case T_SELF: |
|
1400 | + case T_PARENT: |
|
1401 | + case T_STATIC: |
|
1402 | + // Self and parent are valid, static invalid, but was probably intended as type hint. |
|
1403 | + if (isset($defaultStart) === false) { |
|
1404 | + if ($typeHintToken === false) { |
|
1405 | + $typeHintToken = $i; |
|
1406 | + } |
|
1422 | 1407 | |
1423 | - if ($prevComma !== false) { |
|
1424 | - $nextEquals = false; |
|
1425 | - for ($t = $prevComma; $t < $i; $t++) { |
|
1426 | - if ($this->tokens[$t]['code'] === T_EQUAL) { |
|
1427 | - $nextEquals = $t; |
|
1408 | + $typeHint .= $this->tokens[$i]['content']; |
|
1409 | + $typeHintEndToken = $i; |
|
1410 | + } |
|
1411 | + break; |
|
1412 | + case T_STRING: |
|
1413 | + // This is a string, so it may be a type hint, but it could |
|
1414 | + // also be a constant used as a default value. |
|
1415 | + $prevComma = false; |
|
1416 | + for ($t = $i; $t >= $opener; $t--) { |
|
1417 | + if ($this->tokens[$t]['code'] === T_COMMA) { |
|
1418 | + $prevComma = $t; |
|
1428 | 1419 | break; |
1429 | 1420 | } |
1430 | 1421 | } |
1431 | 1422 | |
1432 | - if ($nextEquals !== false) { |
|
1433 | - break; |
|
1434 | - } |
|
1435 | - } |
|
1423 | + if ($prevComma !== false) { |
|
1424 | + $nextEquals = false; |
|
1425 | + for ($t = $prevComma; $t < $i; $t++) { |
|
1426 | + if ($this->tokens[$t]['code'] === T_EQUAL) { |
|
1427 | + $nextEquals = $t; |
|
1428 | + break; |
|
1429 | + } |
|
1430 | + } |
|
1436 | 1431 | |
1437 | - if ($defaultStart === null) { |
|
1438 | - if ($typeHintToken === false) { |
|
1439 | - $typeHintToken = $i; |
|
1432 | + if ($nextEquals !== false) { |
|
1433 | + break; |
|
1434 | + } |
|
1440 | 1435 | } |
1441 | 1436 | |
1442 | - $typeHint .= $this->tokens[$i]['content']; |
|
1443 | - $typeHintEndToken = $i; |
|
1444 | - } |
|
1445 | - break; |
|
1446 | - case T_NS_SEPARATOR: |
|
1447 | - // Part of a type hint or default value. |
|
1448 | - if ($defaultStart === null) { |
|
1449 | - if ($typeHintToken === false) { |
|
1450 | - $typeHintToken = $i; |
|
1437 | + if ($defaultStart === null) { |
|
1438 | + if ($typeHintToken === false) { |
|
1439 | + $typeHintToken = $i; |
|
1440 | + } |
|
1441 | + |
|
1442 | + $typeHint .= $this->tokens[$i]['content']; |
|
1443 | + $typeHintEndToken = $i; |
|
1451 | 1444 | } |
1445 | + break; |
|
1446 | + case T_NS_SEPARATOR: |
|
1447 | + // Part of a type hint or default value. |
|
1448 | + if ($defaultStart === null) { |
|
1449 | + if ($typeHintToken === false) { |
|
1450 | + $typeHintToken = $i; |
|
1451 | + } |
|
1452 | 1452 | |
1453 | - $typeHint .= $this->tokens[$i]['content']; |
|
1454 | - $typeHintEndToken = $i; |
|
1455 | - } |
|
1456 | - break; |
|
1457 | - case T_NULLABLE: |
|
1458 | - if ($defaultStart === null) { |
|
1459 | - $nullableType = true; |
|
1460 | - $typeHint .= $this->tokens[$i]['content']; |
|
1461 | - $typeHintEndToken = $i; |
|
1462 | - } |
|
1463 | - break; |
|
1464 | - case T_CLOSE_PARENTHESIS: |
|
1465 | - case T_COMMA: |
|
1466 | - // If it's null, then there must be no parameters for this |
|
1467 | - // method. |
|
1468 | - if ($currVar === null) { |
|
1469 | - continue 2; |
|
1470 | - } |
|
1453 | + $typeHint .= $this->tokens[$i]['content']; |
|
1454 | + $typeHintEndToken = $i; |
|
1455 | + } |
|
1456 | + break; |
|
1457 | + case T_NULLABLE: |
|
1458 | + if ($defaultStart === null) { |
|
1459 | + $nullableType = true; |
|
1460 | + $typeHint .= $this->tokens[$i]['content']; |
|
1461 | + $typeHintEndToken = $i; |
|
1462 | + } |
|
1463 | + break; |
|
1464 | + case T_CLOSE_PARENTHESIS: |
|
1465 | + case T_COMMA: |
|
1466 | + // If it's null, then there must be no parameters for this |
|
1467 | + // method. |
|
1468 | + if ($currVar === null) { |
|
1469 | + continue 2; |
|
1470 | + } |
|
1471 | 1471 | |
1472 | - $vars[$paramCount] = []; |
|
1473 | - $vars[$paramCount]['token'] = $currVar; |
|
1474 | - $vars[$paramCount]['name'] = $this->tokens[$currVar]['content']; |
|
1475 | - $vars[$paramCount]['content'] = trim($this->getTokensAsString($paramStart, ($i - $paramStart))); |
|
1472 | + $vars[$paramCount] = []; |
|
1473 | + $vars[$paramCount]['token'] = $currVar; |
|
1474 | + $vars[$paramCount]['name'] = $this->tokens[$currVar]['content']; |
|
1475 | + $vars[$paramCount]['content'] = trim($this->getTokensAsString($paramStart, ($i - $paramStart))); |
|
1476 | 1476 | |
1477 | - if ($defaultStart !== null) { |
|
1478 | - $vars[$paramCount]['default'] = trim($this->getTokensAsString($defaultStart, ($i - $defaultStart))); |
|
1479 | - $vars[$paramCount]['default_token'] = $defaultStart; |
|
1480 | - $vars[$paramCount]['default_equal_token'] = $equalToken; |
|
1481 | - } |
|
1477 | + if ($defaultStart !== null) { |
|
1478 | + $vars[$paramCount]['default'] = trim($this->getTokensAsString($defaultStart, ($i - $defaultStart))); |
|
1479 | + $vars[$paramCount]['default_token'] = $defaultStart; |
|
1480 | + $vars[$paramCount]['default_equal_token'] = $equalToken; |
|
1481 | + } |
|
1482 | 1482 | |
1483 | - $vars[$paramCount]['pass_by_reference'] = $passByReference; |
|
1484 | - $vars[$paramCount]['reference_token'] = $referenceToken; |
|
1485 | - $vars[$paramCount]['variable_length'] = $variableLength; |
|
1486 | - $vars[$paramCount]['variadic_token'] = $variadicToken; |
|
1487 | - $vars[$paramCount]['type_hint'] = $typeHint; |
|
1488 | - $vars[$paramCount]['type_hint_token'] = $typeHintToken; |
|
1489 | - $vars[$paramCount]['type_hint_end_token'] = $typeHintEndToken; |
|
1490 | - $vars[$paramCount]['nullable_type'] = $nullableType; |
|
1491 | - |
|
1492 | - if ($this->tokens[$i]['code'] === T_COMMA) { |
|
1493 | - $vars[$paramCount]['comma_token'] = $i; |
|
1494 | - } else { |
|
1495 | - $vars[$paramCount]['comma_token'] = false; |
|
1496 | - } |
|
1483 | + $vars[$paramCount]['pass_by_reference'] = $passByReference; |
|
1484 | + $vars[$paramCount]['reference_token'] = $referenceToken; |
|
1485 | + $vars[$paramCount]['variable_length'] = $variableLength; |
|
1486 | + $vars[$paramCount]['variadic_token'] = $variadicToken; |
|
1487 | + $vars[$paramCount]['type_hint'] = $typeHint; |
|
1488 | + $vars[$paramCount]['type_hint_token'] = $typeHintToken; |
|
1489 | + $vars[$paramCount]['type_hint_end_token'] = $typeHintEndToken; |
|
1490 | + $vars[$paramCount]['nullable_type'] = $nullableType; |
|
1491 | + |
|
1492 | + if ($this->tokens[$i]['code'] === T_COMMA) { |
|
1493 | + $vars[$paramCount]['comma_token'] = $i; |
|
1494 | + } else { |
|
1495 | + $vars[$paramCount]['comma_token'] = false; |
|
1496 | + } |
|
1497 | 1497 | |
1498 | - // Reset the vars, as we are about to process the next parameter. |
|
1499 | - $currVar = null; |
|
1500 | - $paramStart = ($i + 1); |
|
1501 | - $defaultStart = null; |
|
1502 | - $equalToken = null; |
|
1503 | - $passByReference = false; |
|
1504 | - $referenceToken = false; |
|
1505 | - $variableLength = false; |
|
1506 | - $variadicToken = false; |
|
1507 | - $typeHint = ''; |
|
1508 | - $typeHintToken = false; |
|
1509 | - $typeHintEndToken = false; |
|
1510 | - $nullableType = false; |
|
1511 | - |
|
1512 | - $paramCount++; |
|
1513 | - break; |
|
1514 | - case T_EQUAL: |
|
1515 | - $defaultStart = $this->findNext(Util\Tokens::$emptyTokens, ($i + 1), null, true); |
|
1516 | - $equalToken = $i; |
|
1517 | - break; |
|
1498 | + // Reset the vars, as we are about to process the next parameter. |
|
1499 | + $currVar = null; |
|
1500 | + $paramStart = ($i + 1); |
|
1501 | + $defaultStart = null; |
|
1502 | + $equalToken = null; |
|
1503 | + $passByReference = false; |
|
1504 | + $referenceToken = false; |
|
1505 | + $variableLength = false; |
|
1506 | + $variadicToken = false; |
|
1507 | + $typeHint = ''; |
|
1508 | + $typeHintToken = false; |
|
1509 | + $typeHintEndToken = false; |
|
1510 | + $nullableType = false; |
|
1511 | + |
|
1512 | + $paramCount++; |
|
1513 | + break; |
|
1514 | + case T_EQUAL: |
|
1515 | + $defaultStart = $this->findNext(Util\Tokens::$emptyTokens, ($i + 1), null, true); |
|
1516 | + $equalToken = $i; |
|
1517 | + break; |
|
1518 | 1518 | }//end switch |
1519 | 1519 | }//end for |
1520 | 1520 | |
@@ -1591,27 +1591,27 @@ discard block |
||
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | switch ($this->tokens[$i]['code']) { |
1594 | - case T_PUBLIC: |
|
1595 | - $scope = 'public'; |
|
1596 | - $scopeSpecified = true; |
|
1597 | - break; |
|
1598 | - case T_PRIVATE: |
|
1599 | - $scope = 'private'; |
|
1600 | - $scopeSpecified = true; |
|
1601 | - break; |
|
1602 | - case T_PROTECTED: |
|
1603 | - $scope = 'protected'; |
|
1604 | - $scopeSpecified = true; |
|
1605 | - break; |
|
1606 | - case T_ABSTRACT: |
|
1607 | - $isAbstract = true; |
|
1608 | - break; |
|
1609 | - case T_FINAL: |
|
1610 | - $isFinal = true; |
|
1611 | - break; |
|
1612 | - case T_STATIC: |
|
1613 | - $isStatic = true; |
|
1614 | - break; |
|
1594 | + case T_PUBLIC: |
|
1595 | + $scope = 'public'; |
|
1596 | + $scopeSpecified = true; |
|
1597 | + break; |
|
1598 | + case T_PRIVATE: |
|
1599 | + $scope = 'private'; |
|
1600 | + $scopeSpecified = true; |
|
1601 | + break; |
|
1602 | + case T_PROTECTED: |
|
1603 | + $scope = 'protected'; |
|
1604 | + $scopeSpecified = true; |
|
1605 | + break; |
|
1606 | + case T_ABSTRACT: |
|
1607 | + $isAbstract = true; |
|
1608 | + break; |
|
1609 | + case T_FINAL: |
|
1610 | + $isFinal = true; |
|
1611 | + break; |
|
1612 | + case T_STATIC: |
|
1613 | + $isStatic = true; |
|
1614 | + break; |
|
1615 | 1615 | }//end switch |
1616 | 1616 | }//end for |
1617 | 1617 | |
@@ -1784,21 +1784,21 @@ discard block |
||
1784 | 1784 | } |
1785 | 1785 | |
1786 | 1786 | switch ($this->tokens[$i]['code']) { |
1787 | - case T_PUBLIC: |
|
1788 | - $scope = 'public'; |
|
1789 | - $scopeSpecified = true; |
|
1790 | - break; |
|
1791 | - case T_PRIVATE: |
|
1792 | - $scope = 'private'; |
|
1793 | - $scopeSpecified = true; |
|
1794 | - break; |
|
1795 | - case T_PROTECTED: |
|
1796 | - $scope = 'protected'; |
|
1797 | - $scopeSpecified = true; |
|
1798 | - break; |
|
1799 | - case T_STATIC: |
|
1800 | - $isStatic = true; |
|
1801 | - break; |
|
1787 | + case T_PUBLIC: |
|
1788 | + $scope = 'public'; |
|
1789 | + $scopeSpecified = true; |
|
1790 | + break; |
|
1791 | + case T_PRIVATE: |
|
1792 | + $scope = 'private'; |
|
1793 | + $scopeSpecified = true; |
|
1794 | + break; |
|
1795 | + case T_PROTECTED: |
|
1796 | + $scope = 'protected'; |
|
1797 | + $scopeSpecified = true; |
|
1798 | + break; |
|
1799 | + case T_STATIC: |
|
1800 | + $isStatic = true; |
|
1801 | + break; |
|
1802 | 1802 | } |
1803 | 1803 | }//end for |
1804 | 1804 | |
@@ -1896,13 +1896,13 @@ discard block |
||
1896 | 1896 | } |
1897 | 1897 | |
1898 | 1898 | switch ($this->tokens[$i]['code']) { |
1899 | - case T_ABSTRACT: |
|
1900 | - $isAbstract = true; |
|
1901 | - break; |
|
1899 | + case T_ABSTRACT: |
|
1900 | + $isAbstract = true; |
|
1901 | + break; |
|
1902 | 1902 | |
1903 | - case T_FINAL: |
|
1904 | - $isFinal = true; |
|
1905 | - break; |
|
1903 | + case T_FINAL: |
|
1904 | + $isFinal = true; |
|
1905 | + break; |
|
1906 | 1906 | } |
1907 | 1907 | }//end for |
1908 | 1908 |
@@ -866,26 +866,26 @@ |
||
866 | 866 | $nestedBraces = 0; |
867 | 867 | for ($start = $from; $start >= 0; $start--) { |
868 | 868 | switch ($pattern[$start]) { |
869 | - case '(': |
|
870 | - if ($nestedParenthesis === 0) { |
|
871 | - $skip['to'] = 'parenthesis_closer'; |
|
872 | - } |
|
869 | + case '(': |
|
870 | + if ($nestedParenthesis === 0) { |
|
871 | + $skip['to'] = 'parenthesis_closer'; |
|
872 | + } |
|
873 | 873 | |
874 | - $nestedParenthesis--; |
|
875 | - break; |
|
876 | - case '{': |
|
877 | - if ($nestedBraces === 0) { |
|
878 | - $skip['to'] = 'scope_closer'; |
|
879 | - } |
|
874 | + $nestedParenthesis--; |
|
875 | + break; |
|
876 | + case '{': |
|
877 | + if ($nestedBraces === 0) { |
|
878 | + $skip['to'] = 'scope_closer'; |
|
879 | + } |
|
880 | 880 | |
881 | - $nestedBraces--; |
|
882 | - break; |
|
883 | - case '}': |
|
884 | - $nestedBraces++; |
|
885 | - break; |
|
886 | - case ')': |
|
887 | - $nestedParenthesis++; |
|
888 | - break; |
|
881 | + $nestedBraces--; |
|
882 | + break; |
|
883 | + case '}': |
|
884 | + $nestedBraces++; |
|
885 | + break; |
|
886 | + case ')': |
|
887 | + $nestedParenthesis++; |
|
888 | + break; |
|
889 | 889 | }//end switch |
890 | 890 | |
891 | 891 | if (isset($skip['to']) === true) { |