bug #30990 Allow env processor to resolve :: (jderusse)

This PR was merged into the 4.3-dev branch.

Discussion
----------

Allow env processor to resolve `::`

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | N/A

The env processor resolve to null when no fallback are provided. ie. `env(default::NOT_EXISTS)`

Issue is that the regexp does not allow such pattern. thus made the feature unusable.

Commits
-------

6b6c24c618 Allow env processor to resolve `::`
This commit is contained in:
Nicolas Grekas 2019-04-07 23:36:42 +02:00
commit 408e4aa48e
2 changed files with 8 additions and 1 deletions

View File

@ -42,7 +42,7 @@ class EnvPlaceholderParameterBag extends ParameterBag
return $placeholder; // return first result
}
}
if (!preg_match('/^(?:\w++:)*+\w++$/', $env)) {
if (!preg_match('/^(?:\w*+:)*+\w++$/', $env)) {
throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name));
}

View File

@ -194,4 +194,11 @@ class EnvPlaceholderParameterBagTest extends TestCase
$bag->get('env(ARRAY_VAR)');
$bag->resolve();
}
public function testDefaultToNullAllowed()
{
$bag = new EnvPlaceholderParameterBag();
$bag->resolve();
$this->assertNotNull($bag->get('env(default::BAR)'));
}
}