diff options
| author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2011-02-03 12:38:25 +0000 |
|---|---|---|
| committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2011-02-03 12:38:25 +0000 |
| commit | f2329f1f4bff08bf61a7b8d82009a035f20d53c4 (patch) | |
| tree | a2d3a8f34c6c9db8c07112d9d6b96bdcd9fbcf8e | |
| parent | 1f4990299927a9fdf24676ebbd1c7f6729aa3838 (diff) | |
| download | php-git-f2329f1f4bff08bf61a7b8d82009a035f20d53c4.tar.gz | |
- Fixed bug #53915: ReflectionClass::getConstant(s) emits fatal error on
constants with self::.
- Reflown some NEWS entries to have lines no longer than 80 chars.
| -rw-r--r-- | ext/reflection/php_reflection.c | 9 | ||||
| -rw-r--r-- | ext/reflection/tests/bug53915.phpt | 28 |
2 files changed, 35 insertions, 2 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 760fc96b18..77bac956ea 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3973,6 +3973,11 @@ ZEND_METHOD(reflection_class, hasConstant) } /* }}} */ +static int _update_constant_ex_cb_wrapper(void *pDest, void *ce TSRMLS_DC) +{ + return zval_update_constant_ex(pDest, (void*)(zend_uintptr_t)1U, ce); +} + /* {{{ proto public array ReflectionClass::getConstants() Returns an associative array containing this class' constants and their values */ ZEND_METHOD(reflection_class, getConstants) @@ -3986,7 +3991,7 @@ ZEND_METHOD(reflection_class, getConstants) } GET_REFLECTION_OBJECT_PTR(ce); array_init(return_value); - zend_hash_apply_with_argument(&ce->constants_table, (apply_func_arg_t) zval_update_constant, (void*)1 TSRMLS_CC); + zend_hash_apply_with_argument(&ce->constants_table, _update_constant_ex_cb_wrapper, ce TSRMLS_CC); zend_hash_copy(Z_ARRVAL_P(return_value), &ce->constants_table, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *)); } /* }}} */ @@ -4007,7 +4012,7 @@ ZEND_METHOD(reflection_class, getConstant) } GET_REFLECTION_OBJECT_PTR(ce); - zend_hash_apply_with_argument(&ce->constants_table, (apply_func_arg_t) zval_update_constant, (void*)1 TSRMLS_CC); + zend_hash_apply_with_argument(&ce->constants_table, _update_constant_ex_cb_wrapper, ce TSRMLS_CC); if (zend_hash_find(&ce->constants_table, name, name_len + 1, (void **) &value) == FAILURE) { RETURN_FALSE; } diff --git a/ext/reflection/tests/bug53915.phpt b/ext/reflection/tests/bug53915.phpt new file mode 100644 index 0000000000..f2f2ae5675 --- /dev/null +++ b/ext/reflection/tests/bug53915.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #53915 - ReflectionClass::getConstant(s) emits fatal error on selfreferencing constants +--FILE-- +<?php +Class Foo +{ + const A = 1; + const B = self::A; +} + +$rc = new ReflectionClass('Foo'); +print_r($rc->getConstants()); + +Class Foo2 +{ + const A = 1; + const B = self::A; +} + +$rc = new ReflectionClass('Foo2'); +print_r($rc->getConstant('B')); +--EXPECT-- +Array +( + [A] => 1 + [B] => 1 +) +1 |
