Author: Manuel Pichler (mapi@phpmd.org)
 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);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->outputHeading($output, 'PHP Mess Detector on %s');
     $files = $this->plugin->getFiles(Finder::create()->name('*.php'));
     if (count($files) === 0) {
         return $this->outputSkip($output);
     }
     $validate = new Validate();
     $rules = realpath($validate->filePath($input->getOption('rules')));
     $renderer = new MessDetectorRenderer($output, $this->moodle->directory);
     $renderer->setWriter(new StreamWriter(STDOUT));
     $ruleSetFactory = new RuleSetFactory();
     $ruleSetFactory->setMinimumPriority(5);
     $messDetector = new PHPMD();
     $messDetector->processFiles(implode(',', $files), $rules, [$renderer], $ruleSetFactory);
 }
示例#3
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;
 }