-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] use filter_var() instead of XmlUtils::phpize() in EnvVarProcessor #29042
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 “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
@@ -90,19 +89,19 @@ public function getEnv($prefix, $name, \Closure $getEnv) | |||
} | |||
|
|||
if ('bool' === $prefix) { | |||
return (bool) self::phpize($env); | |||
return (bool) (filter_var($env, FILTER_VALIDATE_BOOLEAN) ?: filter_var($env, FILTER_VALIDATE_INT) ?: filter_var($env, FILTER_VALIDATE_FLOAT)); |
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.
why allow ints or floats to be casted as bool, and not limit to bools only ?
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.
Because that's supported+tested today, and we shouldn't break BC.
merging into master as this is not a bug. |
Thank you @nicolas-grekas. |
… EnvVarProcessor (nicolas-grekas) This PR was submitted for the 3.4 branch but it was merged into the 4.2-dev branch instead (closes #29042). Discussion ---------- [DI] use filter_var() instead of XmlUtils::phpize() in EnvVarProcessor | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - #29041 made me realize that we don't need this dependency on the Config component: `filter_var()` is just fine. This allows using a few more legit values for boolean styles, which are already accepted in php.ini Commits ------- ce53261 [DI] use filter_var() instead of XmlUtils::phpize() in EnvVarProcessor
#29041 made me realize that we don't need this dependency on the Config component:
filter_var()
is just fine. This allows using a few more legit values for boolean styles, which are already accepted in php.ini