mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-17 15:18:17 +01:00
Don't ltrim when preserving formatting
We shouldn't ltrim when printing a whole file, that way we will not just fail to preserve formatting, but actually change semantics by dropping meaningful whitespace.
This commit is contained in:
parent
7785d2b887
commit
a3bc900a41
@ -540,7 +540,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter {
|
||||
$result = "<?php\n" . $this->pStmts($stmts, false);
|
||||
}
|
||||
|
||||
return ltrim($this->handleMagicTokens($result));
|
||||
return $this->handleMagicTokens($result);
|
||||
}
|
||||
|
||||
protected function pFallback(Node $node, int $precedence, int $lhsPrecedence): string {
|
||||
|
@ -110,3 +110,13 @@ function test()
|
||||
foo();
|
||||
baz();
|
||||
}
|
||||
-----
|
||||
|
||||
|
||||
<?php $x;
|
||||
-----
|
||||
/* Do nothing, but make sure leading newlines are preserved. */
|
||||
-----
|
||||
|
||||
|
||||
<?php $x;
|
||||
|
Loading…
x
Reference in New Issue
Block a user