cvs: ZendEngine2 / zend_reflection_api.c /tests bug33312.phpt php-src NEWS

From: Date: Mon, 13 Jun 2005 07:55:10 +0000
Subject: cvs: ZendEngine2 / zend_reflection_api.c /tests bug33312.phpt php-src NEWS
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3795@lists.php.net to get a copy of this message
dmitry Mon Jun 13 03:55:10 2005 EDT Added files: /ZendEngine2/tests bug33312.phpt Modified files: /php-src NEWS /ZendEngine2 zend_reflection_api.c Log: Fixed bug #33312 (ReflectionParameter methods do not work correctly) http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1913&r2=1.1914&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1913 php-src/NEWS:1.1914 --- php-src/NEWS:1.1913 Sat Jun 11 16:19:34 2005 +++ php-src/NEWS Mon Jun 13 03:55:01 2005 @@ -1,5 +1,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? 2005, PHP 5.1 +- Fixed bug #33312 (ReflectionParameter methods do not work correctly). + (Dmitry) + 11 Jun 2005, PHP 5.1 Beta 2 - Fixed PDO shutdown problem (possible inifite loop running rollback on shutdown). (Wez) http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.157&r2=1.158&ty=u Index: ZendEngine2/zend_reflection_api.c diff -u ZendEngine2/zend_reflection_api.c:1.157 ZendEngine2/zend_reflection_api.c:1.158 --- ZendEngine2/zend_reflection_api.c:1.157 Fri Jun 10 06:22:36 2005 +++ ZendEngine2/zend_reflection_api.c Mon Jun 13 03:55:07 2005 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_reflection_api.c,v 1.157 2005/06/10 10:22:36 dmitry Exp $ */ +/* $Id: zend_reflection_api.c,v 1.158 2005/06/13 07:55:07 dmitry Exp $ */ #include "zend.h" #include "zend_API.h" #include "zend_exceptions.h" @@ -508,6 +508,24 @@ } /* }}} */ +/* {{{ _get_recv_opcode */ +static zend_op* _get_recv_op(zend_op_array *op_array, zend_uint offset) +{ + zend_op *op = op_array->opcodes; + zend_op *end = op + op_array->last; + + ++offset; + while (op < end) { + if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT) && + op->op1.u.constant.value.lval == offset) { + return op; + } + ++op; + } + return NULL; +} +/* }}} */ + /* {{{ _parameter_string */ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg_info *arg_info, zend_uint offset, zend_uint required, char* indent TSRMLS_DC) { @@ -537,8 +555,8 @@ string_printf(str, "$param%d", offset); } if (fptr->type == ZEND_USER_FUNCTION && offset >= required) { - zend_op *precv = &((zend_op_array*)fptr)->opcodes[offset*2 + 1]; - if (precv->opcode == ZEND_RECV_INIT && precv->op2.op_type != IS_UNUSED) { + zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset); + if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2.op_type != IS_UNUSED) { zval *zv, zv_copy; int use_copy; string_write(str, " = ", sizeof(" = ")-1); @@ -1798,8 +1816,8 @@ if (param->offset < param->required) { RETURN_FALSE; } - precv = &((zend_op_array*)param->fptr)->opcodes[param->offset*2 + 1]; - if (precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) { + precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); + if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) { RETURN_FALSE; } RETURN_TRUE; @@ -1827,8 +1845,8 @@ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); return; } - precv = &((zend_op_array*)param->fptr)->opcodes[param->offset*2 + 1]; - if (precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) { + precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); + if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); return; } http://cvs.php.net/co.php/ZendEngine2/tests/bug33312.phpt?r=1.1&p=1 Index: ZendEngine2/tests/bug33312.phpt +++ ZendEngine2/tests/bug33312.phpt --TEST-- Bug #33312 (ReflectionParameter methods do not work correctly) --FILE-- <?php class Foo { public function bar(Foo $foo, $bar = 'bar') { } } $class = new ReflectionClass('Foo'); $method = $class->getMethod('bar'); foreach ($method->getParameters() as $parameter) { if ($parameter->isDefaultValueAvailable()) { print $parameter->getDefaultValue()."\n"; } } ?> --EXPECT-- bar

« previous php.zend-engine.cvs (#3795) next »