Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c96920f

Browse files
committed
[Dotenv] FIX missing getenv
1 parent e85acdd commit c96920f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/Dotenv/Dotenv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ private function resolveVariables($value, array $loadedVars)
387387
} elseif (isset($this->values[$name])) {
388388
$value = $this->values[$name];
389389
} else {
390-
$value = '';
390+
$value = (string) getenv($name);
391391
}
392392

393393
if (!$matches['opening_brace'] && isset($matches['closing_brace'])) {

src/Symfony/Component/Dotenv/Tests/DotenvTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,16 @@ public function testGetVariablesValueFromEnvFirst()
314314
$this->assertSame('foo2_prod', $values['TEST2']);
315315
}
316316
}
317+
318+
public function testGetVariablesValueFromGetenv()
319+
{
320+
putenv('Foo=Bar');
321+
322+
$dotenv = new Dotenv(true);
323+
324+
$test = "Foo=\${Foo}";
325+
$values = $dotenv->parse($test);
326+
327+
$this->assertSame('Bar', $values['Foo']);
328+
}
317329
}

0 commit comments

Comments
 (0)