run() public method

The return value of this method can be used as an exit code. A value equal to EXIT_SUCCESS means that no violations or errors were found in the analyzed code. Otherwise this method will return a value equal to EXIT_VIOLATION. The use of flag --ignore-violations-on-exit will result to a EXIT_SUCCESS even if any violation is found.
public run ( CommandLineOptions $opts, RuleSetFactory $ruleSetFactory ) : integer
$opts CommandLineOptions
$ruleSetFactory PHPMD\RuleSetFactory
return integer
Exemplo n.º 1
0
 protected function runCommand(array $args)
 {
     $argv = $this->parseSugaredArgv($args);
     $config = $this->getConfig($argv['namespace']);
     $ruleSetFactory = new RuleSetFactory();
     $options = new CommandLineOptions($argv['args'], $ruleSetFactory->listAvailableRuleSets(), $config);
     $command = new Command();
     return $command->run($options, $ruleSetFactory);
 }
Exemplo n.º 2
0
 /**
  * The main method that can be used by a calling shell script, the return
  * value can be used as exit code.
  *
  * @param array $args The raw command line arguments array.
  *
  * @return integer
  */
 public static function main(array $args)
 {
     try {
         $ruleSetFactory = new RuleSetFactory();
         $options = new CommandLineOptions($args, $ruleSetFactory->listAvailableRuleSets());
         $command = new Command();
         $exitCode = $command->run($options, $ruleSetFactory);
     } catch (\Exception $e) {
         fwrite(STDERR, $e->getMessage());
         fwrite(STDERR, PHP_EOL);
         $exitCode = self::EXIT_EXCEPTION;
     }
     return $exitCode;
 }