Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61444 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77613 invoked from network); 18 Jul 2012 22:31:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jul 2012 22:31:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:35288] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/06-46800-75937005 for ; Wed, 18 Jul 2012 18:31:52 -0400 Received: by lbgc1 with SMTP id c1so3116374lbg.29 for ; Wed, 18 Jul 2012 15:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3gF+C8FvRZ3alZHtgcZFTaXu9gs8v+wJ8svyJrovRfk=; b=gOx62IG5dczrSXiXP8rw864nPQ3wRCw6SpPveb9B8c4yIjshRN684UtB6hIP5uE7Zw xLvpJwn42C2VI68MvfDdi+ZoXN6PDtpk+6XZMpr7tkspif+DnFaHCksZPQc4RMNPCIHg g0fCjqTU1SlzvcPFOtCwMoVkFG31MES+whSK0t4FTkSgVgRXCRg+6Fd3ZeRX8f6af3E/ 0UUk6wMjPrXK759fngr0ZYDRjf8lhDElkmOIRPN83PnNNTXwWbromkHxEHPchUhm6ahH gA46jm8LiTAd6/UbOMi0y59R+WbW27shS/Qn6F81I81CT/GCgYsfRSMK7a+iz6yJWiZE g+NQ== MIME-Version: 1.0 Received: by 10.112.17.200 with SMTP id q8mr2665871lbd.11.1342650708198; Wed, 18 Jul 2012 15:31:48 -0700 (PDT) Received: by 10.152.114.70 with HTTP; Wed, 18 Jul 2012 15:31:48 -0700 (PDT) In-Reply-To: References: Date: Thu, 19 Jul 2012 00:31:48 +0200 Message-ID: To: Gustavo Lopes Cc: "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] zend_parse_parameters() improvements From: nikita.ppv@gmail.com (Nikita Popov) On Wed, Jul 18, 2012 at 11:05 PM, Gustavo Lopes wrote: > 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 > } > } +1 The long/null issue comes up every once in a while. This is really useful. Nikita