function DescriptionFactory::lex
Strips the contents from superfluous whitespace and splits the description into a series of tokens.
Return value
string[] A series of tokens of which the description text is composed.
1 call to DescriptionFactory::lex()
- DescriptionFactory::create in vendor/
phpdocumentor/ reflection-docblock/ src/ DocBlock/ DescriptionFactory.php - Returns the parsed text of this description.
File
-
vendor/
phpdocumentor/ reflection-docblock/ src/ DocBlock/ DescriptionFactory.php, line 92
Class
- DescriptionFactory
- Creates a new Description object given a body of text.
Namespace
phpDocumentor\Reflection\DocBlockCode
private function lex(string $contents) : array {
$contents = $this->removeSuperfluousStartingWhitespace($contents);
// performance optimalization; if there is no inline tag, don't bother splitting it up.
if (strpos($contents, '{@') === false) {
return [
$contents,
];
}
return Utils::pregSplit('/\\{
# "{@}" 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', $contents, 0, PREG_SPLIT_DELIM_CAPTURE);
}