[DotEnv] Fix variable substitution

This commit is contained in:
Brieuc Thomas 2017-07-06 14:23:24 +02:00
parent 48bb1953b9
commit 1dfcdc7000
2 changed files with 3 additions and 1 deletions

View File

@ -351,7 +351,7 @@ final class Dotenv
}
$name = $matches[3];
$value = isset($this->values[$name]) ? $this->values[$name] : (isset($_ENV[$name]) ? isset($_ENV[$name]) : (string) getenv($name));
$value = isset($this->values[$name]) ? $this->values[$name] : (isset($_ENV[$name]) ? $_ENV[$name] : (string) getenv($name));
if (!$matches[2] && isset($matches[4])) {
$value .= '}';

View File

@ -63,6 +63,7 @@ class DotenvTest extends TestCase
public function getEnvData()
{
putenv('LOCAL=local');
$_ENV['REMOTE'] = 'remote';
$tests = array(
// spaces
@ -134,6 +135,7 @@ class DotenvTest extends TestCase
array('FOO=" \\$ "', array('FOO' => ' $ ')),
array('FOO=" $ "', array('FOO' => ' $ ')),
array('BAR=$LOCAL', array('BAR' => 'local')),
array('BAR=$REMOTE', array('BAR' => 'remote')),
array('FOO=$NOTDEFINED', array('FOO' => '')),
);