Skip to content

[DependencyInjection] EnvPlaceholderParameterBag - Digits not allowed #63654

@tcoch

Description

@tcoch

Symfony version(s) affected

6.4

Description

https://github.com/symfony/symfony/blob/8.1/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php states that environment variables name can contain:

letters, digits, hyphens, backslashes and colons

NB: Support for dots have also been added recently (94182c8).

Turns out, hyphens are not supported. Since 6.4 at least.

How to reproduce

Checkout to branch 6.4 and add the following test in src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php:

public function testHyphensAllowed()
{
    $bag = new EnvPlaceholderParameterBag();
    $this->expectException(InvalidArgumentException::class);
    $bag->get('env(foo-bar)');
}

Possible Solution

Now, the question is: do we aim to fix this behavior (and actually support it), or fix the error message?

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions