mirror of
https://github.com/danog/phpdoc-parser.git
synced 2024-12-02 09:28:02 +01:00
Do not add space if empty string
This commit is contained in:
parent
ea0b17460e
commit
fac86158ff
@ -271,7 +271,14 @@ class PhpDocNode implements Node
|
|||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return "/**\n * " . implode("\n * ", $this->children) . "\n */";
|
$children = array_map(
|
||||||
|
static function (PhpDocChildNode $child): string {
|
||||||
|
$s = (string) $child;
|
||||||
|
return $s === '' ? '' : ' ' . $s;
|
||||||
|
},
|
||||||
|
$this->children
|
||||||
|
);
|
||||||
|
return "/**\n *" . implode("\n *", $children) . "\n */";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,19 @@ final class NodePrintTest extends TestCase
|
|||||||
]),
|
]),
|
||||||
'/**
|
'/**
|
||||||
* It works
|
* It works
|
||||||
|
*/',
|
||||||
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
new PhpDocNode([
|
||||||
|
new PhpDocTextNode('It works'),
|
||||||
|
new PhpDocTextNode(''),
|
||||||
|
new PhpDocTextNode('with empty lines'),
|
||||||
|
]),
|
||||||
|
'/**
|
||||||
|
* It works
|
||||||
|
*
|
||||||
|
* with empty lines
|
||||||
*/',
|
*/',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user