Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23070 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57030 invoked by uid 1010); 2 May 2006 06:42:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 57015 invoked from network); 2 May 2006 06:42:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 May 2006 06:42:11 -0000 X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.5 (sometimes 2.4) (4) Received: from ([204.11.219.139:60906] helo=lerdorf.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 3D/5F-18514-24FF6544 for ; Tue, 02 May 2006 02:42:10 -0400 Received: from [192.168.200.106] (c-24-6-5-134.hsd1.ca.comcast.net [24.6.5.134]) (authenticated bits=0) by lerdorf.com (8.13.6/8.13.6/Debian-1) with ESMTP id k426g5nm007827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 1 May 2006 23:42:06 -0700 Message-ID: <4456FF3D.7030607@lerdorf.com> Date: Mon, 01 May 2006 23:42:05 -0700 User-Agent: Thunderbird 3.0a1 (Macintosh/20060414) MIME-Version: 1.0 To: pierre.php@gmail.com CC: internals@lists.php.net References: <20060501161754.64020950@localhost.localdomain> In-Reply-To: <20060501161754.64020950@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] ext/filter, add input_get_args, support of scalar or array result From: rasmus@lerdorf.com (Rasmus Lerdorf) 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' ); 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, ) ); -Rasmus