Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61448 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84297 invoked from network); 18 Jul 2012 23:11:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jul 2012 23:11:44 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.147 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.147 smtp147.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.147] ([67.192.241.147:51341] helo=smtp147.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/A8-46800-EA247005 for ; Wed, 18 Jul 2012 19:11:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp31.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id D7F7250203; Wed, 18 Jul 2012 19:11:39 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp31.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 81470501D7; Wed, 18 Jul 2012 19:11:39 -0400 (EDT) Message-ID: <500742AA.9070307@sugarcrm.com> Date: Wed, 18 Jul 2012 16:11:38 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Gustavo Lopes CC: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] zend_parse_parameters() improvements From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > Some deficiencies in zpp have been constrai > ning the implementation of common scenarios such as 'allow integer or > NULL'* or the more general 'allow different types for an argument'**. > > So I propose the changes in this branch: > > https://github.com/cataphract/php-src/compare/zpp_improv This looks interesting. I have a bit different idea about how to make "parameter not passed" scenario - see https://wiki.php.net/rfc/skipparams - but having something like l! would work in that case too. It'd be nice to have a description of these as an RFC though - so we could use it in the docs, when updating READMEs and for reference - tracking down commit messages is not very convenient. > Example: > http://lxr.php.net/xref/PHP_TRUNK/ext/intl/timezone/timezone_methods.cpp#143 > In this case, NULL, int and string are allowed. This would become much > simpler: > > if (arg == NULL || Z_TYPE_PP(arg) == IS_NULL) { > se = TimeZone::createEnumeration(); > } else { > long l; > char *s; > int s_len; > if (zend_parse_parameter(ZEND_PARSE_PARAMS_QUIET, > 1 TSRMLS_DC, arg, "l", &l) == SUCCESS) { > TimeZone::createEnumeration((int32_t) l); > } else if (zend_parse_parameter(ZEND_PARSE_PARAMS_QUIET, > 1 TSRMLS_DC, arg, "s", &s, &s_len) == SUCCESS) { > TimeZone::createEnumeration(s); > } else { > //raise errror > } Wait, didn't you say applying zpp to arg as l, then as s would change it? Or your function doesn't change it? In any case, I think giving access to single-parameter parsing is a good idea and allows functions to implement complex cases in more consistent manner - right now I know there are some functions that return different error messages than zpp does when they parse arguments, for example - this can be fixes. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227