getDefaults() public method

Get a list of default values for all possible command line arguments.
public getDefaults ( ) : array
return array
 /**
  * Run PHPCS on a file.
  *
  * Returns a string representation of the output that would normally
  * be printed to the console. Artifically sets the `-s` (showSources)
  * command line switch to make it possible to parse which rules failed
  * for a given sample file.
  *
  * @param string $file to run.
  * @return string The output from phpcs.
  */
 public function runPhpCs($file)
 {
     $defaults = $this->_phpcs->getDefaults();
     $standard = $this->_rootDir . '/ruleset.xml';
     if (defined('PHP_CodeSniffer::VERSION') && version_compare(PHP_CodeSniffer::VERSION, '1.5.0') != -1) {
         $standard = [$standard];
     }
     $options = ['encoding' => 'utf-8', 'files' => [$file], 'standard' => $standard, 'showSources' => true] + $defaults;
     // New PHPCS has a strange issue where the method arguments
     // are not stored on the instance causing weird errors.
     $reflection = new ReflectionProperty($this->_phpcs, 'values');
     $reflection->setAccessible(true);
     $reflection->setValue($this->_phpcs, $options);
     ob_start();
     $this->_phpcs->process($options);
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
Beispiel #2
0
 /**
  * Get a list of default values for all possible command line arguments.
  *
  * @return array
  */
 public function getDefaults()
 {
     $defaults = parent::getDefaults();
     $showLevel = PHP_CodeSniffer::getConfigData('show_level');
     if ($showLevel === null) {
         if ($defaults['showWarnings']) {
             $defaults['showLevel'] = SQLI_CodeSniffer_Reports::WARNING;
         } else {
             $defaults['showLevel'] = SQLI_CodeSniffer_Reports::ERROR;
         }
     } else {
         $defaults['showLevel'] = $showLevel;
     }
     return $defaults;
 }
 /**
  * Get a list of default values for all possible command line arguments.
  *
  * @return array
  */
 public function getDefaults()
 {
     $defaults = parent::getDefaults();
     $defaults['standard'] = array('Drupal');
     // The Sniffer tries really hard to discard its logs
     // ALL the time unless we tell it not to.
     // All these settings are just to prevent that amnesia.
     $defaults['showSources'] = TRUE;
     $defaults['verbosity'] = 1;
     $defaults['reports'] = array('full' => NULL);
     $defaults['warningSeverity'] = PHPCS_DEFAULT_WARN_SEV;
     // If the severities are left as the default (zero) then
     // NOTHING is considered worth logging or even counting!
     $this->warningSeverity = PHPCS_DEFAULT_WARN_SEV;
     $this->errorSeverity = PHPCS_DEFAULT_ERROR_SEV;
     return $defaults;
 }