@@ -87,33 +87,33 @@ discard block |
||
| 87 | 87 | * @var array<string, mixed> |
| 88 | 88 | */ |
| 89 | 89 | private $settings = array( |
| 90 | - 'files' => null, |
|
| 91 | - 'standards' => null, |
|
| 92 | - 'verbosity' => null, |
|
| 93 | - 'interactive' => null, |
|
| 94 | - 'parallel' => null, |
|
| 95 | - 'explain' => null, |
|
| 96 | - 'local' => null, |
|
| 97 | - 'showSources' => null, |
|
| 98 | - 'showProgress' => null, |
|
| 99 | - 'tabWidth' => null, |
|
| 100 | - 'extensions' => null, |
|
| 101 | - 'sniffs' => null, |
|
| 102 | - 'ignored' => null, |
|
| 103 | - 'reportFile' => null, |
|
| 104 | - 'generator' => null, |
|
| 105 | - 'filter' => null, |
|
| 106 | - 'bootstrap' => null, |
|
| 107 | - 'reports' => null, |
|
| 108 | - 'basepath' => null, |
|
| 109 | - 'reportWidth' => null, |
|
| 110 | - 'errorSeverity' => null, |
|
| 111 | - 'warningSeverity' => null, |
|
| 112 | - 'recordErrors' => null, |
|
| 113 | - 'suffix' => null, |
|
| 114 | - 'stdin' => null, |
|
| 115 | - 'stdinContent' => null, |
|
| 116 | - 'stdinPath' => null, |
|
| 90 | + 'files' => null, |
|
| 91 | + 'standards' => null, |
|
| 92 | + 'verbosity' => null, |
|
| 93 | + 'interactive' => null, |
|
| 94 | + 'parallel' => null, |
|
| 95 | + 'explain' => null, |
|
| 96 | + 'local' => null, |
|
| 97 | + 'showSources' => null, |
|
| 98 | + 'showProgress' => null, |
|
| 99 | + 'tabWidth' => null, |
|
| 100 | + 'extensions' => null, |
|
| 101 | + 'sniffs' => null, |
|
| 102 | + 'ignored' => null, |
|
| 103 | + 'reportFile' => null, |
|
| 104 | + 'generator' => null, |
|
| 105 | + 'filter' => null, |
|
| 106 | + 'bootstrap' => null, |
|
| 107 | + 'reports' => null, |
|
| 108 | + 'basepath' => null, |
|
| 109 | + 'reportWidth' => null, |
|
| 110 | + 'errorSeverity' => null, |
|
| 111 | + 'warningSeverity' => null, |
|
| 112 | + 'recordErrors' => null, |
|
| 113 | + 'suffix' => null, |
|
| 114 | + 'stdin' => null, |
|
| 115 | + 'stdinContent' => null, |
|
| 116 | + 'stdinPath' => null, |
|
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -407,11 +407,11 @@ discard block |
||
| 407 | 407 | $this->parallel = 1; |
| 408 | 408 | $this->tabWidth = 0; |
| 409 | 409 | $this->extensions = array( |
| 410 | - 'php' => 'PHP', |
|
| 411 | - 'inc' => 'PHP', |
|
| 412 | - 'js' => 'JS', |
|
| 413 | - 'css' => 'CSS', |
|
| 414 | - ); |
|
| 410 | + 'php' => 'PHP', |
|
| 411 | + 'inc' => 'PHP', |
|
| 412 | + 'js' => 'JS', |
|
| 413 | + 'css' => 'CSS', |
|
| 414 | + ); |
|
| 415 | 415 | $this->sniffs = array(); |
| 416 | 416 | $this->ignored = array(); |
| 417 | 417 | $this->filter = null; |
@@ -197,35 +197,35 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | switch ($name) { |
| 200 | - case 'reportWidth' : |
|
| 201 | - // Support auto terminal width. |
|
| 202 | - if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) { |
|
| 203 | - $value = (int) $matches[1]; |
|
| 204 | - } else { |
|
| 205 | - $value = (int) $value; |
|
| 206 | - } |
|
| 207 | - break; |
|
| 208 | - case 'standards' : |
|
| 209 | - $cleaned = array(); |
|
| 210 | - |
|
| 211 | - // Check if the standard name is valid, or if the case is invalid. |
|
| 212 | - $installedStandards = Util\Standards::getInstalledStandards(); |
|
| 213 | - foreach ($value as $standard) { |
|
| 214 | - foreach ($installedStandards as $validStandard) { |
|
| 215 | - if (strtolower($standard) === strtolower($validStandard)) { |
|
| 216 | - $standard = $validStandard; |
|
| 217 | - break; |
|
| 218 | - } |
|
| 200 | + case 'reportWidth' : |
|
| 201 | + // Support auto terminal width. |
|
| 202 | + if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) { |
|
| 203 | + $value = (int) $matches[1]; |
|
| 204 | + } else { |
|
| 205 | + $value = (int) $value; |
|
| 219 | 206 | } |
| 207 | + break; |
|
| 208 | + case 'standards' : |
|
| 209 | + $cleaned = array(); |
|
| 210 | + |
|
| 211 | + // Check if the standard name is valid, or if the case is invalid. |
|
| 212 | + $installedStandards = Util\Standards::getInstalledStandards(); |
|
| 213 | + foreach ($value as $standard) { |
|
| 214 | + foreach ($installedStandards as $validStandard) { |
|
| 215 | + if (strtolower($standard) === strtolower($validStandard)) { |
|
| 216 | + $standard = $validStandard; |
|
| 217 | + break; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $cleaned[] = $standard; |
|
| 222 | - } |
|
| 221 | + $cleaned[] = $standard; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - $value = $cleaned; |
|
| 225 | - break; |
|
| 226 | - default : |
|
| 227 | - // No validation required. |
|
| 228 | - break; |
|
| 224 | + $value = $cleaned; |
|
| 225 | + break; |
|
| 226 | + default : |
|
| 227 | + // No validation required. |
|
| 228 | + break; |
|
| 229 | 229 | }//end switch |
| 230 | 230 | |
| 231 | 231 | $this->settings[$name] = $value; |
@@ -490,68 +490,68 @@ discard block |
||
| 490 | 490 | public function processShortArgument($arg, $pos) |
| 491 | 491 | { |
| 492 | 492 | switch ($arg) { |
| 493 | - case 'h': |
|
| 494 | - case '?': |
|
| 495 | - $this->printUsage(); |
|
| 496 | - exit(0); |
|
| 497 | - case 'i' : |
|
| 498 | - Util\Standards::printInstalledStandards(); |
|
| 499 | - exit(0); |
|
| 500 | - case 'v' : |
|
| 501 | - $this->verbosity++; |
|
| 502 | - $this->overriddenDefaults['verbosity'] = true; |
|
| 503 | - break; |
|
| 504 | - case 'l' : |
|
| 505 | - $this->local = true; |
|
| 506 | - $this->overriddenDefaults['local'] = true; |
|
| 507 | - break; |
|
| 508 | - case 's' : |
|
| 509 | - $this->showSources = true; |
|
| 510 | - $this->overriddenDefaults['showSources'] = true; |
|
| 511 | - break; |
|
| 512 | - case 'a' : |
|
| 513 | - $this->interactive = true; |
|
| 514 | - $this->overriddenDefaults['interactive'] = true; |
|
| 515 | - break; |
|
| 516 | - case 'e': |
|
| 517 | - $this->explain = true; |
|
| 518 | - $this->overriddenDefaults['explain'] = true; |
|
| 519 | - break; |
|
| 520 | - case 'p' : |
|
| 521 | - $this->showProgress = true; |
|
| 522 | - $this->overriddenDefaults['showProgress'] = true; |
|
| 523 | - break; |
|
| 524 | - case 'm' : |
|
| 525 | - $this->recordErrors = false; |
|
| 526 | - $this->overriddenDefaults['recordErrors'] = true; |
|
| 527 | - break; |
|
| 528 | - case 'd' : |
|
| 529 | - $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
| 530 | - $this->cliArgs[($pos + 1)] = ''; |
|
| 531 | - if (isset($ini[1]) === true) { |
|
| 532 | - ini_set($ini[0], $ini[1]); |
|
| 533 | - } else { |
|
| 534 | - ini_set($ini[0], true); |
|
| 535 | - } |
|
| 536 | - break; |
|
| 537 | - case 'n' : |
|
| 538 | - if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
| 539 | - $this->warningSeverity = 0; |
|
| 540 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
| 541 | - } |
|
| 542 | - break; |
|
| 543 | - case 'w' : |
|
| 544 | - if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
| 545 | - $this->warningSeverity = $this->errorSeverity; |
|
| 546 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
| 547 | - } |
|
| 548 | - break; |
|
| 549 | - default: |
|
| 550 | - if ($this->dieOnUnknownArg === false) { |
|
| 551 | - $this->values[$arg] = $arg; |
|
| 552 | - } else { |
|
| 553 | - $this->processUnknownArgument('-'.$arg, $pos); |
|
| 554 | - } |
|
| 493 | + case 'h': |
|
| 494 | + case '?': |
|
| 495 | + $this->printUsage(); |
|
| 496 | + exit(0); |
|
| 497 | + case 'i' : |
|
| 498 | + Util\Standards::printInstalledStandards(); |
|
| 499 | + exit(0); |
|
| 500 | + case 'v' : |
|
| 501 | + $this->verbosity++; |
|
| 502 | + $this->overriddenDefaults['verbosity'] = true; |
|
| 503 | + break; |
|
| 504 | + case 'l' : |
|
| 505 | + $this->local = true; |
|
| 506 | + $this->overriddenDefaults['local'] = true; |
|
| 507 | + break; |
|
| 508 | + case 's' : |
|
| 509 | + $this->showSources = true; |
|
| 510 | + $this->overriddenDefaults['showSources'] = true; |
|
| 511 | + break; |
|
| 512 | + case 'a' : |
|
| 513 | + $this->interactive = true; |
|
| 514 | + $this->overriddenDefaults['interactive'] = true; |
|
| 515 | + break; |
|
| 516 | + case 'e': |
|
| 517 | + $this->explain = true; |
|
| 518 | + $this->overriddenDefaults['explain'] = true; |
|
| 519 | + break; |
|
| 520 | + case 'p' : |
|
| 521 | + $this->showProgress = true; |
|
| 522 | + $this->overriddenDefaults['showProgress'] = true; |
|
| 523 | + break; |
|
| 524 | + case 'm' : |
|
| 525 | + $this->recordErrors = false; |
|
| 526 | + $this->overriddenDefaults['recordErrors'] = true; |
|
| 527 | + break; |
|
| 528 | + case 'd' : |
|
| 529 | + $ini = explode('=', $this->cliArgs[($pos + 1)]); |
|
| 530 | + $this->cliArgs[($pos + 1)] = ''; |
|
| 531 | + if (isset($ini[1]) === true) { |
|
| 532 | + ini_set($ini[0], $ini[1]); |
|
| 533 | + } else { |
|
| 534 | + ini_set($ini[0], true); |
|
| 535 | + } |
|
| 536 | + break; |
|
| 537 | + case 'n' : |
|
| 538 | + if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
| 539 | + $this->warningSeverity = 0; |
|
| 540 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
| 541 | + } |
|
| 542 | + break; |
|
| 543 | + case 'w' : |
|
| 544 | + if (isset($this->overriddenDefaults['warningSeverity']) === false) { |
|
| 545 | + $this->warningSeverity = $this->errorSeverity; |
|
| 546 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
| 547 | + } |
|
| 548 | + break; |
|
| 549 | + default: |
|
| 550 | + if ($this->dieOnUnknownArg === false) { |
|
| 551 | + $this->values[$arg] = $arg; |
|
| 552 | + } else { |
|
| 553 | + $this->processUnknownArgument('-'.$arg, $pos); |
|
| 554 | + } |
|
| 555 | 555 | }//end switch |
| 556 | 556 | |
| 557 | 557 | }//end processShortArgument() |
@@ -568,176 +568,176 @@ discard block |
||
| 568 | 568 | public function processLongArgument($arg, $pos) |
| 569 | 569 | { |
| 570 | 570 | switch ($arg) { |
| 571 | - case 'help': |
|
| 572 | - $this->printUsage(); |
|
| 573 | - exit(0); |
|
| 574 | - case 'version': |
|
| 575 | - echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') '; |
|
| 576 | - echo 'by Squiz (http://www.squiz.net)'.PHP_EOL; |
|
| 577 | - exit(0); |
|
| 578 | - case 'cache': |
|
| 579 | - if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false) { |
|
| 580 | - $this->cache = true; |
|
| 571 | + case 'help': |
|
| 572 | + $this->printUsage(); |
|
| 573 | + exit(0); |
|
| 574 | + case 'version': |
|
| 575 | + echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') '; |
|
| 576 | + echo 'by Squiz (http://www.squiz.net)'.PHP_EOL; |
|
| 577 | + exit(0); |
|
| 578 | + case 'cache': |
|
| 579 | + if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false) { |
|
| 580 | + $this->cache = true; |
|
| 581 | + $this->overriddenDefaults['cache'] = true; |
|
| 582 | + } |
|
| 583 | + break; |
|
| 584 | + case 'no-cache': |
|
| 585 | + $this->cache = false; |
|
| 581 | 586 | $this->overriddenDefaults['cache'] = true; |
| 582 | - } |
|
| 583 | - break; |
|
| 584 | - case 'no-cache': |
|
| 585 | - $this->cache = false; |
|
| 586 | - $this->overriddenDefaults['cache'] = true; |
|
| 587 | - break; |
|
| 588 | - default: |
|
| 589 | - if (substr($arg, 0, 7) === 'sniffs=') { |
|
| 590 | - $sniffs = explode(',', substr($arg, 7)); |
|
| 591 | - foreach ($sniffs as $sniff) { |
|
| 592 | - if (substr_count($sniff, '.') !== 2) { |
|
| 593 | - echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
| 594 | - $this->printUsage(); |
|
| 595 | - exit(2); |
|
| 587 | + break; |
|
| 588 | + default: |
|
| 589 | + if (substr($arg, 0, 7) === 'sniffs=') { |
|
| 590 | + $sniffs = explode(',', substr($arg, 7)); |
|
| 591 | + foreach ($sniffs as $sniff) { |
|
| 592 | + if (substr_count($sniff, '.') !== 2) { |
|
| 593 | + echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL; |
|
| 594 | + $this->printUsage(); |
|
| 595 | + exit(2); |
|
| 596 | + } |
|
| 596 | 597 | } |
| 597 | - } |
|
| 598 | 598 | |
| 599 | - $this->sniffs = $sniffs; |
|
| 600 | - $this->overriddenDefaults['sniffs'] = true; |
|
| 601 | - } else if (substr($arg, 0, 10) === 'bootstrap=') { |
|
| 602 | - $files = explode(',', substr($arg, 10)); |
|
| 603 | - $bootstrap = array(); |
|
| 604 | - foreach ($files as $file) { |
|
| 605 | - $path = Util\Common::realpath($file); |
|
| 606 | - if ($path === false) { |
|
| 607 | - echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
| 608 | - $this->printUsage(); |
|
| 609 | - exit(2); |
|
| 599 | + $this->sniffs = $sniffs; |
|
| 600 | + $this->overriddenDefaults['sniffs'] = true; |
|
| 601 | + } else if (substr($arg, 0, 10) === 'bootstrap=') { |
|
| 602 | + $files = explode(',', substr($arg, 10)); |
|
| 603 | + $bootstrap = array(); |
|
| 604 | + foreach ($files as $file) { |
|
| 605 | + $path = Util\Common::realpath($file); |
|
| 606 | + if ($path === false) { |
|
| 607 | + echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; |
|
| 608 | + $this->printUsage(); |
|
| 609 | + exit(2); |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + $bootstrap[] = $path; |
|
| 610 | 613 | } |
| 611 | 614 | |
| 612 | - $bootstrap[] = $path; |
|
| 613 | - } |
|
| 615 | + $this->bootstrap = array_merge($this->bootstrap, $bootstrap); |
|
| 616 | + $this->overriddenDefaults['bootstrap'] = true; |
|
| 617 | + } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
| 618 | + $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
| 614 | 619 | |
| 615 | - $this->bootstrap = array_merge($this->bootstrap, $bootstrap); |
|
| 616 | - $this->overriddenDefaults['bootstrap'] = true; |
|
| 617 | - } else if (substr($arg, 0, 11) === 'stdin-path=') { |
|
| 618 | - $this->stdinPath = Util\Common::realpath(substr($arg, 11)); |
|
| 620 | + // It may not exist and return false instead, so use whatever they gave us. |
|
| 621 | + if ($this->stdinPath === false) { |
|
| 622 | + $this->stdinPath = trim(substr($arg, 11)); |
|
| 623 | + } |
|
| 619 | 624 | |
| 620 | - // It may not exist and return false instead, so use whatever they gave us. |
|
| 621 | - if ($this->stdinPath === false) { |
|
| 622 | - $this->stdinPath = trim(substr($arg, 11)); |
|
| 623 | - } |
|
| 625 | + $this->overriddenDefaults['stdinPath'] = true; |
|
| 626 | + } else if (substr($arg, 0, 9) === 'basepath=') { |
|
| 627 | + if (isset($this->overriddenDefaults['basepath']) === true) { |
|
| 628 | + break; |
|
| 629 | + } |
|
| 624 | 630 | |
| 625 | - $this->overriddenDefaults['stdinPath'] = true; |
|
| 626 | - } else if (substr($arg, 0, 9) === 'basepath=') { |
|
| 627 | - if (isset($this->overriddenDefaults['basepath']) === true) { |
|
| 628 | - break; |
|
| 629 | - } |
|
| 631 | + $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
| 630 | 632 | |
| 631 | - $this->basepath = Util\Common::realpath(substr($arg, 9)); |
|
| 633 | + // It may not exist and return false instead. |
|
| 634 | + if ($this->basepath === false) { |
|
| 635 | + $this->basepath = substr($arg, 9); |
|
| 636 | + } |
|
| 632 | 637 | |
| 633 | - // It may not exist and return false instead. |
|
| 634 | - if ($this->basepath === false) { |
|
| 635 | - $this->basepath = substr($arg, 9); |
|
| 636 | - } |
|
| 638 | + $this->overriddenDefaults['basepath'] = true; |
|
| 637 | 639 | |
| 638 | - $this->overriddenDefaults['basepath'] = true; |
|
| 640 | + if (is_dir($this->basepath) === false) { |
|
| 641 | + echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
| 642 | + $this->printUsage(); |
|
| 643 | + exit(2); |
|
| 644 | + } |
|
| 645 | + } else if (substr($arg, 0, 7) === 'filter=') { |
|
| 646 | + if (isset($this->overriddenDefaults['filter']) === true) { |
|
| 647 | + break; |
|
| 648 | + } |
|
| 639 | 649 | |
| 640 | - if (is_dir($this->basepath) === false) { |
|
| 641 | - echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; |
|
| 642 | - $this->printUsage(); |
|
| 643 | - exit(2); |
|
| 644 | - } |
|
| 645 | - } else if (substr($arg, 0, 7) === 'filter=') { |
|
| 646 | - if (isset($this->overriddenDefaults['filter']) === true) { |
|
| 647 | - break; |
|
| 648 | - } |
|
| 650 | + $this->filter = substr($arg, 7); |
|
| 651 | + $this->overriddenDefaults['filter'] = true; |
|
| 652 | + } else if (substr($arg, 0, 9) === 'standard=') { |
|
| 653 | + $standards = trim(substr($arg, 9)); |
|
| 654 | + if ($standards !== '') { |
|
| 655 | + $this->standards = explode(',', $standards); |
|
| 656 | + } |
|
| 649 | 657 | |
| 650 | - $this->filter = substr($arg, 7); |
|
| 651 | - $this->overriddenDefaults['filter'] = true; |
|
| 652 | - } else if (substr($arg, 0, 9) === 'standard=') { |
|
| 653 | - $standards = trim(substr($arg, 9)); |
|
| 654 | - if ($standards !== '') { |
|
| 655 | - $this->standards = explode(',', $standards); |
|
| 656 | - } |
|
| 658 | + $this->overriddenDefaults['standards'] = true; |
|
| 659 | + } else if (substr($arg, 0, 11) === 'extensions=') { |
|
| 660 | + $extensions = explode(',', substr($arg, 11)); |
|
| 661 | + $newExtensions = array(); |
|
| 662 | + foreach ($extensions as $ext) { |
|
| 663 | + $slash = strpos($ext, '/'); |
|
| 664 | + if ($slash !== false) { |
|
| 665 | + // They specified the tokenizer too. |
|
| 666 | + list($ext, $tokenizer) = explode('/', $ext); |
|
| 667 | + $newExtensions[$ext] = strtoupper($tokenizer); |
|
| 668 | + continue; |
|
| 669 | + } |
|
| 657 | 670 | |
| 658 | - $this->overriddenDefaults['standards'] = true; |
|
| 659 | - } else if (substr($arg, 0, 11) === 'extensions=') { |
|
| 660 | - $extensions = explode(',', substr($arg, 11)); |
|
| 661 | - $newExtensions = array(); |
|
| 662 | - foreach ($extensions as $ext) { |
|
| 663 | - $slash = strpos($ext, '/'); |
|
| 664 | - if ($slash !== false) { |
|
| 665 | - // They specified the tokenizer too. |
|
| 666 | - list($ext, $tokenizer) = explode('/', $ext); |
|
| 667 | - $newExtensions[$ext] = strtoupper($tokenizer); |
|
| 668 | - continue; |
|
| 671 | + if (isset($this->extensions[$ext]) === true) { |
|
| 672 | + $newExtensions[$ext] = $this->extensions[$ext]; |
|
| 673 | + } else { |
|
| 674 | + $newExtensions[$ext] = 'PHP'; |
|
| 675 | + } |
|
| 669 | 676 | } |
| 670 | 677 | |
| 671 | - if (isset($this->extensions[$ext]) === true) { |
|
| 672 | - $newExtensions[$ext] = $this->extensions[$ext]; |
|
| 673 | - } else { |
|
| 674 | - $newExtensions[$ext] = 'PHP'; |
|
| 675 | - } |
|
| 676 | - } |
|
| 678 | + $this->extensions = $newExtensions; |
|
| 679 | + $this->overriddenDefaults['extensions'] = true; |
|
| 680 | + } else if (substr($arg, 0, 7) === 'suffix=') { |
|
| 681 | + $this->suffix = explode(',', substr($arg, 7)); |
|
| 682 | + $this->overriddenDefaults['suffix'] = true; |
|
| 683 | + } else if (substr($arg, 0, 9) === 'parallel=') { |
|
| 684 | + $this->parallel = max((int) substr($arg, 9), 1); |
|
| 685 | + $this->overriddenDefaults['parallel'] = true; |
|
| 686 | + } else if (substr($arg, 0, 9) === 'severity=') { |
|
| 687 | + $this->errorSeverity = (int) substr($arg, 9); |
|
| 688 | + $this->warningSeverity = $this->errorSeverity; |
|
| 689 | + $this->overriddenDefaults['errorSeverity'] = true; |
|
| 690 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
| 691 | + } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
| 692 | + $this->errorSeverity = (int) substr($arg, 15); |
|
| 693 | + $this->overriddenDefaults['errorSeverity'] = true; |
|
| 694 | + } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
| 695 | + $this->warningSeverity = (int) substr($arg, 17); |
|
| 696 | + $this->overriddenDefaults['warningSeverity'] = true; |
|
| 697 | + } else if (substr($arg, 0, 7) === 'ignore=') { |
|
| 698 | + // Split the ignore string on commas, unless the comma is escaped |
|
| 699 | + // using 1 or 3 slashes (\, or \\\,). |
|
| 700 | + $patterns = preg_split( |
|
| 701 | + '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
| 702 | + substr($arg, 7) |
|
| 703 | + ); |
|
| 704 | + |
|
| 705 | + $ignored = array(); |
|
| 706 | + foreach ($patterns as $pattern) { |
|
| 707 | + $pattern = trim($pattern); |
|
| 708 | + if ($pattern === '') { |
|
| 709 | + continue; |
|
| 710 | + } |
|
| 677 | 711 | |
| 678 | - $this->extensions = $newExtensions; |
|
| 679 | - $this->overriddenDefaults['extensions'] = true; |
|
| 680 | - } else if (substr($arg, 0, 7) === 'suffix=') { |
|
| 681 | - $this->suffix = explode(',', substr($arg, 7)); |
|
| 682 | - $this->overriddenDefaults['suffix'] = true; |
|
| 683 | - } else if (substr($arg, 0, 9) === 'parallel=') { |
|
| 684 | - $this->parallel = max((int) substr($arg, 9), 1); |
|
| 685 | - $this->overriddenDefaults['parallel'] = true; |
|
| 686 | - } else if (substr($arg, 0, 9) === 'severity=') { |
|
| 687 | - $this->errorSeverity = (int) substr($arg, 9); |
|
| 688 | - $this->warningSeverity = $this->errorSeverity; |
|
| 689 | - $this->overriddenDefaults['errorSeverity'] = true; |
|
| 690 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
| 691 | - } else if (substr($arg, 0, 15) === 'error-severity=') { |
|
| 692 | - $this->errorSeverity = (int) substr($arg, 15); |
|
| 693 | - $this->overriddenDefaults['errorSeverity'] = true; |
|
| 694 | - } else if (substr($arg, 0, 17) === 'warning-severity=') { |
|
| 695 | - $this->warningSeverity = (int) substr($arg, 17); |
|
| 696 | - $this->overriddenDefaults['warningSeverity'] = true; |
|
| 697 | - } else if (substr($arg, 0, 7) === 'ignore=') { |
|
| 698 | - // Split the ignore string on commas, unless the comma is escaped |
|
| 699 | - // using 1 or 3 slashes (\, or \\\,). |
|
| 700 | - $patterns = preg_split( |
|
| 701 | - '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', |
|
| 702 | - substr($arg, 7) |
|
| 703 | - ); |
|
| 704 | - |
|
| 705 | - $ignored = array(); |
|
| 706 | - foreach ($patterns as $pattern) { |
|
| 707 | - $pattern = trim($pattern); |
|
| 708 | - if ($pattern === '') { |
|
| 709 | - continue; |
|
| 712 | + $ignored[$pattern] = 'absolute'; |
|
| 710 | 713 | } |
| 711 | 714 | |
| 712 | - $ignored[$pattern] = 'absolute'; |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - $this->ignored = $ignored; |
|
| 716 | - $this->overriddenDefaults['ignored'] = true; |
|
| 717 | - } else if (substr($arg, 0, 10) === 'generator=' |
|
| 718 | - && PHP_CodeSniffer_CBF === false |
|
| 719 | - ) { |
|
| 720 | - $this->generator = substr($arg, 10); |
|
| 721 | - $this->overriddenDefaults['generator'] = true; |
|
| 722 | - } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
| 723 | - $this->tabWidth = (int) substr($arg, 10); |
|
| 724 | - $this->overriddenDefaults['tabWidth'] = true; |
|
| 725 | - } else { |
|
| 726 | - if ($this->dieOnUnknownArg === false) { |
|
| 727 | - $eqPos = strpos($arg, '='); |
|
| 728 | - if ($eqPos === false) { |
|
| 729 | - $this->values[$arg] = $arg; |
|
| 715 | + $this->ignored = $ignored; |
|
| 716 | + $this->overriddenDefaults['ignored'] = true; |
|
| 717 | + } else if (substr($arg, 0, 10) === 'generator=' |
|
| 718 | + && PHP_CodeSniffer_CBF === false |
|
| 719 | + ) { |
|
| 720 | + $this->generator = substr($arg, 10); |
|
| 721 | + $this->overriddenDefaults['generator'] = true; |
|
| 722 | + } else if (substr($arg, 0, 10) === 'tab-width=') { |
|
| 723 | + $this->tabWidth = (int) substr($arg, 10); |
|
| 724 | + $this->overriddenDefaults['tabWidth'] = true; |
|
| 725 | + } else { |
|
| 726 | + if ($this->dieOnUnknownArg === false) { |
|
| 727 | + $eqPos = strpos($arg, '='); |
|
| 728 | + if ($eqPos === false) { |
|
| 729 | + $this->values[$arg] = $arg; |
|
| 730 | + } else { |
|
| 731 | + $value = substr($arg, ($eqPos + 1)); |
|
| 732 | + $arg = substr($arg, 0, $eqPos); |
|
| 733 | + $this->values[$arg] = $value; |
|
| 734 | + } |
|
| 730 | 735 | } else { |
| 731 | - $value = substr($arg, ($eqPos + 1)); |
|
| 732 | - $arg = substr($arg, 0, $eqPos); |
|
| 733 | - $this->values[$arg] = $value; |
|
| 736 | + $this->processUnknownArgument('--'.$arg, $pos); |
|
| 734 | 737 | } |
| 735 | - } else { |
|
| 736 | - $this->processUnknownArgument('--'.$arg, $pos); |
|
| 737 | - } |
|
| 738 | - }//end if |
|
| 738 | + }//end if |
|
| 739 | 739 | |
| 740 | - break; |
|
| 740 | + break; |
|
| 741 | 741 | }//end switch |
| 742 | 742 | |
| 743 | 743 | }//end processLongArgument() |