예제 #1
0
파일: Include.php 프로젝트: hjr3/Docblox
 /**
  * Get the type and name for this include.
  *
  * @param DocBlox_Token_Iterator $tokens
  *
  * @return void
  */
 protected function processGenericInformation(DocBlox_Token_Iterator $tokens)
 {
     $this->type = ucwords(strtolower(str_replace('_', ' ', substr($tokens->current()->getName(), 2))));
     if ($token = $tokens->gotoNextByType(T_CONSTANT_ENCAPSED_STRING, 10, array(';'))) {
         $this->setName(trim($token->getContent(), '\'"'));
     } elseif ($token = $tokens->gotoNextByType(T_VARIABLE, 10, array(';'))) {
         $this->setName(trim($token->getContent(), '\'"'));
     }
 }
예제 #2
0
 public function testGetTokenIdsOfParenthesisPair()
 {
     $this->object->seek(0);
     $this->object->gotoNextByType(T_FUNCTION, 0);
     $result = $this->object->getTokenIdsOfParenthesisPair();
     $this->assertInternalType('array', $result, 'Expected result to be an array');
     $this->assertArrayHasKey(0, $result, 'Expected result to have a start element');
     $this->assertArrayHasKey(1, $result, 'Expected result to have an end element');
     $this->assertEquals(17, $result[0], 'Expected the first brace to be at token id 17');
     $this->assertEquals(18, $result[1], 'Expected the closing brace to be at token id 18');
 }
예제 #3
0
파일: Constant.php 프로젝트: hjr3/Docblox
 /**
  * Retrieves the generic information.
  *
  * Finds out what the name and value is of this constant on top of the information found using the
  * DocBlox_Reflection_DocBlockedAbstract parent method.
  *
  * @param DocBlox_Token_Iterator $tokens
  *
  * @see DocBlox_Reflection_DocBlockedAbstract::processGenericInformation
  *
  * @return void
  */
 protected function processGenericInformation(DocBlox_Token_Iterator $tokens)
 {
     if ($tokens->current()->getContent() == 'define') {
         // find the first encapsed string and strip the opening and closing
         // apostrophe
         $name_token = $tokens->gotoNextByType(T_CONSTANT_ENCAPSED_STRING, 5, array(','));
         if (!$name_token) {
             $this->log('Unable to process constant in file ' . $tokens->getFilename() . ' at line ' . $tokens->current()->getLineNumber(), DocBlox_Core_Log::CRIT);
             return;
         }
         $this->setName(substr($name_token->getContent(), 1, -1));
         // skip to after the comma
         while ($tokens->current()->getContent() != ',') {
             if ($tokens->next() === false) {
                 break;
             }
         }
         // get everything until the closing brace and use that for value, take child parenthesis under consideration
         $value = '';
         $level = 0;
         while (!($tokens->current()->getContent() == ')' && $level == -1)) {
             if ($tokens->next() === false) {
                 break;
             }
             switch ($tokens->current()->getContent()) {
                 case '(':
                     $level++;
                     break;
                 case ')':
                     $level--;
                     break;
             }
             $value .= $tokens->current()->getContent();
         }
         $this->setValue(trim(substr($value, 0, -1)));
     } else {
         $this->setName($tokens->gotoNextByType(T_STRING, 5, array('='))->getContent());
         $this->setValue($this->findDefault($tokens));
     }
     parent::processGenericInformation($tokens);
 }
예제 #4
0
파일: File.php 프로젝트: hjr3/Docblox
 /**
  * Changes the active namespace indicator when a namespace token is
  * encountered to indicate that the space has changed.
  *
  * @param DocBlox_Token_Iterator $tokens Tokens to interpret with the
  *      pointer at the token to be processed.
  *
  * @return void
  */
 protected function processNamespace(DocBlox_Token_Iterator $tokens)
 {
     // collect all namespace parts
     $namespace = array();
     while ($token = $tokens->gotoNextByType(T_STRING, 5, array(';', '{'))) {
         $namespace[] = $token->getContent();
     }
     $namespace = implode('\\', $namespace);
     $this->active_namespace = $namespace;
 }