Esempio n. 1
0
File: Dcd.php Progetto: horde/horde
 /**
  * Run the task.
  *
  * @param array &$options Additional options.
  *
  * @return integer Number of errors.
  */
 public function run(&$options)
 {
     $finder = new FinderFacade(array(realpath($this->_config->getPath() . '/lib')));
     $files = $finder->findFiles();
     $detector = new PHPDCD\Detector();
     $result = $detector->detectDeadCode($files, true);
     $this->_printResult($result);
 }
Esempio n. 2
0
 /**
  * Executes the current command.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $finder = new FinderFacade($input->getArgument('values'), $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'));
     $files = $finder->findFiles();
     if (empty($files)) {
         $output->writeln('No files found to scan');
         exit(1);
     }
     $quiet = $output->getVerbosity() == OutputInterface::VERBOSITY_QUIET;
     $detector = new Detector();
     $result = $detector->detectDeadCode($files, $input->getOption('recursive'));
     if (!$quiet) {
         $printer = new Text();
         $printer->printResult($output, $result);
         $output->writeln(\PHP_Timer::resourceUsage());
     }
 }
Esempio n. 3
0
 /**
  * @covers SebastianBergmann\PHPDCD\Detector::detectDeadCode
  */
 public function testIgnoreAbstractMethods()
 {
     $file = TEST_FILES_PATH . 'abstract_methods.php';
     $result = $this->detector->detectDeadCode(array($file), FALSE);
     $this->assertEquals(array('Painting::getShape'), array_keys($result));
 }
Esempio n. 4
0
 /**
  * @param $files
  *
  * @return array
  */
 protected function analyze($files)
 {
     $detector = new Detector();
     $issues = $detector->detectDeadCode($files, $this->config['enabled']);
     $reports = $this->formatter->formatResults($issues);
     foreach ($reports as $key => $report) {
         $this->defaultWriter->write($report);
     }
 }