Example #1
0
 /** @covers \phpDocumentor\Fileset\Collection::getFilenames() */
 public function testGetFilenamesWhenIgnorePatternHidesSomething()
 {
     // load the data test folder... must add non-default extensions first
     $this->fixture->setAllowedExtensions(array('phar', 'txt'));
     $this->fixture->getIgnorePatterns()->append('(phar)');
     $this->fixture->addDirectory($this->getNameOfDataDir());
     $files = $this->fixture->getFilenames();
     // this file should have been seen
     $this->assertContains(realpath($this->getNameOfDataDir() . 'fileWithText.txt'), $files);
     // this file should have been ignored
     $this->assertNotContains(realpath($this->getNameOfDataDir() . 'test.phar'), $files);
 }
Example #2
0
 /**
  * Iterates through the given files and builds the structure.xml file.
  *
  * @param \phpDocumentor\Fileset\Collection $files          A files container
  *     to parse.
  * @param bool                           $include_source whether to include
  *     the source in the generated output..
  *
  * @api
  *
  * @return bool|string
  */
 public function parseFiles(\phpDocumentor\Fileset\Collection $files, $include_source = false)
 {
     $timer = microtime(true);
     $this->exporter = new \phpDocumentor\Parser\Exporter\Xml\Xml($this);
     $this->exporter->initialize();
     $paths = $files->getFilenames();
     $this->log('Starting to process ' . count($paths) . ' files');
     $this->log('  Project root is:  ' . $files->getProjectRoot());
     $this->log('  Ignore paths are: ' . implode(', ', $files->getIgnorePatterns()->getArrayCopy()));
     if (count($paths) < 1) {
         throw new Exception('No files were found', Exception::NO_FILES_FOUND);
     }
     $file_count = count($paths);
     foreach ($paths as $key => $file) {
         $this->dispatch('parser.file.pre', array('file' => $file, 'progress' => array($key + 1, $file_count)));
         $this->parseFile($file, $include_source);
     }
     $this->exporter->finalize();
     $this->log('--');
     $this->log('Elapsed time to parse all files: ' . round(microtime(true) - $timer, 2) . 's');
     $this->log('Peak memory usage: ' . round(memory_get_peak_usage() / 1024 / 1024, 2) . 'M');
     return $this->exporter->getContents();
 }