Esempio n. 1
0
 /**
  * Sets the tokens for this file.
  *
  * @param array(array) $tokens The generated tokens.
  *
  * @return void
  */
 public function setTokens(array $tokens)
 {
     $storage = PHP_Depend_StorageRegistry::get(PHP_Depend::TOKEN_STORAGE);
     $storage->store($tokens, md5($this->_fileName), __CLASS__);
 }
Esempio n. 2
0
 /**
  * Sets a new php source file.
  *
  * @param string $sourceFile A php source file.
  *
  * @return void
  */
 public function setSourceFile($sourceFile)
 {
     $storage = PHP_Depend_StorageRegistry::get(PHP_Depend::PARSER_STORAGE);
     $id = '$Id$-@package_version@';
     $key = md5_file($sourceFile);
     $group = get_class($this->_tokenizer);
     $tokens = $storage->restore($key, $group, $id);
     if (is_array($tokens)) {
         $this->_sourceFile = new PHP_Depend_Code_File($sourceFile);
         $this->_sourceFile->setTokens($tokens);
     } else {
         $this->_tokenizer->setSourceFile($sourceFile);
         $this->_sourceFile = $this->_tokenizer->getSourceFile();
         $tokens = $this->_sourceFile->getTokens();
         $storage->store($tokens, $key, $group, $id);
     }
     $this->_tokens = $tokens;
     $this->_index = 0;
     $this->_count = count($tokens);
 }
Esempio n. 3
0
 /**
  * Sets the tokens found in the function body.
  *
  * @param array(mixed) $tokens The body tokens.
  *
  * @return void
  */
 public function setTokens(array $tokens)
 {
     $storage = PHP_Depend_StorageRegistry::get(PHP_Depend::TOKEN_STORAGE);
     $storage->store($tokens, $this->getUUID(), get_class($this));
 }
Esempio n. 4
0
 /**
  * Sets the tokens found in the function body.
  *
  * @param array(mixed) $tokens The body tokens.
  *
  * @return void
  */
 public function setTokens(array $tokens)
 {
     $this->_startLine = reset($tokens)->startLine;
     $this->_endLine = end($tokens)->endLine;
     $storage = PHP_Depend_StorageRegistry::get(PHP_Depend::TOKEN_STORAGE);
     $storage->store($tokens, $this->getUUID(), get_class($this));
 }
Esempio n. 5
0
 /**
  * Tests that the registry throws an exception when an invalid engine key
  * is used.
  *
  * @return void
  */
 public function testRegistryThrowsExpectedExceptionForInvalidEngineKey()
 {
     $storageKey = uniqid(md5(rand(0, PHP_INT_MAX)), true);
     $this->setExpectedException('OutOfRangeException', sprintf('Invalid storage identifier "%s" given.', $storageKey));
     PHP_Depend_StorageRegistry::get($storageKey);
 }