public function render(Formatter $formatter = null) { if ($formatter === null) { $formatter = new Formatter\PassthroughFormatter(); } return $formatter->format($this); }
/** * Renders this description as a string where the provided formatter will format the tags in the expected string * format. * * @param Formatter|null $formatter * * @return string */ public function render(Formatter $formatter = null) { if ($formatter === null) { $formatter = new PassthroughFormatter(); } $tags = []; foreach ($this->tags as $tag) { $tags[] = '{' . $formatter->format($tag) . '}'; } return vsprintf($this->bodyTemplate, $tags); }
/** * @param DocBlock $docblock * @param $wrapLength * @param $indent * @param $comment * @return string */ private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment) { foreach ($docblock->getTags() as $tag) { $formatter = new DocBlock\Tags\Formatter\PassthroughFormatter(); $tagText = $formatter->format($tag); if ($wrapLength !== null) { $tagText = wordwrap($tagText, $wrapLength); } $tagText = str_replace("\n", "\n{$indent} * ", $tagText); $comment .= "{$indent} * {$tagText}\n"; } return $comment; }
/** * @covers ::format * @uses \phpDocumentor\Reflection\DocBlock\Description * @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag * @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic */ public function testFormatterCallsToStringAndReturnsAStandardRepresentation() { $expected = '@unknown-tag This is a description'; $fixture = new PassthroughFormatter(); $this->assertSame($expected, $fixture->format(new Generic('unknown-tag', new Description('This is a description')))); }