Пример #1
0
 public function addFile(SourceFile $file)
 {
     $path = $file->getRealPath();
     $node = $this->workDom->createElementNS('http://xml.phpdox.net/src', 'file');
     $node->setAttribute('name', basename($file->getBasename()));
     $node->setAttribute('size', $file->getSize());
     $node->setAttribute('time', date('c', $file->getMTime()));
     $node->setAttribute('unixtime', $file->getMTime());
     $node->setAttribute('sha1', sha1_file($file->getPathname()));
     $this->collection[$path] = $node;
     $changed = $this->isChanged($path);
     if (!$changed) {
         $node->setAttribute('xml', $this->original[$path]->getAttribute('xml'));
     }
     return $changed;
 }
Пример #2
0
 /**
  * @param FileInfo $file
  *
  * @throws CollectorException
  * @throws \TheSeer\phpDox\ProgressLoggerException
  *
  * @return bool
  */
 private function processFile(SourceFile $file)
 {
     try {
         if ($file->getSize() === 0) {
             $this->logger->progress('processed');
             return true;
         }
         $result = $this->backend->parse($file);
         if ($result->hasClasses()) {
             foreach ($result->getClasses() as $class) {
                 $this->project->addClass($class);
             }
         }
         if ($result->hasInterfaces()) {
             foreach ($result->getInterfaces() as $interface) {
                 $this->project->addInterface($interface);
             }
         }
         if ($result->hasTraits()) {
             foreach ($result->getTraits() as $trait) {
                 $this->project->addTrait($trait);
             }
         }
         $this->logger->progress('processed');
         return true;
     } catch (ParseErrorException $e) {
         $this->parseErrors[$file->getPathname()] = $e->getPrevious()->getMessage();
         $this->logger->progress('failed');
         return false;
     } catch (\Exception $e) {
         throw new CollectorException('Error while processing source file', CollectorException::ProcessingError, $e, $file);
     }
 }