This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/HttpFoundation/Tests
Fabien Potencier 1eed20a3f6 feature #11086 [HttpFoundation] Added ParameterBag::getBoolean (peterjmit)
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
2014-06-16 09:42:55 +02:00
..
File Merge branch '2.3' into 2.4 2013-12-31 14:43:26 +01:00
Session [HttpFoundation] merge symfony/symfony#11009 into master 2014-06-06 14:10:28 +02:00
AcceptHeaderItemTest.php [HttpFoundation] Fix AcceptHeader 2012-11-13 17:18:54 +01:00
AcceptHeaderTest.php [HttpFoundation] Fix AcceptHeader 2012-11-13 17:18:54 +01:00
ApacheRequestTest.php moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
BinaryFileResponseTest.php BinaryFileResponse should also return 416 or 200 on some range-requets 2013-12-16 20:50:58 +01:00
CookieTest.php Merge branch '2.3' into 2.4 2013-11-26 17:40:27 +01:00
ExpressionRequestMatcherTest.php add expression request matcher tests 2014-03-03 18:30:41 +01:00
FileBagTest.php [HttpFoundation] Remove temporary files after tests run 2012-05-28 12:39:57 +05:45
HeaderBagTest.php Merge branch '2.1' 2012-12-11 11:41:51 +01:00
IpUtilsTest.php [HttpFoundation] refactored code to avoid code duplication 2013-04-20 17:49:57 +02:00
JsonResponseTest.php [HttpFoundation] JsonResponse::setEncodingOptions accepts also integer 2014-01-07 14:19:33 +01:00
ParameterBagTest.php [HttpFoundation] Added ParameterBag::getBoolean 2014-06-10 18:08:57 -04:00
RedirectResponseTest.php unify short ternary operator 2013-11-14 15:22:38 +01:00
RequestMatcherTest.php [HttpFoundation] Add a way to match a specific scheme in RequestMatcher #10556 2014-06-03 23:09:07 +02:00
RequestStackTest.php Revert "[HttpFoundation] removed test file not related to 2.3" 2014-03-04 08:36:26 +01:00
RequestTest.php Merge branch '2.3' into 2.4 2014-06-12 12:00:57 +02:00
ResponseHeaderBagTest.php Merge branch '2.1' into 2.2 2013-04-20 21:05:29 +02:00
ResponseTest.php Merge branch '2.3' into 2.4 2014-04-18 22:37:09 +02:00
ResponseTestCase.php added missing license blocks 2013-04-22 06:29:54 +02:00
ServerBagTest.php Fixing broken http auth digest in some circumstances (php-fpm + apache). 2013-09-07 07:57:27 +02:00
StreamedResponseTest.php StreamedResponseTest 2012-09-01 07:57:21 -04:00