Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #11086 [HttpFoundation] Added ParameterBag::getBoolean (peter…
…jmit) This PR was merged into the 2.3-dev branch. Discussion ---------- [HttpFoundation] Added ParameterBag::getBoolean | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a At the moment to pull a boolean value from a request the user has to use `ParameterBag::filter` or use `filter_var` directly ```php // GET /products?hide_archived=true $request->query->filter('hide_archived', false, false, FILTER_VALIDATE_BOOLEAN); // or filter_var($request->query->get('hide_archived'), FILTER_VALIDATE_BOOLEAN); ``` This is a pure convenience addition, adding a nice way of pulling a boolean value from a query string or request body (especially if http form/url encoded). Example usage: ```php // GET /products?hide_archived=true $request->query->getBoolean('hide_archived'); // (boolean) true $request->query->get('hide_archived'); // (string) "true" // GET /products?hide_archived=1 $request->query->getBoolean('hide_archived'); // (boolean) true // GET /products?hide_archived=false $request->query->getBoolean('hide_archived'); // (boolean) false // GET /products?hide_archived=banana $request->query->getBoolean('hide_archived'); // (boolean) false ``` Commits ------- 36c58f8 [HttpFoundation] Added ParameterBag::getBoolean
- Loading branch information