[DotEnv] Fix variable substitution
This commit is contained in:
parent
48bb1953b9
commit
1dfcdc7000
@ -351,7 +351,7 @@ final class Dotenv
|
|||||||
}
|
}
|
||||||
|
|
||||||
$name = $matches[3];
|
$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])) {
|
if (!$matches[2] && isset($matches[4])) {
|
||||||
$value .= '}';
|
$value .= '}';
|
||||||
|
@ -63,6 +63,7 @@ class DotenvTest extends TestCase
|
|||||||
public function getEnvData()
|
public function getEnvData()
|
||||||
{
|
{
|
||||||
putenv('LOCAL=local');
|
putenv('LOCAL=local');
|
||||||
|
$_ENV['REMOTE'] = 'remote';
|
||||||
|
|
||||||
$tests = array(
|
$tests = array(
|
||||||
// spaces
|
// spaces
|
||||||
@ -134,6 +135,7 @@ class DotenvTest extends TestCase
|
|||||||
array('FOO=" \\$ "', array('FOO' => ' $ ')),
|
array('FOO=" \\$ "', array('FOO' => ' $ ')),
|
||||||
array('FOO=" $ "', array('FOO' => ' $ ')),
|
array('FOO=" $ "', array('FOO' => ' $ ')),
|
||||||
array('BAR=$LOCAL', array('BAR' => 'local')),
|
array('BAR=$LOCAL', array('BAR' => 'local')),
|
||||||
|
array('BAR=$REMOTE', array('BAR' => 'remote')),
|
||||||
array('FOO=$NOTDEFINED', array('FOO' => '')),
|
array('FOO=$NOTDEFINED', array('FOO' => '')),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user