예제 #1
0
 /**
  * Adds a file to the backend storage.
  *
  * @param \TokenReflection\Stream\StreamBase $tokenStream Token stream
  * @param \TokenReflection\ReflectionFile $file File reflection object
  * @return \TokenReflection\Broker\Backend\Memory
  */
 public function addFile(TokenReflection\Stream\StreamBase $tokenStream, TokenReflection\ReflectionFile $file)
 {
     if ($this->cacheTokenStreams) {
         $this->fileCache[$file->getName()] = $cacheFile = tempnam(sys_get_temp_dir(), 'trc');
         file_put_contents($cacheFile, serialize($tokenStream));
     }
     parent::addFile($tokenStream, $file);
     return $this;
 }
예제 #2
0
 /**
  * Adds a file to the backend storage.
  *
  * @param \TokenReflection\Stream\StreamBase $tokenStream Token stream
  * @param \TokenReflection\ReflectionFile    $file        File reflection object
  *
  * @return \TokenReflection\Broker\Backend\Memory
  */
 public function addFile(TokenReflection\Stream\StreamBase $tokenStream, TokenReflection\ReflectionFile $file)
 {
     $this->tokenStreams[$file->getName()] = $this->storingTokenStreams ? $tokenStream : true;
     $this->files[$file->getName()] = $file;
     $errors = array();
     foreach ($file->getNamespaces() as $fileNamespace) {
         try {
             $namespaceName = $fileNamespace->getName();
             if (!isset($this->namespaces[$namespaceName])) {
                 $this->namespaces[$namespaceName] = new TokenReflection\ReflectionNamespace($namespaceName, $file->getBroker());
             }
             $this->namespaces[$namespaceName]->addFileNamespace($fileNamespace);
         } catch (Exception\FileProcessingException $e) {
             $errors = array_merge($errors, $e->getReasons());
         } catch (\Exception $e) {
             echo $e->getTraceAsString();
             die($e->getMessage());
         }
     }
     // Reset all-*-cache
     $this->allClasses = null;
     $this->allFunctions = null;
     $this->allConstants = null;
     if (!empty($errors)) {
         throw new Exception\FileProcessingException($errors, $file);
     }
     return $this;
 }