bug #23434 [DotEnv] Fix variable substitution (brieucthomas)

This PR was merged into the 3.3 branch.

Discussion
----------

[DotEnv] Fix variable substitution

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23423
| License       | MIT
| Doc PR        | no

Commits
-------

1dfcdc7000 [DotEnv] Fix variable substitution
This commit is contained in:
Fabien Potencier 2017-07-06 15:57:36 +03:00
commit c3ec5c5361
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' => '')),
);