Skip to content

Commit d400e28

Browse files
Merge branch '3.6'
2 parents 0e1d107 + 82cccaa commit d400e28

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/Loader/Lines.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static function process(array $lines)
2222
foreach ($lines as $line) {
2323
list($multiline, $line, $multilineBuffer) = self::multilineProcess($multiline, $line, $multilineBuffer);
2424

25-
if (!$multiline && !self::isComment($line) && self::isSetter($line)) {
25+
if (!$multiline && !self::isCommentOrWhitespace($line)) {
2626
$output[] = $line;
2727
}
2828
}
@@ -116,28 +116,20 @@ private static function getCharPairs($line)
116116
}
117117

118118
/**
119-
* Determine if the line in the file is a comment, e.g. begins with a #.
119+
* Determine if the line in the file is a comment or whitespace.
120120
*
121121
* @param string $line
122122
*
123123
* @return bool
124124
*/
125-
private static function isComment($line)
125+
private static function isCommentOrWhitespace($line)
126126
{
127+
if (trim($line) === '') {
128+
return true;
129+
}
130+
127131
$line = ltrim($line);
128132

129133
return isset($line[0]) && $line[0] === '#';
130134
}
131-
132-
/**
133-
* Determine if the given line looks like it's setting a variable.
134-
*
135-
* @param string $line
136-
*
137-
* @return bool
138-
*/
139-
private static function isSetter($line)
140-
{
141-
return strpos($line, '=') !== false;
142-
}
143135
}

tests/Dotenv/DotenvTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ public function testMutlilineLoading()
272272
$this->assertSame('https://vision.googleapis.com/v1/images:annotate?key=', getenv('TEST_EQS'));
273273
}
274274

275+
public function testEmptyLoading()
276+
{
277+
$dotenv = Dotenv::createImmutable($this->folder, 'empty.env');
278+
$this->assertSame(['EMPTY_VAR' => null], $dotenv->load());
279+
}
280+
275281
public function testLegacyConstructor()
276282
{
277283
$loader = new Loader();

tests/fixtures/env/empty.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EMPTY_VAR

0 commit comments

Comments
 (0)