-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Add defined
prefix for env var processor
#50791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking &ldqu 8000 o;Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I tried with bool first, but any other value than '1' or 'true' get interpreted as false:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
5f1f041
to
473fc19
Compare
Thank you @GaryPEGEOT. |
Allow to add a
defined
prefix:Returns
false
if the env var doesn't exist or if it's null or the empty string.Returns
true
otherwise.