/** * 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); }
/** * Returns the first docblock preceding the active token within 10 tokens. * * Please note that the iterator cursor does not change with to this method. * * @param DocBlox_Token_Iterator $tokens * * @return DocBlox_Reflection_DocBlock|null */ protected function findDocBlock(DocBlox_Token_Iterator $tokens) { $result = null; $docblock = $tokens->findPreviousByType(T_DOC_COMMENT, 10, array('{', '}', ';')); try { $result = $docblock ? new DocBlox_Reflection_DocBlock($docblock->getContent()) : null; if ($result) { // attach line number to class, the DocBlox_Reflection_DocBlock does not know the number $result->line_number = $docblock->getLineNumber(); } } catch (Exception $e) { $this->log($e->getMessage(), Zend_Log::CRIT); } $this->validateDocBlock($this->filename, $docblock ? $docblock->getLineNumber() : 0, $result); // if the object has no DocBlock _and_ is not a Closure; throw a warning $type = substr(get_class($this), strrpos(get_class($this), '_') + 1); if (!$result && ($type !== 'Function' && $this->getName() !== 'Closure')) { $this->log('No DocBlock was found for ' . $type . ' ' . $this->getName() . ' in file ' . $tokens->getFilename() . ' on line ' . $this->getLineNumber(), Zend_Log::ERR); } return $result; }