[DependencyInjection] Add defined prefix for env var processor#50791
[DependencyInjection] Add defined prefix for env var processor#50791nicolas-grekas merged 1 commit intosymfony:6.4from GaryPEGEOT:feat/defined-processor
defined prefix for env var processor#50791Conversation
|
|
I tried with bool first, but any other value than '1' or 'true' get interpreted as false: |
There was a problem hiding this comment.
Sounds like a useful feature.
src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php
Outdated
Show resolved
Hide resolved
That's unexpected. We use FILTER_VALIDATE_BOOL, which handles way more cases. The test suite is also proving that. |
;) personally im not to fond of turning we do this in runtime for some env: however, in hindsight i'd split it into 2 envs, rather than 1 conditional env, thus: |
There was a problem hiding this comment.
On second thought, we already do have the NO_COLOR env vars which works like that, and this is indeed not the same as bool.
On the behavior side, this should not throw when the env var is not defined. It does current if I'm not wrong.
The check should be moved below the code handling "default" and should account for not found vars. I would also not use empty but use a comparison to the empty string only.
@nicolas-grekas maybe check for |
|
|
|
Fixed the checks and added a few test cases |
src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php
Outdated
Show resolved
Hide resolved
|
@nicolas-grekas but as we don't use |
|
Thank you @GaryPEGEOT. |
Allow to add a
definedprefix:Returns
falseif the env var doesn't exist or if it's null or the empty string.Returns
trueotherwise.