Пример #1
0
 /** @covers \phpDocumentor\Fileset\Collection::addDirectories() */
 public function testAddDirectoriesWhenGivenTheSamePathTwiceDoesNotResultInDuplicatedFilenames()
 {
     $this->fixture->setAllowedExtensions(array('phar', 'txt'));
     $this->fixture->addDirectories(array($this->getNameOfDataDir()));
     $this->fixture->addDirectories(array($this->getNameOfDataDir()));
     $files = $this->fixture->getFilenames();
     $this->assertEquals($this->getCountOfDataDirFiles(), count($files));
 }
Пример #2
0
 /**
  * Returns the collection of files based on the input and configuration.
  *
  * @param InputInterface $input
  *
  * @return Collection
  */
 protected function getFileCollection($input)
 {
     /** @var ConfigurationHelper $configurationHelper */
     $configurationHelper = $this->getHelper('phpdocumentor_configuration');
     $this->files->setAllowedExtensions($configurationHelper->getOption($input, 'extensions', 'parser/extensions', array('php', 'php3', 'phtml'), true));
     $this->files->setIgnorePatterns($configurationHelper->getOption($input, 'ignore', 'files/ignore', array(), true));
     $ignoreHidden = $configurationHelper->getOption($input, 'hidden', 'files/ignore-hidden', 'off');
     $this->files->setIgnoreHidden($ignoreHidden !== 'off' && $ignoreHidden === false);
     $this->files->setFollowSymlinks($configurationHelper->getOption($input, 'ignore-symlinks', 'files/ignore-symlinks', 'off') == 'on');
     $file_options = (array) $configurationHelper->getOption($input, 'filename', 'files/files', array(), true);
     $added_files = array();
     foreach ($file_options as $glob) {
         if (!is_string($glob)) {
             continue;
         }
         $matches = glob($glob);
         if (is_array($matches)) {
             foreach ($matches as $file) {
                 if (!empty($file)) {
                     $file = realpath($file);
                     if (!empty($file)) {
                         $added_files[] = $file;
                     }
                 }
             }
         }
     }
     $this->files->addFiles($added_files);
     $directory_options = $configurationHelper->getOption($input, 'directory', 'files/directories', array(), true);
     $added_directories = array();
     foreach ($directory_options as $glob) {
         if (!is_string($glob)) {
             continue;
         }
         $matches = glob($glob, GLOB_ONLYDIR);
         if (is_array($matches)) {
             foreach ($matches as $dir) {
                 if (!empty($dir)) {
                     $dir = realpath($dir);
                     if (!empty($dir)) {
                         $added_directories[] = $dir;
                     }
                 }
             }
         }
     }
     $this->files->addDirectories($added_directories);
     return $this->files;
 }