Bug #16013 [Opn->Csd]: proto doesn't support array properly when optional

From: Date: Tue, 10 Mar 2009 18:34:47 +0000
Subject: Bug #16013 [Opn->Csd]: proto doesn't support array properly when optional
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-136@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=16013&edit=1 ID: 16013 Updated by: tworeilly@gmail.com Reported By: tworeilly at gmail dot com Summary: proto doesn't support array properly when optional -Status: Open +Status: Closed Type: Bug Package: CodeGen_PECL Operating System: NA Package Version: 1.1.2 PHP Version: 5.2.5 -Assigned To: +Assigned To: tommyo Roadmap Versions: New Comment: -Status: Open +Status: Closed -Assigned To: +Assigned To: tommyo errors in trac caused bug to be opened multiple times. closing. Previous Comments: ------------------------------------------------------------------------ [2009-03-10 18:28:55] tommyo Description: ------------ CodeGen/PECL/Element/Function.php doesn't generate a proper default for arrays before sending to the parser, so when array is expected as optional, it chokes on HASH_OF if not sent. Patch attached. Test script: --------------- <function name="myMethod" access="public"> <proto>mixed myMethod( mixed url [, array extra ] )</proto> <code><![CDATA[RETURN_TRUE;]]></code> </function> Expected result: ---------------- /* {{{ proto mixed myMethod( mixed url [, array extra ] ) */ PHP_METHOD(Object, myMethod) { zend_class_entry * _this_ce; zval * _this_zval = NULL; zval * url = NULL; zval * extra; HashTable * extra_hash = NULL; MAKE_STD_ZVAL(extra); array_init(extra); if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz/|a/", &_this_zval, Object_ce_ptr, &url, &extra) == FAILURE) { return; } _this_ce = Z_OBJCE_P(_this_zval); extra_hash = HASH_OF(extra); do { RETURN_TRUE; } while (0); } /* }}} myMethod */ Actual result: -------------- /* {{{ proto mixed myMethod( mixed url [, array extra ] ) */ PHP_METHOD(Object, myMethod) { zend_class_entry * _this_ce; zval * _this_zval = NULL; zval * url = NULL; zval * extra = NULL; HashTable * extra_hash = NULL; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz/|a/", &_this_zval, Object_ce_ptr, &url, &extra) == FAILURE) { return; } _this_ce = Z_OBJCE_P(_this_zval); extra_hash = HASH_OF(extra); do { RETURN_TRUE; } while (0); } ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=16013&edit=1

« previous php.pear.bugs (#136) next »