Ejemplo n.º 1
0
 /**
  * Generate a DocBlock comment.
  *
  * @param DocBlock The DocBlock to serialize.
  * 
  * @return string The serialized doc block.
  */
 public function getDocComment(DocBlock $docblock)
 {
     $indent = str_repeat($this->indentString, $this->indent);
     $firstIndent = $this->isFirstLineIndented ? $indent : '';
     $text = $docblock->getText();
     if ($this->lineLength) {
         //3 === strlen(' * ')
         $wrapLength = $this->lineLength - strlen($indent) - 3;
         $text = wordwrap($text, $wrapLength);
     }
     $text = str_replace("\n", "\n{$indent} * ", $text);
     $comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";
     /** @var Tag $tag */
     foreach ($docblock->getTags() as $tag) {
         $tagText = (string) $tag;
         if ($this->lineLength) {
             $tagText = wordwrap($tagText, $wrapLength);
         }
         $tagText = str_replace("\n", "\n{$indent} * ", $tagText);
         $comment .= "{$indent} * {$tagText}\n";
     }
     $comment .= $indent . ' */';
     return $comment;
 }