diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/reflection/php_reflection.c | 30 | ||||
-rw-r--r-- | ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt | 31 |
2 files changed, 50 insertions, 11 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index ebc34e902d..0c9a8dbed1 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -457,7 +457,6 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in zend_class_constant *c; ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, c) { - zval_update_constant_ex(&c->value, c->ce); _class_const_string(str, ZSTR_VAL(key), c, ZSTR_VAL(sub_indent.buf)); } ZEND_HASH_FOREACH_END(); } @@ -622,12 +621,16 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in static void _const_string(string *str, char *name, zval *value, char *indent) { char *type = zend_zval_type_name(value); - zend_string *value_str = zval_get_string(value); - string_printf(str, "%s Constant [ %s %s ] { %s }\n", - indent, type, name, ZSTR_VAL(value_str)); - - zend_string_release(value_str); + if (Z_TYPE_P(value) == IS_ARRAY) { + string_printf(str, "%s Constant [ %s %s ] { Array }\n", + indent, type, name); + } else { + zend_string *value_str = zval_get_string(value); + string_printf(str, "%s Constant [ %s %s ] { %s }\n", + indent, type, name, ZSTR_VAL(value_str)); + zend_string_release(value_str); + } } /* }}} */ @@ -635,17 +638,22 @@ static void _const_string(string *str, char *name, zval *value, char *indent) static void _class_const_string(string *str, char *name, zend_class_constant *c, char *indent) { char *visibility = zend_visibility_string(Z_ACCESS_FLAGS(c->value)); - zend_string *value_str; char *type; zval_update_constant_ex(&c->value, c->ce); - value_str = zval_get_string(&c->value); type = zend_zval_type_name(&c->value); - string_printf(str, "%sConstant [ %s %s %s ] { %s }\n", - indent, visibility, type, name, ZSTR_VAL(value_str)); + if (Z_TYPE(c->value) == IS_ARRAY) { + string_printf(str, "%sConstant [ %s %s %s ] { Array }\n", + indent, visibility, type, name); + } else { + zend_string *value_str = zval_get_string(&c->value); + + string_printf(str, "%sConstant [ %s %s %s ] { %s }\n", + indent, visibility, type, name, ZSTR_VAL(value_str)); - zend_string_release(value_str); + zend_string_release(value_str); + } } /* }}} */ diff --git a/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt new file mode 100644 index 0000000000..9ccc285433 --- /dev/null +++ b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt @@ -0,0 +1,31 @@ +--TEST-- +ReflectionClass::export() - array constants +--FILE-- +<?php +Class A { + const A = 8; + const B = ["a", "b"]; +} +ReflectionClass::export("A"); +?> +--EXPECTF-- +Class [ <user> class A ] { + @@ %s 2-5 + + - Constants [2] { + Constant [ public integer A ] { 8 } + Constant [ public array B ] { Array } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [0] { + } +} |