From 36ec11386330b6039b247b41a6721bddecb26804 Mon Sep 17 00:00:00 2001 From: Ashoka de Wit Date: Fri, 11 Oct 2019 19:29:56 +0800 Subject: [PATCH] Append a newline to the buffer if not present When a file was loaded that did not end with a newline a new variable would be written on the same line as the last variable. --- src/Jackiedo/DotenvEditor/DotenvWriter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Jackiedo/DotenvEditor/DotenvWriter.php b/src/Jackiedo/DotenvEditor/DotenvWriter.php index 4e7e35d..fe10cd2 100644 --- a/src/Jackiedo/DotenvEditor/DotenvWriter.php +++ b/src/Jackiedo/DotenvEditor/DotenvWriter.php @@ -60,6 +60,10 @@ protected function ensureFileIsWritable($filePath) */ public function setBuffer($content) { + if ($content !== '' && substr($content, -1) !== PHP_EOL) { + $content .= PHP_EOL; + } + $this->buffer = $content; return $this; }