function DescriptionFactory::create
Returns the parsed text of this description.
File
-
vendor/
phpdocumentor/ reflection-docblock/ src/ DocBlock/ DescriptionFactory.php, line 64
Class
- DescriptionFactory
- Creates a new Description object given a body of text.
Namespace
phpDocumentor\Reflection\DocBlockCode
public function create(string $contents, ?TypeContext $context = null) : Description {
$tokens = $this->lex($contents);
$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 "}".
//"%" is escaped to "%%" because of vsprintf.
//See unit tests for examples.
for ($i = 0; $i < $count; $i += 2) {
$tokens[$i] = str_replace([
'{@}',
'{}',
'%',
], [
'@',
'}',
'%%',
], $tokens[$i]);
}
return new Description(implode('', $tokens), $tags);
}