You are here

public function Description::getParsedContents in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Description.php \phpDocumentor\Reflection\DocBlock\Description::getParsedContents()

Returns the parsed text of this description.

Return value

array An array of strings and tag objects, in the order they occur within the description.

File

vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Description.php, line 77

Class

Description
Parses a Description of a DocBlock or tag.

Namespace

phpDocumentor\Reflection\DocBlock

Code

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;
}