Fix PhpDocNode end newline print

This commit is contained in:
Tomas Votruba 2021-03-22 17:52:24 +01:00 committed by GitHub
parent b2169b6c87
commit 86b0a001af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -271,7 +271,7 @@ class PhpDocNode implements Node
public function __toString(): string
{
return "/**\n * " . implode("\n * ", $this->children) . '*/';
return "/**\n * " . implode("\n * ", $this->children) . "\n */";
}
}

View File

@ -0,0 +1,32 @@
<?php declare(strict_types = 1);
namespace PHPStan\PhpDocParser\Ast\PhpDoc;
use PHPStan\PhpDocParser\Ast\Node;
use PHPUnit\Framework\TestCase;
final class NodePrintTest extends TestCase
{
/**
* @dataProvider providePhpDocData
*/
public function testPrintMultiline(Node $node, string $expectedPrinted): void
{
$this->assertSame($expectedPrinted, (string) $node);
}
public function providePhpDocData(): \Iterator
{
yield [
new PhpDocNode([
new PhpDocTextNode('It works'),
]),
'/**
* It works
*/',
];
}
}