8000 Allow env processor to resolve `::` · symfony/symfony@56cb561 · GitHub
[go: up one dir, main page]

Skip to content

Commit 56cb561

Browse files
committed
Allow env processor to resolve ::
1 parent 50c22b3 commit 56cb561

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function get($name)
4242
return $placeholder; // return first result
4343
}
4444
}
45-
if (!preg_match('/^(?:\w++:)*+\w++$/', $env)) {
45+
if (!preg_match('/^(?:\w++::?)*+\w++$/', $env)) {
4646
throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name));
4747
}
4848

src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,22 @@ public function testGetThrowsOnBadDefaultValue()
194194
$bag->get('env(ARRAY_VAR)');
195195
$bag->resolve();
196196
}
197+
198+
public function testDefaultToNullAllowed()
199+
{
200+
$bag = new EnvPlaceholderParameterBag();
201+
$bag->resolve();
202+
$this->assertNotNull($bag->get('env(default::BAR)'));
203+
}
204+
205+
/**
206+
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
207+
* @expectedExceptionMessage Invalid env(default:::BAR) name: only "word" characters are allowed.
208+
*/
209+
public function testMalformedPattern()
210+
{
211+
$bag = new EnvPlaceholderParameterBag();
212+
$bag->resolve();
213+
$bag->get('env(default:::BAR)');
214+
}
197215
}

0 commit comments

Comments
 (0)
0