On Wed, Jul 18, 2012 at 11:05 PM, Gustavo Lopes <[email protected]> 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