1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-27 04:14:44 +01:00

Make sure that pretty printer preserves whitespace after <?php

This commit is contained in:
nikic 2014-04-21 11:15:33 +02:00
parent 947a897238
commit 2e195d7cb2

View File

@ -87,7 +87,7 @@ abstract class PrettyPrinterAbstract
public function prettyPrint(array $stmts) {
$this->preprocessNodes($stmts);
return trim(str_replace("\n" . $this->noIndentToken, "\n", $this->pStmts($stmts, false)));
return ltrim(str_replace("\n" . $this->noIndentToken, "\n", $this->pStmts($stmts, false)));
}
/**
@ -109,7 +109,7 @@ abstract class PrettyPrinterAbstract
* @return string Pretty printed statements
*/
public function prettyPrintFile(array $stmts) {
$p = $this->prettyPrint($stmts);
$p = rtrim($this->prettyPrint($stmts));
$p = preg_replace('/^\?>\n?/', '', $p, -1, $count);
$p = preg_replace('/<\?php$/', '', $p);