Fix rendering a description when it contains escaped characters and no tags

This commit is contained in:
Aydin Hassan
2023-10-11 14:57:53 +02:00
parent 7b21721772
commit ae20798fde
2 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ class Description
public function render(?Formatter $formatter = null): string
{
if ($this->tags === []) {
return $this->bodyTemplate;
return vsprintf($this->bodyTemplate, []);
}
if ($formatter === null) {
+27
View File
@@ -142,4 +142,31 @@ class DescriptionTest extends TestCase
. 'inverseJoinColumns={@JoinColumn (name="column_id_2", referencedColumnName="id")})';
$this->assertSame($expected, (string) $fixture);
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
*
* @covers ::__construct
* @covers ::render
* @covers ::__toString
*/
public function testDescriptionWithEscapedCharactersAndNoTagsCanBeCastToString(): void
{
//% chars are escaped in \phpDocumentor\Reflection\DocBlock\DescriptionFactory::create
$body = <<<'EOT'
{%% for user in users %%}
{{ user.name }}
{%% endfor %%}';
EOT;
$expected = <<<'EOT'
{% for user in users %}
{{ user.name }}
{% endfor %}';
EOT;
$fixture = new Description($body, []);
$this->assertSame($expected, (string) $fixture);
}
}