phpDocumentor\Reflection\DocBlock\Description::getParsedContents PHP Method

getParsedContents() public method

Returns the parsed text of this description.
public getParsedContents ( ) : array
return array An array of strings and tag objects, in the order they occur within the description.
    public function getParsedContents()
    {
        if (null === $this->parsedContents) {
            $this->parsedContents = preg_split('/\\{
                    # "{@}" is not a valid inline tag. This ensures that
                    # we do not treat it as one, but treat it literally.
                    (?!@\\})
                    # We want to capture the whole tag line, but without the
                    # inline tag delimiters.
                    (\\@
                        # Match everything up to the next delimiter.
                        [^{}]*
                        # Nested inline tag content should not be captured, or
                        # it will appear in the result separately.
                        (?:
                            # Match nested inline tags.
                            (?:
                                # Because we did not catch the tag delimiters
                                # earlier, we must be explicit with them here.
                                # Notice that this also matches "{}", as a way
                                # to later introduce it as an escape sequence.
                                \\{(?1)?\\}
                                |
                                # Make sure we match hanging "{".
                                \\{
                            )
                            # Match content after the nested inline tag.
                            [^{}]*
                        )* # If there are more inline tags, match them as well.
                           # We use "*" since there may not be any nested inline
                           # tags.
                    )
                \\}/Sux', $this->contents, null, PREG_SPLIT_DELIM_CAPTURE);
            $count = count($this->parsedContents);
            for ($i = 1; $i < $count; $i += 2) {
                $this->parsedContents[$i] = Tag::createInstance($this->parsedContents[$i], $this->docblock);
            }
            //In order to allow "literal" inline tags, the otherwise invalid
            //sequence "{@}" is changed to "@", and "{}" is changed to "}".
            //See unit tests for examples.
            for ($i = 0; $i < $count; $i += 2) {
                $this->parsedContents[$i] = str_replace(array('{@}', '{}'), array('@', '}'), $this->parsedContents[$i]);
            }
        }
        return $this->parsedContents;
    }

Usage Example

Ejemplo n.º 1
0
 private function buildDescription($docBlock, $content = null)
 {
     if ($content === null) {
         $content = $docBlock->getText();
     }
     $desc = new Description($content, $docBlock);
     $parsedContents = $desc->getParsedContents();
     if (count($parsedContents) > 1) {
         // convert inline {@see} tag to custom type link
         foreach ($parsedContents as &$part) {
             if ($part instanceof Seetag) {
                 $reference = $part->getReference();
                 if (substr_compare($reference, 'Google\\Cloud', 0, 12) === 0) {
                     $part = $this->buildLink($reference);
                 }
             }
         }
         $content = implode('', $parsedContents);
     }
     $content = str_ireplace('[optional]', '', $content);
     return $this->markdown->parse($content);
 }
All Usage Examples Of phpDocumentor\Reflection\DocBlock\Description::getParsedContents