@@ -89,36 +89,36 @@ discard block |
||
89 | 89 | * @var array<string, mixed> |
90 | 90 | */ |
91 | 91 | private $settings = array( |
92 | - 'files' => null, |
|
93 | - 'standards' => null, |
|
94 | - 'verbosity' => null, |
|
95 | - 'interactive' => null, |
|
96 | - 'parallel' => null, |
|
97 | - 'cache' => null, |
|
98 | - 'cacheFile' => null, |
|
99 | - 'colors' => null, |
|
100 | - 'explain' => null, |
|
101 | - 'local' => null, |
|
102 | - 'showSources' => null, |
|
103 | - 'showProgress' => null, |
|
104 | - 'tabWidth' => null, |
|
105 | - 'extensions' => null, |
|
106 | - 'sniffs' => null, |
|
107 | - 'ignored' => null, |
|
108 | - 'reportFile' => null, |
|
109 | - 'generator' => null, |
|
110 | - 'filter' => null, |
|
111 | - 'bootstrap' => null, |
|
112 | - 'reports' => null, |
|
113 | - 'basepath' => null, |
|
114 | - 'reportWidth' => null, |
|
115 | - 'errorSeverity' => null, |
|
116 | - 'warningSeverity' => null, |
|
117 | - 'recordErrors' => null, |
|
118 | - 'suffix' => null, |
|
119 | - 'stdin' => null, |
|
120 | - 'stdinContent' => null, |
|
121 | - 'stdinPath' => null, |
|
92 | + 'files' => null, |
|
93 | + 'standards' => null, |
|
94 | + 'verbosity' => null, |
|
95 | + 'interactive' => null, |
|
96 | + 'parallel' => null, |
|
97 | + 'cache' => null, |
|
98 | + 'cacheFile' => null, |
|
99 | + 'colors' => null, |
|
100 | + 'explain' => null, |
|
101 | + 'local' => null, |
|
102 | + 'showSources' => null, |
|
103 | + 'showProgress' => null, |
|
104 | + 'tabWidth' => null, |
|
105 | + 'extensions' => null, |
|
106 | + 'sniffs' => null, |
|
107 | + 'ignored' => null, |
|
108 | + 'reportFile' => null, |
|
109 | + 'generator' => null, |
|
110 | + 'filter' => null, |
|
111 | + 'bootstrap' => null, |
|
112 | + 'reports' => null, |
|
113 | + 'basepath' => null, |
|
114 | + 'reportWidth' => null, |
|
115 | + 'errorSeverity' => null, |
|
116 | + 'warningSeverity' => null, |
|
117 | + 'recordErrors' => null, |
|
118 | + 'suffix' => null, |
|
119 | + 'stdin' => null, |
|
120 | + 'stdinContent' => null, |
|
121 | + 'stdinPath' => null, |
|
122 | 122 | ); |
123 | 123 | |
124 | 124 | /** |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | $this->parallel = 1; |
415 | 415 | $this->tabWidth = 0; |
416 | 416 | $this->extensions = array( |
417 | - 'php' => 'PHP', |
|
418 | - 'inc' => 'PHP', |
|
419 | - 'js' => 'JS', |
|
420 | - 'css' => 'CSS', |
|
421 | - ); |
|
417 | + 'php' => 'PHP', |
|
418 | + 'inc' => 'PHP', |
|
419 | + 'js' => 'JS', |
|
420 | + 'css' => 'CSS', |
|
421 | + ); |
|
422 | 422 | $this->sniffs = array(); |
423 | 423 | $this->ignored = array(); |
424 | 424 | $this->filter = null; |
@@ -202,35 +202,35 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | switch ($name) { |
205 | - case 'reportWidth' : |
|
206 | - // Support auto terminal width. |
|
207 | - if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) { |
|
208 | - $value = (int) $matches[1]; |
|
209 | - } else { |
|
210 | - $value = (int) $value; |
|
211 | - } |
|
212 | - break; |
|
213 | - case 'standards' : |
|
214 | - $cleaned = array(); |
|
215 | - |
|
216 | - // Check if the standard name is valid, or if the case is invalid. |
|
217 | - $installedStandards = Util\Standards::getInstalledStandards(); |
|
218 | - foreach ($value as $standard) { |
|
219 | - foreach ($installedStandards as $validStandard) { |
|
220 | - if (strtolower($standard) === strtolower($validStandard)) { |
|
221 | - $standard = $validStandard; |
|
222 | - break; |
|
223 | - } |
|
205 | + case 'reportWidth' : |
|
206 | + // Support auto terminal width. |
|
207 | + if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) { |
|
208 | + $value = (int) $matches[1]; |
|
209 | + } else { |
|
210 | + $value = (int) $value; |
|
224 | 211 | } |
212 | + break; |
|
213 | + case 'standards' : |
|
214 | + $cleaned = array(); |
|
215 | + |
|
216 | + // Check if the standard name is valid, or if the case is invalid. |
|
217 | + $installedStandards = Util\Standards::getInstalledStandards(); |
|
218 | + foreach ($value as $standard) { |
|
219 | + foreach ($installedStandards as $validStandard) { |
|
220 | + if (strtolower($standard) === strtolower($validStandard)) { |
|
221 | + $standard = $validStandard; |
|
222 | + break; |
|
223 | + } |
|
224 | + } |
|
225 | 225 | |
226 | - $cleaned[] = $standard; |
|
227 | - } |
|
226 | + $cleaned[] = $standard; |
|
227 | + } |
|
228 | 228 | |
229 | - $value = $cleaned; |
|
230 | - break; |
|
231 | - default : |
|
232 | - // No validation required. |
|
233 | - break; |
|
229 | + $value = $cleaned; |
|
230 | + break; |
|
231 | + default : |
|
232 | + // No validation required. |
|
233 | + break; |
|
234 | 234 | }//end switch |
235 | 235 | |
236 | 236 | $this->settings[$name] = $value; |
@@ -502,68 +502,68 @@ discard block |
||
502 | 502 | public function processShortArgument($arg, $pos) |
503 | 503 | { |
504 | 504 | switch ($arg) { |
505 | - case 'h': |
|
506 | - case '?': |
|
507 | - $this->printUsage(); |
|
508 | - exit(0); |
|
509 | - case 'i' : |
|
510 | - Util\Standards::printInstalledStandards(); |
|
511 | - exit(0); |
|
512 | - case 'v' : |
|
513 | - $this->verbosity++; |
|
514 | - $this->overriddenDefaults['verbosity'] = true; |
|
515 | - break; |
|
516 | - case 'l' : |
|
517 | - $this->local = true; |
|
518 | - $this->overriddenDefaults['local'] = true; |
|
519 | - break; |
|
520 | - case 's' : |
|
521 | - $this->showSources = true; |
|
522 | - $this->overriddenDefaults['showSources'] = true; |
|
523 | - break; |
|
524 | - case 'a' : |
|
525 | - $this->interactive = true; |
|
526 | - $this->overriddenDefaults['interactive'] = true; |
|
527 | - break; |
|
528 | - case 'e': |
|
529 | - $this->explain = true; |
|
530 | - $this->overriddenDefaults['explain'] = true; |
|
531 | - break; |
|
532 | - case 'p' : |
|
533 | - $this->showProgress = true; |
|
534 | - $this->overriddenDefaults['showProgress'] = true; |
|
535 | - break; |
|
536 | - case 'm' : |
|
537 | - $this->recordErrors = false; |
|
538 | - $this->overriddenDefaults['recordErrors'] = true; |
|
539 | - break; |
|
540 | - case 'd' : |
|
541 | - $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
542 | - $this->cliArgs[($pos + 1)] = ''; |
|
543 | - if (isset($ini[1]) === true) { |
|
544 | - ini_set($ini[0], $ini[1]); |
|
545 | - } else { |
|
546 | - ini_set($ini[0], true); |
|
547 | - } |
|
548 | - break; |
|
549 | - case 'n' : |
|
550 | - if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
551 | - $this->warningSeverity = 0; |
|
552 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
553 | - } |
|
554 | - break; |
|
555 | - case 'w' : |
|
556 | - if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
557 | - $this->warningSeverity = $this->errorSeverity; |
|
558 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
559 | - } |
|
560 | - break; |
|
561 | - default: |
|
562 | - if ($this->dieOnUnknownArg === false) { |
|
563 | - $this->values[$arg] = $arg; |
|
564 | - } else { |
|
565 | - $this->processUnknownArgument('-'.$arg, $pos); |
|
566 | - } |
|
505 | + case 'h': |
|
506 | + case '?': |
|
507 | + $this->printUsage(); |
|
508 | + exit(0); |
|
509 | + case 'i' : |
|
510 | + Util\Standards::printInstalledStandards(); |
|
511 | + exit(0); |
|
512 | + case 'v' : |
|
513 | + $this->verbosity++; |
|
514 | + $this->overriddenDefaults['verbosity'] = true; |
|
515 | + break; |
|
516 | + case 'l' : |
|
517 | + $this->local = true; |
|
518 | + $this->overriddenDefaults['local'] = true; |
|
519 | + break; |
|
520 | + case 's' : |
|
521 | + $this->showSources = true; |
|
522 | + $this->overriddenDefaults['showSources'] = true; |
|
523 | + break; |
|
524 | + case 'a' : |
|
525 | + $this->interactive = true; |
|
526 | + $this->overriddenDefaults['interactive'] = true; |
|
527 | + break; |
|
528 | + case 'e': |
|
529 | + $this->explain = true; |
|
530 | + $this->overriddenDefaults['explain'] = true; |
|
531 | + break; |
|
532 | + case 'p' : |
|
533 | + $this->showProgress = true; |
|
534 | + $this->overriddenDefaults['showProgress'] = true; |
|
535 | + break; |
|
536 | + case 'm' : |
|
537 | + $this->recordErrors = false; |
|
538 | + $this->overriddenDefaults['recordErrors'] = true; |
|
539 | + break; |
|
540 | + case 'd' : |
|
541 | + $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
542 | + $this->cliArgs[($pos + 1)] = ''; |
|
543 | + if (isset($ini[1]) === true) { |
|
544 | + ini_set($ini[0], $ini[1]); |
|
545 | + } else { |
|
546 | + ini_set($ini[0], true); |
|
547 | + } |
|
548 | + break; |
|
549 | + case 'n' : |
|
550 | + if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
551 | + $this->warningSeverity = 0; |
|
552 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
553 | + } |
|
554 | + break; |
|
555 | + case 'w' : |
|
556 | + if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
557 | + $this->warningSeverity = $this->errorSeverity; |
|
558 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
559 | + } |
|
560 | + break; |
|
561 | + default: |
|
562 | + if ($this->dieOnUnknownArg === false) { |
|
563 | + $this->values[$arg] = $arg; |
|
564 | + } else { |
|
565 | + $this->processUnknownArgument('-'.$arg, $pos); |
|
566 | + } |
|
567 | 567 | }//end switch |
568 | 568 | |
569 | 569 | }//end processShortArgument() |
@@ -580,223 +580,223 @@ discard block |
||
580 | 580 | public function processLongArgument($arg, $pos) |
581 | 581 | { |
582 | 582 | switch ($arg) { |
583 | - case 'help': |
|
584 | - $this->printUsage(); |
|
585 | - exit(0); |
|
586 | - case 'version': |
|
587 | - echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') '; |
|
588 | - echo 'by Squiz (http://www.squiz.net)'.PHP_EOL; |
|
589 | - exit(0); |
|
590 | - case 'colors': |
|
591 | - $this->colors = true; |
|
592 | - $this->overriddenDefaults['colors'] = true; |
|
593 | - break; |
|
594 | - case 'no-colors': |
|
595 | - $this->colors = false; |
|
596 | - $this->overriddenDefaults['colors'] = true; |
|
597 | - break; |
|
598 | - case 'cache': |
|
599 | - if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false) { |
|
600 | - $this->cache = true; |
|
583 | + case 'help': |
|
584 | + $this->printUsage(); |
|
585 | + exit(0); |
|
586 | + case 'version': |
|
587 | + echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') '; |
|
588 | + echo 'by Squiz (http://www.squiz.net)'.PHP_EOL; |
|
589 | + exit(0); |
|
590 | + case 'colors': |
|
591 | + $this->colors = true; |
|
592 | + $this->overriddenDefaults['colors'] = true; |
|
593 | + break; |
|
594 | + case 'no-colors': |
|
595 | + $this->colors = false; |
|
596 | + $this->overriddenDefaults['colors'] = true; |
|
597 | + break; |
|
598 | + case 'cache': |
|
599 | + if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false) { |
|
600 | + $this->cache = true; |
|
601 | + $this->overriddenDefaults['cache'] = true; |
|
602 | + } |
|
603 | + break; |
|
604 | + case 'no-cache': |
|
605 | + $this->cache = false; |
|
601 | 606 | $this->overriddenDefaults['cache'] = true; |
602 | - } |
|
603 | - break; |
|
604 | - case 'no-cache': |
|
605 | - $this->cache = false; |
|
606 | - $this->overriddenDefaults['cache'] = true; |
|
607 | - break; |
|
608 | - default: |
|
609 | - if (substr($arg, 0, 7) === 'sniffs=') { |
|
610 | - $sniffs = explode(',', substr($arg, 7)); |
|
611 | - foreach ($sniffs as $sniff) { |
|
612 | - if (substr_count($sniff, '.') !== 2) { |
|
613 | - echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
614 | - $this->printUsage(); |
|
615 | - exit(2); |
|
607 | + break; |
|
608 | + default: |
|
609 | + if (substr($arg, 0, 7) === 'sniffs=') { |
|
610 | + $sniffs = explode(',', substr($arg, 7)); |
|
611 | + foreach ($sniffs as $sniff) { |
|
612 | + if (substr_count($sniff, '.') !== 2) { |
|
613 | + echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
614 | + $this->printUsage(); |
|
615 | + exit(2); |
|
616 | + } |
|
616 | 617 | } |
617 | - } |
|
618 | 618 | |
619 | - $this->sniffs = $sniffs; |
|
620 | - $this->overriddenDefaults['sniffs'] = true; |
|
621 | - } else if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false |
|
622 | - && substr($arg, 0, 6) === 'cache=' |
|
623 | - ) { |
|
624 | - // Turn caching on. |
|
625 | - $this->cache = true; |
|
626 | - $this->overriddenDefaults['cache'] = true; |
|
619 | + $this->sniffs = $sniffs; |
|
620 | + $this->overriddenDefaults['sniffs'] = true; |
|
621 | + } else if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false |
|
622 | + && substr($arg, 0, 6) === 'cache=' |
|
623 | + ) { |
|
624 | + // Turn caching on. |
|
625 | + $this->cache = true; |
|
626 | + $this->overriddenDefaults['cache'] = true; |
|
627 | + |
|
628 | + $this->cacheFile = Util\Common::realpath(substr($arg, 6)); |
|
629 | + |
|
630 | + // It may not exist and return false instead. |
|
631 | + if ($this->cacheFile === false) { |
|
632 | + $this->cacheFile = substr($arg, 6); |
|
633 | + |
|
634 | + $dir = dirname($this->cacheFile); |
|
635 | + if (is_dir($dir) === false) { |
|
636 | + echo 'ERROR: The specified cache file path "'.$this->cacheFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
637 | + $this->printUsage(); |
|
638 | + exit(2); |
|
639 | + } |
|
627 | 640 | |
628 | - $this->cacheFile = Util\Common::realpath(substr($arg, 6)); |
|
641 | + if ($dir === '.') { |
|
642 | + // Passed report file is a file in the current directory. |
|
643 | + $this->cacheFile = getcwd().'/'.basename($this->cacheFile); |
|
644 | + } else { |
|
645 | + $dir = Util\Common::realpath(getcwd().'/'.$dir); |
|
646 | + if ($dir !== false) { |
|
647 | + // Report file path is relative. |
|
648 | + $this->cacheFile = $dir.'/'.basename($this->cacheFile); |
|
649 | + } |
|
650 | + } |
|
651 | + }//end if |
|
629 | 652 | |
630 | - // It may not exist and return false instead. |
|
631 | - if ($this->cacheFile === false) { |
|
632 | - $this->cacheFile = substr($arg, 6); |
|
653 | + $this->overriddenDefaults['cacheFile'] = true; |
|
633 | 654 | |
634 | - $dir = dirname($this->cacheFile); |
|
635 | - if (is_dir($dir) === false) { |
|
636 | - echo 'ERROR: The specified cache file path "'.$this->cacheFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
655 | + if (is_dir($this->cacheFile) === true) { |
|
656 | + echo 'ERROR: The specified cache file path "'.$this->cacheFile.'" is a directory'.PHP_EOL.PHP_EOL; |
|
637 | 657 | $this->printUsage(); |
638 | 658 | exit(2); |
639 | 659 | } |
640 | - |
|
641 | - if ($dir === '.') { |
|
642 | - // Passed report file is a file in the current directory. |
|
643 | - $this->cacheFile = getcwd().'/'.basename($this->cacheFile); |
|
644 | - } else { |
|
645 | - $dir = Util\Common::realpath(getcwd().'/'.$dir); |
|
646 | - if ($dir !== false) { |
|
647 | - // Report file path is relative. |
|
648 | - $this->cacheFile = $dir.'/'.basename($this->cacheFile); |
|
660 | + } else if (substr($arg, 0, 10) === 'bootstrap=') { |
|
661 | + $files = explode(',', substr($arg, 10)); |
|
662 | + $bootstrap = array(); |
|
663 | + foreach ($files as $file) { |
|
664 | + $path = Util\Common::realpath($file); |
|
665 | + if ($path === false) { |
|
666 | + echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
667 | + $this->printUsage(); |
|
668 | + exit(2); |
|
649 | 669 | } |
650 | - } |
|
651 | - }//end if |
|
652 | 670 | |
653 | - $this->overriddenDefaults['cacheFile'] = true; |
|
654 | - |
|
655 | - if (is_dir($this->cacheFile) === true) { |
|
656 | - echo 'ERROR: The specified cache file path "'.$this->cacheFile.'" is a directory'.PHP_EOL.PHP_EOL; |
|
657 | - $this->printUsage(); |
|
658 | - exit(2); |
|
659 | - } |
|
660 | - } else if (substr($arg, 0, 10) === 'bootstrap=') { |
|
661 | - $files = explode(',', substr($arg, 10)); |
|
662 | - $bootstrap = array(); |
|
663 | - foreach ($files as $file) { |
|
664 | - $path = Util\Common::realpath($file); |
|
665 | - if ($path === false) { |
|
666 | - echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
667 | - $this->printUsage(); |
|
668 | - exit(2); |
|
671 | + $bootstrap[] = $path; |
|
669 | 672 | } |
670 | 673 | |
671 | - $bootstrap[] = $path; |
|
672 | - } |
|
674 | + $this->bootstrap = array_merge($this->bootstrap, $bootstrap); |
|
675 | + $this->overriddenDefaults['bootstrap'] = true; |
|
676 | + } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
677 | + $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
673 | 678 | |
674 | - $this->bootstrap = array_merge($this->bootstrap, $bootstrap); |
|
675 | - $this->overriddenDefaults['bootstrap'] = true; |
|
676 | - } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
677 | - $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
679 | + // It may not exist and return false instead, so use whatever they gave us. |
|
680 | + if ($this->stdinPath === false) { |
|
681 | + $this->stdinPath = trim(substr($arg, 11)); |
|
682 | + } |
|
678 | 683 | |
679 | - // It may not exist and return false instead, so use whatever they gave us. |
|
680 | - if ($this->stdinPath === false) { |
|
681 | - $this->stdinPath = trim(substr($arg, 11)); |
|
682 | - } |
|
684 | + $this->overriddenDefaults['stdinPath'] = true; |
|
685 | + } else if (substr($arg, 0, 9) === 'basepath=') { |
|
686 | + if (isset($this->overriddenDefaults['basepath']) === true) { |
|
687 | + break; |
|
688 | + } |
|
683 | 689 | |
684 | - $this->overriddenDefaults['stdinPath'] = true; |
|
685 | - } else if (substr($arg, 0, 9) === 'basepath=') { |
|
686 | - if (isset($this->overriddenDefaults['basepath']) === true) { |
|
687 | - break; |
|
688 | - } |
|
690 | + $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
689 | 691 | |
690 | - $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
692 | + // It may not exist and return false instead. |
|
693 | + if ($this->basepath === false) { |
|
694 | + $this->basepath = substr($arg, 9); |
|
695 | + } |
|
691 | 696 | |
692 | - // It may not exist and return false instead. |
|
693 | - if ($this->basepath === false) { |
|
694 | - $this->basepath = substr($arg, 9); |
|
695 | - } |
|
697 | + $this->overriddenDefaults['basepath'] = true; |
|
696 | 698 | |
697 | - $this->overriddenDefaults['basepath'] = true; |
|
699 | + if (is_dir($this->basepath) === false) { |
|
700 | + echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
701 | + $this->printUsage(); |
|
702 | + exit(2); |
|
703 | + } |
|
704 | + } else if (substr($arg, 0, 7) === 'filter=') { |
|
705 | + if (isset($this->overriddenDefaults['filter']) === true) { |
|
706 | + break; |
|
707 | + } |
|
698 | 708 | |
699 | - if (is_dir($this->basepath) === false) { |
|
700 | - echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
701 | - $this->printUsage(); |
|
702 | - exit(2); |
|
703 | - } |
|
704 | - } else if (substr($arg, 0, 7) === 'filter=') { |
|
705 | - if (isset($this->overriddenDefaults['filter']) === true) { |
|
706 | - break; |
|
707 | - } |
|
709 | + $this->filter = substr($arg, 7); |
|
710 | + $this->overriddenDefaults['filter'] = true; |
|
711 | + } else if (substr($arg, 0, 9) === 'standard=') { |
|
712 | + $standards = trim(substr($arg, 9)); |
|
713 | + if ($standards !== '') { |
|
714 | + $this->standards = explode(',', $standards); |
|
715 | + } |
|
708 | 716 | |
709 | - $this->filter = substr($arg, 7); |
|
710 | - $this->overriddenDefaults['filter'] = true; |
|
711 | - } else if (substr($arg, 0, 9) === 'standard=') { |
|
712 | - $standards = trim(substr($arg, 9)); |
|
713 | - if ($standards !== '') { |
|
714 | - $this->standards = explode(',', $standards); |
|
715 | - } |
|
717 | + $this->overriddenDefaults['standards'] = true; |
|
718 | + } else if (substr($arg, 0, 11) === 'extensions=') { |
|
719 | + $extensions = explode(',', substr($arg, 11)); |
|
720 | + $newExtensions = array(); |
|
721 | + foreach ($extensions as $ext) { |
|
722 | + $slash = strpos($ext, '/'); |
|
723 | + if ($slash !== false) { |
|
724 | + // They specified the tokenizer too. |
|
725 | + list($ext, $tokenizer) = explode('/', $ext); |
|
726 | + $newExtensions[$ext] = strtoupper($tokenizer); |
|
727 | + continue; |
|
728 | + } |
|
716 | 729 | |
717 | - $this->overriddenDefaults['standards'] = true; |
|
718 | - } else if (substr($arg, 0, 11) === 'extensions=') { |
|
719 | - $extensions = explode(',', substr($arg, 11)); |
|
720 | - $newExtensions = array(); |
|
721 | - foreach ($extensions as $ext) { |
|
722 | - $slash = strpos($ext, '/'); |
|
723 | - if ($slash !== false) { |
|
724 | - // They specified the tokenizer too. |
|
725 | - list($ext, $tokenizer) = explode('/', $ext); |
|
726 | - $newExtensions[$ext] = strtoupper($tokenizer); |
|
727 | - continue; |
|
730 | + if (isset($this->extensions[$ext]) === true) { |
|
731 | + $newExtensions[$ext] = $this->extensions[$ext]; |
|
732 | + } else { |
|
733 | + $newExtensions[$ext] = 'PHP'; |
|
734 | + } |
|
728 | 735 | } |
729 | 736 | |
730 | - if (isset($this->extensions[$ext]) === true) { |
|
731 | - $newExtensions[$ext] = $this->extensions[$ext]; |
|
732 | - } else { |
|
733 | - $newExtensions[$ext] = 'PHP'; |
|
734 | - } |
|
735 | - } |
|
737 | + $this->extensions = $newExtensions; |
|
738 | + $this->overriddenDefaults['extensions'] = true; |
|
739 | + } else if (substr($arg, 0, 7) === 'suffix=') { |
|
740 | + $this->suffix = explode(',', substr($arg, 7)); |
|
741 | + $this->overriddenDefaults['suffix'] = true; |
|
742 | + } else if (substr($arg, 0, 9) === 'parallel=') { |
|
743 | + $this->parallel = max((int) substr($arg, 9), 1); |
|
744 | + $this->overriddenDefaults['parallel'] = true; |
|
745 | + } else if (substr($arg, 0, 9) === 'severity=') { |
|
746 | + $this->errorSeverity = (int) substr($arg, 9); |
|
747 | + $this->warningSeverity = $this->errorSeverity; |
|
748 | + $this->overriddenDefaults['errorSeverity'] = true; |
|
749 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
750 | + } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
751 | + $this->errorSeverity = (int) substr($arg, 15); |
|
752 | + $this->overriddenDefaults['errorSeverity'] = true; |
|
753 | + } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
754 | + $this->warningSeverity = (int) substr($arg, 17); |
|
755 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
756 | + } else if (substr($arg, 0, 7) === 'ignore=') { |
|
757 | + // Split the ignore string on commas, unless the comma is escaped |
|
758 | + // using 1 or 3 slashes (\, or \\\,). |
|
759 | + $patterns = preg_split( |
|
760 | + '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
761 | + substr($arg, 7) |
|
762 | + ); |
|
763 | + |
|
764 | + $ignored = array(); |
|
765 | + foreach ($patterns as $pattern) { |
|
766 | + $pattern = trim($pattern); |
|
767 | + if ($pattern === '') { |
|
768 | + continue; |
|
769 | + } |
|
736 | 770 | |
737 | - $this->extensions = $newExtensions; |
|
738 | - $this->overriddenDefaults['extensions'] = true; |
|
739 | - } else if (substr($arg, 0, 7) === 'suffix=') { |
|
740 | - $this->suffix = explode(',', substr($arg, 7)); |
|
741 | - $this->overriddenDefaults['suffix'] = true; |
|
742 | - } else if (substr($arg, 0, 9) === 'parallel=') { |
|
743 | - $this->parallel = max((int) substr($arg, 9), 1); |
|
744 | - $this->overriddenDefaults['parallel'] = true; |
|
745 | - } else if (substr($arg, 0, 9) === 'severity=') { |
|
746 | - $this->errorSeverity = (int) substr($arg, 9); |
|
747 | - $this->warningSeverity = $this->errorSeverity; |
|
748 | - $this->overriddenDefaults['errorSeverity'] = true; |
|
749 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
750 | - } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
751 | - $this->errorSeverity = (int) substr($arg, 15); |
|
752 | - $this->overriddenDefaults['errorSeverity'] = true; |
|
753 | - } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
754 | - $this->warningSeverity = (int) substr($arg, 17); |
|
755 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
756 | - } else if (substr($arg, 0, 7) === 'ignore=') { |
|
757 | - // Split the ignore string on commas, unless the comma is escaped |
|
758 | - // using 1 or 3 slashes (\, or \\\,). |
|
759 | - $patterns = preg_split( |
|
760 | - '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
761 | - substr($arg, 7) |
|
762 | - ); |
|
763 | - |
|
764 | - $ignored = array(); |
|
765 | - foreach ($patterns as $pattern) { |
|
766 | - $pattern = trim($pattern); |
|
767 | - if ($pattern === '') { |
|
768 | - continue; |
|
771 | + $ignored[$pattern] = 'absolute'; |
|
769 | 772 | } |
770 | 773 | |
771 | - $ignored[$pattern] = 'absolute'; |
|
772 | - } |
|
773 | - |
|
774 | - $this->ignored = $ignored; |
|
775 | - $this->overriddenDefaults['ignored'] = true; |
|
776 | - } else if (substr($arg, 0, 10) === 'generator=' |
|
777 | - && PHP_CodeSniffer_CBF === false |
|
778 | - ) { |
|
779 | - $this->generator = substr($arg, 10); |
|
780 | - $this->overriddenDefaults['generator'] = true; |
|
781 | - } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
782 | - $this->tabWidth = (int) substr($arg, 10); |
|
783 | - $this->overriddenDefaults['tabWidth'] = true; |
|
784 | - } else { |
|
785 | - if ($this->dieOnUnknownArg === false) { |
|
786 | - $eqPos = strpos($arg, '='); |
|
787 | - if ($eqPos === false) { |
|
788 | - $this->values[$arg] = $arg; |
|
774 | + $this->ignored = $ignored; |
|
775 | + $this->overriddenDefaults['ignored'] = true; |
|
776 | + } else if (substr($arg, 0, 10) === 'generator=' |
|
777 | + && PHP_CodeSniffer_CBF === false |
|
778 | + ) { |
|
779 | + $this->generator = substr($arg, 10); |
|
780 | + $this->overriddenDefaults['generator'] = true; |
|
781 | + } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
782 | + $this->tabWidth = (int) substr($arg, 10); |
|
783 | + $this->overriddenDefaults['tabWidth'] = true; |
|
784 | + } else { |
|
785 | + if ($this->dieOnUnknownArg === false) { |
|
786 | + $eqPos = strpos($arg, '='); |
|
787 | + if ($eqPos === false) { |
|
788 | + $this->values[$arg] = $arg; |
|
789 | + } else { |
|
790 | + $value = substr($arg, ($eqPos + 1)); |
|
791 | + $arg = substr($arg, 0, $eqPos); |
|
792 | + $this->values[$arg] = $value; |
|
793 | + } |
|
789 | 794 | } else { |
790 | - $value = substr($arg, ($eqPos + 1)); |
|
791 | - $arg = substr($arg, 0, $eqPos); |
|
792 | - $this->values[$arg] = $value; |
|
795 | + $this->processUnknownArgument('--'.$arg, $pos); |
|
793 | 796 | } |
794 | - } else { |
|
795 | - $this->processUnknownArgument('--'.$arg, $pos); |
|
796 | - } |
|
797 | - }//end if |
|
797 | + }//end if |
|
798 | 798 | |
799 | - break; |
|
799 | + break; |
|
800 | 800 | }//end switch |
801 | 801 | |
802 | 802 | }//end processLongArgument() |