RE: [PHP-DEV] ext/filter, add input_get_args, support of scalar orarray result
| From: | Jared Williams | Date: | Tue, 02 May 2006 12:28:39 +0000 |
| Subject: | RE: [PHP-DEV] ext/filter, add input_get_args, support of scalar orarray result | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-23074@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Rasmus Lerdorf [mailto:rasmus@lerdorf.com]
> Sent: 02 May 2006 07:42
> To: pierre.php@gmail.com
> Cc: internals@lists.php.net
> Subject: Re: [PHP-DEV] ext/filter, add input_get_args,
> support of scalar orarray result
>
> Pierre wrote:
> > I put a small example here:
> >
> > http://pecl.php.net/~pierre/filter_input_get_args_example.phps
> >
> > and the patch:
> >
> > http://pecl.php.net/~pierre/patch_filter_input_get_args.txt
>
> I think this looks ok. I have been trying to come up with a
> shorter and cleaner syntax to specify these things, but so
> far I haven't come up with anything I really like. The
> closest I have come is something like
> this:
>
> $args = array(
> 'product_id' => 'Enc',
> 'component' => 'Int:Array:1-10',
> 'versions' => 'Enc',
> 'doesnotexist' => 'Int',
> 'testscalar' => 'Int:Scalar',
> 'testarray' => 'Int:Array'
> );
Would a little helper function to create the array be a little neater (and less typing :) for the
more common complex options?
$args = array(
'component' => somefunc(FILTER_VALIDATE_INT, FILTER_FLAG_ARRAY, 1, 10);
);
>
> But I am not completely happy with the magic shortcuts in the
> strings there. The above would be equivalent to:
>
> $args = array(
> 'product_id' => FILTER_SANITIZE_ENCODED,
> 'component' => array('filter' => FILTER_VALIDATE_INT,
> 'flags' => FILTER_FLAG_ARRAY,
> 'options' => array("min_range"=>1,
> "max_range"=>10)
> ),
> 'versions' => FILTER_SANITIZE_ENCODED,
> 'doesnotexist' => FILTER_VALIDATE_INT,
> 'testscalar' => array(
> 'filter' => FILTER_VALIDATE_INT,
> 'flags' => FILTER_FLAG_SCALAR,
>
> ),
> 'testarray' => array(
> 'filter' => FILTER_VALIDATE_INT,
> 'flags' => FILTER_FLAG_ARRAY,
> )
>
> );
Jared