From: Felipe Pena Date: Wed, 26 May 2010 00:00:58 +0000 (+0000) Subject: - Fixed bug #51905 (ReflectionParameter fails if default value is an array with an... X-Git-Tag: php-5.2.14RC1~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f17687150b19c50bf29fb1d92520538351280af0;p=php - Fixed bug #51905 (ReflectionParameter fails if default value is an array with an access to self::) --- diff --git a/NEWS b/NEWS index cc6717566b..ef6105ce52 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,8 @@ PHP NEWS by Mateusz Kocielski. (Ilia) - Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with +- Fixed bug #51905 (ReflectionParameter fails if default value is an array + with an access to self::). (Felipe) constant array). (Felipe) - Fixed bug #51671 (imagefill does not work correctly for small images). (Pierre) diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 60a84671df..a409b6fc5e 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -140,6 +140,8 @@ static inline int i_zend_is_true(zval *op) } ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC); +ZEND_API int zval_update_constant_inline_change(zval **pp, void *arg TSRMLS_DC); +ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *arg TSRMLS_DC); ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC); /* dedicated Zend executor functions - do not use! */ diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 4ac5badea5..c8f4bf9ac1 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -584,12 +584,22 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco zend_hash_move_forward(Z_ARRVAL_P(p)); zval_dtor(&const_value); } - zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); + zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant_inline_change, (void *) scope TSRMLS_CC); zend_hash_internal_pointer_reset(Z_ARRVAL_P(p)); } return 0; } +ZEND_API int zval_update_constant_inline_change(zval **pp, void *scope TSRMLS_DC) +{ + return zval_update_constant_ex(pp, (void*)1, scope TSRMLS_CC); +} + +ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *scope TSRMLS_DC) +{ + return zval_update_constant_ex(pp, (void*)0, scope TSRMLS_CC); +} + ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC) { return zval_update_constant_ex(pp, arg, NULL TSRMLS_CC); diff --git a/ext/reflection/tests/bug51905.phpt b/ext/reflection/tests/bug51905.phpt new file mode 100644 index 0000000000..8969924e45 --- /dev/null +++ b/ext/reflection/tests/bug51905.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #51905 (ReflectionParameter fails if default value is an array with an access to self::) +--FILE-- +getMethod('x'); +foreach ($method->getParameters() as $param) { + if ( $param->isDefaultValueAvailable()) + echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n"; +} + +?> +--EXPECT-- +$x : 1 +$y : array ( + 0 => 12, +) +$z : 20