/** * This method will process all files that can be found in the given input * path. It will apply rules defined in the comma-separated <b>$ruleSets</b> * argument. The result will be passed to all given renderer instances. * * @param string $inputPath File or directory * @param string $ruleSets Rule-sets to apply * @param array(PHP_PMD_AbstractRenderer) $renderers Report renderers * @param PHP_PMD_RuleSetFactory $ruleSetFactory The factory to use * * @return void */ public function processFiles($inputPath, $ruleSets, array $renderers, PHP_PMD_RuleSetFactory $ruleSetFactory) { $this->_input = $inputPath; $report = new PHP_PMD_Report(); $factory = new PHP_PMD_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(); }
/** * testFactoryConfiguresFileExtensions * * @return void * @covers PHP_PMD_ParserFactory * @group phpmd * @group unittest */ public function testFactoryConfiguresFileExtensions() { $factory = new PHP_PMD_ParserFactory(); $uri = $this->createFileUri('ParserFactory/File/Test.php'); $phpmd = $this->getMock('PHP_PMD'); $phpmd->expects($this->exactly(2))->method('getFileExtensions')->will($this->returnValue(array('.php'))); $phpmd->expects($this->once())->method('getInput')->will($this->returnValue($uri)); $parser = $factory->create($phpmd); }