diff options
| author | Felipe Pena <felipe@php.net> | 2010-05-26 00:00:58 +0000 |
|---|---|---|
| committer | Felipe Pena <felipe@php.net> | 2010-05-26 00:00:58 +0000 |
| commit | 79d2aaf0f1775f89a775b2d2d793dff8bb0e7755 (patch) | |
| tree | 4fb7db3456c0369c1e000a22167d285056ebab99 | |
| parent | 433cb868d65545f021a63d994febae21a1abe8aa (diff) | |
| download | php-git-79d2aaf0f1775f89a775b2d2d793dff8bb0e7755.tar.gz | |
- Fixed bug #51905 (ReflectionParameter fails if default value is an array with an access to self::)
| -rw-r--r-- | Zend/zend_execute.h | 2 | ||||
| -rw-r--r-- | Zend/zend_execute_API.c | 14 | ||||
| -rw-r--r-- | ext/reflection/tests/bug51905.phpt | 28 |
3 files changed, 43 insertions, 1 deletions
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 78b79431a9..d0adabab06 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -156,6 +156,8 @@ static zend_always_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 a0dcb48e64..91e1b6aec8 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -684,13 +684,25 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco } 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-- +<?php + +class Bar { + const Y = 20; +} + +class Foo extends Bar { + const X = 12; + public function x($x = 1, $y = array(self::X), $z = parent::Y) {} +} + +$clazz = new ReflectionClass('Foo'); +$method = $clazz->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 |
