Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61440 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68666 invoked from network); 18 Jul 2012 21:05:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jul 2012 21:05:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:55329] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0C/54-46800-23527005 for ; Wed, 18 Jul 2012 17:05:55 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id B71A77000458 for ; Wed, 18 Jul 2012 22:05:51 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id 9IK7GiRU34gX for ; Wed, 18 Jul 2012 22:05:51 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 7C91B700044A for ; Wed, 18 Jul 2012 22:05:51 +0100 (WEST) Received: from damnation (unknown [IPv6:2001:470:94a2:4:c3b:c2a4:1058:64f9]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id E38192005297 for ; Wed, 18 Jul 2012 22:05:50 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "internals@lists.php.net" Date: Wed, 18 Jul 2012 23:05:45 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: User-Agent: Opera Mail/12.50 (Linux) Subject: zend_parse_parameters() improvements From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") 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 Please see the commit messages for the rationale. *Example: https://github.com/php/php-src/pull/13 (again more recently on https://github.com/php/php-src/pull/133 ) ** 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 } } -- Gustavo Lopes