mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Added "{}" around all double quoted variables, for readability's sake;
Performance improvement in Serializer - wrap length is calculated once during the text portion only. Tags reuse the result. Also no "prefix" adding in tags - the name is simply added before wrapping.
This commit is contained in:
@@ -243,7 +243,7 @@ class DocBlock implements \Reflector
|
|||||||
$long = $this->getLongDescription()->getContents();
|
$long = $this->getLongDescription()->getContents();
|
||||||
|
|
||||||
if ($long) {
|
if ($long) {
|
||||||
return $short . "\n\n" . $long;
|
return "{$short}\n\n{$long}";
|
||||||
} else {
|
} else {
|
||||||
return $short;
|
return $short;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,36 +172,23 @@ class Serializer
|
|||||||
|
|
||||||
$text = $docblock->getText();
|
$text = $docblock->getText();
|
||||||
if ($this->lineLength) {
|
if ($this->lineLength) {
|
||||||
$text = wordwrap(
|
//3 === strlen(' * ')
|
||||||
$text,
|
$wrapLength = $this->lineLength - strlen($indent) - 3;
|
||||||
$this->lineLength - strlen($indent) - 3/*strlen(' * ')*/
|
$text = wordwrap($text, $wrapLength);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$text = str_replace("\n", "\n$indent * ", $text);
|
$text = str_replace("\n", "\n{$indent} * ", $text);
|
||||||
|
|
||||||
$comment = "$firstIndent/**\n$indent * $text\n$indent *\n";
|
$comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";
|
||||||
|
|
||||||
/** @var Tag $tag */
|
/** @var Tag $tag */
|
||||||
foreach ($docblock->getTags() as $tag) {
|
foreach ($docblock->getTags() as $tag) {
|
||||||
$tagName = $tag->getName();
|
$tagText = "@{$tag->getName()} {$tag->getContent()}";
|
||||||
$prefixLength = 1/*strlen('@')*/ + strlen($tagName);
|
|
||||||
|
|
||||||
//Added to take the first line of the tag into account.
|
|
||||||
$tagContent = str_repeat(' ', $prefixLength) . $tag->getContent();
|
|
||||||
|
|
||||||
if ($this->lineLength) {
|
if ($this->lineLength) {
|
||||||
$tagContent = wordwrap(
|
$tagText = wordwrap($tagText, $wrapLength);
|
||||||
$tagContent,
|
|
||||||
$this->lineLength - strlen($indent) - 3/*strlen(' * ')*/
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
||||||
|
|
||||||
//Clean up the prefix.
|
$comment .= "{$indent} * {$tagText}\n";
|
||||||
substr_replace($tagContent, '', 0, $prefixLength);
|
|
||||||
|
|
||||||
$tagContent = str_replace("\n", "\n$indent * ", $tagContent);
|
|
||||||
|
|
||||||
$comment .= "$indent * @{$tagName} {$tagContent}\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment .= $indent . ' */';
|
$comment .= $indent . ' */';
|
||||||
|
|||||||
Reference in New Issue
Block a user