Ejemplo n.º 1
0
        public function addFile(FileInfo $file) {
            $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()));

            $path = $file->getRealPath();
            $this->collection[$path] = $node;
            return $this->isChanged($path);
        }
Ejemplo n.º 2
0
 /**
  * @param FileInfo $file
  */
 private function processFile(FileInfo $file)
 {
     try {
         if ($file->getSize() === 0) {
             $this->logger->progress('processed');
             return true;
         }
         $result = $this->backend->parse(new SourceFile($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);
     }
 }