/** * Creates the tag objects. * * @param string $tags Tag block to parse. * * @return DocBlock\Tag[] */ private function parseTagBlock($tags) { $tags = $this->filterTagBlock($tags); if (!$tags) { return []; } $result = $this->splitTagBlockIntoTagLines($tags); foreach ($result as $key => $tagLine) { $result[$key] = $this->tagFactory->create(trim($tagLine)); } return $result; }
/** * Parses the stream of tokens in to a new set of tokens containing Tags. * * @param string[] $tokens * @param TypeContext $context * * @return string[]|Tag[] */ private function parse($tokens, TypeContext $context) { $count = count($tokens); $tagCount = 0; $tags = []; for ($i = 1; $i < $count; $i += 2) { $tags[] = $this->tagFactory->create($tokens[$i], $context); $tokens[$i] = '%' . ++$tagCount . '$s'; } //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) { $tokens[$i] = str_replace(['{@}', '{}'], ['@', '}'], $tokens[$i]); } return [implode('', $tokens), $tags]; }