Doctrine\Common\Annotations\DocParser::parse PHP Method

parse() public method

Parses the given docblock string for annotations.
public parse ( string $input, string $context = '' ) : array
$input string The docblock string to parse.
$context string The parsing context.
return array Array of annotations. If no annotations are found, an empty array is returned.
    public function parse($input, $context = '')
    {
        $pos = $this->findInitialTokenPosition($input);
        if ($pos === null) {
            return array();
        }
        $this->context = $context;
        $this->lexer->setInput(trim(substr($input, $pos), '* /'));
        $this->lexer->moveNext();
        return $this->Annotations();
    }

Usage Example

Beispiel #1
0
 /**
  * Dispatch annotations found in phpDoc with context given in second argument.
  *
  * @param string     $phpDoc     phpDoc
  * @param mixed      $context    context
  */
 private function processDocComment($phpDoc, $context = null)
 {
     $annotations = $this->docParser->parse($phpDoc);
     foreach ($annotations as $annotation) {
         $this->collection->dispatch(Events::TOKEN_PHP_ANNOTATION, new Context\PHP\Annotation($annotation, $context), $this->result);
     }
 }
All Usage Examples Of Doctrine\Common\Annotations\DocParser::parse