Skip to content

Commit

Permalink
Trim useless whitespace
Browse files Browse the repository at this point in the history
@jaxwilko's favourite piece of the whole ArrayFile parser ;)
  • Loading branch information
LukeTowers committed Mar 4, 2022
1 parent cf98dcf commit 9fda6cd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Parse/PHP/ArrayFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@ public function constant(string $name): PHPConstant
*/
public function render(): string
{
return $this->printer->prettyPrintFile($this->ast) . "\n";
// Make sure lines with only indentation are trimmed
return preg_replace(
'/^\s+$/m',
'',
$this->printer->prettyPrintFile($this->ast) . "\n"
);
}

/**
Expand Down

0 comments on commit 9fda6cd

Please sign in to comment.