don't fail when referenced env var does not exist
This commit is contained in:
parent
a8a9e69488
commit
8026609dc9
@ -466,7 +466,7 @@ final class Dotenv
|
||||
$value = '';
|
||||
}
|
||||
|
||||
if ('' === $value && isset($matches['default_value'])) {
|
||||
if ('' === $value && isset($matches['default_value']) && '' !== $matches['default_value']) {
|
||||
$unsupportedChars = strpbrk($matches['default_value'], '\'"{$');
|
||||
if (false !== $unsupportedChars) {
|
||||
throw $this->createFormatException(sprintf('Unsupported character "%s" found in the default value of variable "$%s".', $unsupportedChars[0], $name));
|
||||
|
@ -172,6 +172,7 @@ class DotenvTest extends TestCase
|
||||
["FOO=BAR\nBAR=\${NOTDEFINED:=TEST}", ['FOO' => 'BAR', 'NOTDEFINED' => 'TEST', 'BAR' => 'TEST']],
|
||||
["FOO=\nBAR=\${FOO:=TEST}", ['FOO' => 'TEST', 'BAR' => 'TEST']],
|
||||
["FOO=\nBAR=\$FOO:=TEST}", ['FOO' => 'TEST', 'BAR' => 'TEST}']],
|
||||
["FOO=foo\nFOOBAR=\${FOO}\${BAR}", ['FOO' => 'foo', 'FOOBAR' => 'foo']],
|
||||
];
|
||||
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
|
Reference in New Issue
Block a user