Merge pull request #357 from AydinHassan/fix-description-formatting-with-escaping

Fix rendering a description when it contains escaped chars and no tags
This commit is contained in:
Jaap van Otterdijk
2024-03-12 22:17:14 +01:00
committed by GitHub
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 public function render(?Formatter $formatter = null): string
{ {
if ($this->tags === []) { if ($this->tags === []) {
return $this->bodyTemplate; return vsprintf($this->bodyTemplate, []);
} }
if ($formatter === null) { if ($formatter === null) {
+27
View File
@@ -142,4 +142,31 @@ class DescriptionTest extends TestCase
. 'inverseJoinColumns={@JoinColumn (name="column_id_2", referencedColumnName="id")})'; . 'inverseJoinColumns={@JoinColumn (name="column_id_2", referencedColumnName="id")})';
$this->assertSame($expected, (string) $fixture); $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);
}
} }