diff --git a/lib/PhpParser/Comment.php b/lib/PhpParser/Comment.php index 2c604c2f91..7e6e41a526 100644 --- a/lib/PhpParser/Comment.php +++ b/lib/PhpParser/Comment.php @@ -150,7 +150,7 @@ public function __toString() : string { * @return mixed|string */ public function getReformattedText() { - $text = trim($this->text); + $text = $this->text; $newlinePos = strpos($text, "\n"); if (false === $newlinePos) { // Single line comments don't need further processing diff --git a/test/PhpParser/CommentTest.php b/test/PhpParser/CommentTest.php index c51a26be8f..23174c7e08 100644 --- a/test/PhpParser/CommentTest.php +++ b/test/PhpParser/CommentTest.php @@ -31,7 +31,7 @@ public function testReformatting($commentText, $reformattedText) { public function provideTestReformatting() { return [ - ['// Some text' . "\n", '// Some text'], + ['// Some text', '// Some text'], ['/* Some text */', '/* Some text */'], [ '/** diff --git a/test/code/formatPreservation/classMethodNop.test b/test/code/formatPreservation/classMethodNop.test index e2ad5ae13e..61010210f5 100644 --- a/test/code/formatPreservation/classMethodNop.test +++ b/test/code/formatPreservation/classMethodNop.test @@ -65,7 +65,7 @@ class Foo { } } ----- -$stmts[0]->stmts[0]->stmts[0]->setAttribute('comments', [new Comment("// I'm a new comment\n")]); +$stmts[0]->stmts[0]->stmts[0]->setAttribute('comments', [new Comment("// I'm a new comment")]); -----