PHPMD\PHPMD::processFiles PHP Метод

processFiles() публичный Метод

This method will process all files that can be found in the given input path. It will apply rules defined in the comma-separated $ruleSets argument. The result will be passed to all given renderer instances.
public processFiles ( string $inputPath, string $ruleSets, array $renderers, RuleSetFactory $ruleSetFactory ) : void
$inputPath string
$ruleSets string
$renderers array
$ruleSetFactory RuleSetFactory
Результат void
    public function processFiles($inputPath, $ruleSets, array $renderers, RuleSetFactory $ruleSetFactory)
    {
        // Merge parsed excludes
        $this->ignorePatterns = array_merge($this->ignorePatterns, $ruleSetFactory->getIgnorePattern($ruleSets));
        $this->input = $inputPath;
        $report = new Report();
        $factory = new ParserFactory();
        $parser = $factory->create($this);
        foreach ($ruleSetFactory->createRuleSets($ruleSets) as $ruleSet) {
            $parser->addRuleSet($ruleSet);
        }
        $report->start();
        $parser->parse($report);
        $report->end();
        foreach ($renderers as $renderer) {
            $renderer->start();
        }
        foreach ($renderers as $renderer) {
            $renderer->renderReport($report);
        }
        foreach ($renderers as $renderer) {
            $renderer->end();
        }
        $this->violations = !$report->isEmpty();
    }

Usage Example

 /**
  * testLocalVariableUsedInDoubleQuoteStringGetsNotReported
  *
  * @return void
  * @outputBuffering enabled
  */
 public function testLocalVariableUsedInDoubleQuoteStringGetsNotReported()
 {
     $renderer = new TextRenderer();
     $renderer->setWriter(new StreamWriter(self::createTempFileUri()));
     $inputs = self::createCodeResourceUriForTest();
     $rules = 'unusedcode';
     $renderes = array($renderer);
     $factory = new RuleSetFactory();
     $phpmd = new PHPMD();
     $phpmd->processFiles($inputs, $rules, $renderes, $factory);
 }
All Usage Examples Of PHPMD\PHPMD::processFiles