Exemple #1
0
 /**
  * Processes a short (-e) command line argument.
  *
  * @param string $arg The command line argument.
  * @param int    $pos The position of the argument on the command line.
  *
  * @return void
  */
 public function processShortArgument($arg, $pos)
 {
     switch ($arg) {
         case 'h':
         case '?':
             $this->printUsage();
             exit(0);
         case 'i':
             Util\Standards::printInstalledStandards();
             exit(0);
         case 'v':
             if ($this->quiet === true) {
                 // Ignore when quiet mode is enabled.
                 break;
             }
             $this->verbosity++;
             $this->overriddenDefaults['verbosity'] = true;
             break;
         case 'l':
             $this->local = true;
             $this->overriddenDefaults['local'] = true;
             break;
         case 's':
             $this->showSources = true;
             $this->overriddenDefaults['showSources'] = true;
             break;
         case 'a':
             $this->interactive = true;
             $this->overriddenDefaults['interactive'] = true;
             break;
         case 'e':
             $this->explain = true;
             $this->overriddenDefaults['explain'] = true;
             break;
         case 'p':
             if ($this->quiet === true) {
                 // Ignore when quiet mode is enabled.
                 break;
             }
             $this->showProgress = true;
             $this->overriddenDefaults['showProgress'] = true;
             break;
         case 'q':
             // Quiet mode disables a few other settings as well.
             $this->quiet = true;
             $this->showProgress = false;
             $this->verbosity = 0;
             $this->overriddenDefaults['quiet'] = true;
             break;
         case 'm':
             $this->recordErrors = false;
             $this->overriddenDefaults['recordErrors'] = true;
             break;
         case 'd':
             $ini = explode('=', $this->cliArgs[$pos + 1]);
             $this->cliArgs[$pos + 1] = '';
             if (isset($ini[1]) === true) {
                 ini_set($ini[0], $ini[1]);
             } else {
                 ini_set($ini[0], true);
             }
             break;
         case 'n':
             if (isset($this->overriddenDefaults['warningSeverity']) === false) {
                 $this->warningSeverity = 0;
                 $this->overriddenDefaults['warningSeverity'] = true;
             }
             break;
         case 'w':
             if (isset($this->overriddenDefaults['warningSeverity']) === false) {
                 $this->warningSeverity = $this->errorSeverity;
                 $this->overriddenDefaults['warningSeverity'] = true;
             }
             break;
         default:
             if ($this->dieOnUnknownArg === false) {
                 $this->values[$arg] = $arg;
             } else {
                 $this->processUnknownArgument('-' . $arg, $pos);
             }
     }
     //end switch
 }
Exemple #2
0
 /**
  * Init the rulesets and other high-level settings.
  *
  * @return void
  */
 private function init()
 {
     // Ensure this option is enabled or else line endings will not always
     // be detected properly for files created on a Mac with the /r line ending.
     ini_set('auto_detect_line_endings', true);
     // Check that the standards are valid.
     foreach ($this->config->standards as $standard) {
         if (Util\Standards::isInstalledStandard($standard) === false) {
             // They didn't select a valid coding standard, so help them
             // out by letting them know which standards are installed.
             echo 'ERROR: the "' . $standard . '" coding standard is not installed. ';
             Util\Standards::printInstalledStandards();
             exit(3);
         }
     }
     // Saves passing the Config object into other objects that only need
     // the verbostity flag for deubg output.
     if (defined('PHP_CODESNIFFER_VERBOSITY') === false) {
         define('PHP_CODESNIFFER_VERBOSITY', $this->config->verbosity);
     }
     // Create this class so it is autoloaded and sets up a bunch
     // of PHP_CodeSniffer-specific token type constants.
     $tokens = new Util\Tokens();
     // The ruleset contains all the information about how the files
     // should be checked and/or fixed.
     $this->ruleset = new Ruleset($this->config);
 }