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/tests/Symfony/Tests/Component
Fabien Potencier 7b204ed23a merged branch drak/paramaterbag_filter (PR #2261)
Commits
-------

c4a0f79 Updates according to suggestions.
6aec789 Added tests.
54454ba Added generic filtering to ParameterBag.

Discussion
----------

Added generic filtering to ParameterBag.

Adds filtering convenience using PHP's filter_var() e.g.

    $request->get->filter($key, '', false, FITLER_SANITIZE_STRING);

See http://php.net/manual/en/filter.filters.php for capabilities.

---------------------------------------------------------------------------

by GromNaN at 2011/09/25 15:41:50 -0700

What is the use case ?

---------------------------------------------------------------------------

by drak at 2011/09/25 15:52:19 -0700

Input variable validation/sanitization.  ParameterBag has a few built in like `getAlnum()` for example.  This method offer's PHP's full filtering and sanitization suite.

---------------------------------------------------------------------------

by fabpot at 2011/09/27 00:56:41 -0700

Can you add some unit tests for this new feature?

---------------------------------------------------------------------------

by drak at 2011/09/27 00:58:56 -0700

Sure thing.

---------------------------------------------------------------------------

by drak at 2011/09/27 01:07:03 -0700

Before I make the commit, is the method name ok for you or would you prefer it is called `getFiltered()`?

---------------------------------------------------------------------------

by fabpot at 2011/09/27 01:13:46 -0700

`filter` sounds good to me.

---------------------------------------------------------------------------

by drak at 2011/09/27 02:37:01 -0700

I've added some tests.

---------------------------------------------------------------------------

by stloyd at 2011/09/27 02:42:42 -0700

@drak IMO you must check that user don't use unknown filter and/or flags for filter.

---------------------------------------------------------------------------

by drak at 2011/09/27 02:48:38 -0700

@stloyd - I'm not sure that's practical at all, this is a wrapper for a built-in PHP function and I don't understand why we would need validate arguments for a PHP function - it's the coder's job to use the API correctly - none of the inputs to this function are coming from a web request.  It would also mean that the API would need to keep track of any upstream changes to constants in the PHP engine (which are just integers after all).  It's really just not practical.

---------------------------------------------------------------------------

by stealth35 at 2011/09/27 05:16:50 -0700

@drak it's could be cool to use `filter_id` ✌️

    if (is_string) {
        $filter = filter_id($filter);
    }

---------------------------------------------------------------------------

by drak at 2011/09/27 07:05:42 -0700

@stealth35 regarding this

    if (is_string) {
        $filter = filter_id($filter);
    }

I believe strongly in the use of IDEs when coding and autocomplete nicely provides when you type `FILTER_`.  Additionally, `filter_id()` only works on filters, but not for the flags, so I'm not entirely sure how useful it would be overall compared to using a good IDE (which you need when working with complex frameworks anyhow, imo :)

---------------------------------------------------------------------------

by drak at 2011/09/27 07:30:10 -0700

Ok check it now.
2011-09-27 17:21:30 +02:00
..
BrowserKit [Tests] Use proper phpunit assertion functions: "assertTrue", "assertFalse", "assertNull" 2011-08-25 15:41:15 +02:00
ClassLoader [Classloader] Fixed failing test on Windows 2011-09-12 13:21:31 +02:00
Config added some missing accessors/mutators 2011-09-16 13:43:09 +02:00
Console [Console] Improved checks for InputArgument and InputOption constructor's $mode parameter. 2011-08-31 23:53:00 +02:00
CssSelector UnitTest 2011-06-29 18:22:32 +02:00
DependencyInjection merged 2.0 2011-09-25 11:52:31 +02:00
DomCrawler [DomCrawler] added unit tests for previous merge 2011-09-23 08:10:01 +02:00
EventDispatcher [EventDispatcher] Fix removeSubscriber() to work with priority syntax 2011-08-23 16:41:08 -04:00
Finder [Finder] added a convenience method Finder::create() 2011-06-14 14:18:24 +02:00
Form [Form] added tests for previous merge 2011-09-27 10:12:54 +02:00
HttpFoundation Updates according to suggestions. 2011-09-27 20:14:32 +05:45
HttpKernel Added lifetime/cleanup support. 2011-09-19 22:37:12 +02:00
Locale [Locale] Fix #2179 StubIntlDateFormatter support yy format 2011-09-16 13:12:22 +02:00
Process Adjust the way of checking for windows 2011-09-17 12:57:47 +02:00
Routing [Routing] fixed unit tests broken by previous merge 2011-09-23 20:56:18 +02:00
Security Removed executable bits from all php files 2011-09-09 15:16:17 +02:00
Serializer fix tests 2011-06-10 01:11:51 +02:00
Templating fixed CS 2011-06-23 13:39:36 +02:00
Translation merged 2.0 2011-09-21 20:14:11 +02:00
Validator Removed executable bits from all php files 2011-09-09 15:16:17 +02:00
Yaml fixed unit tests broken by previous merge 2011-09-23 07:59:44 +02:00