From 7b409b2276606583c07274d260d5921807a9652c Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 26 Jul 2006 23:18:41 +0000 Subject: [PATCH] Improved fix for bug #38132 --- ext/reflection/php_reflection.c | 16 +++++----------- ext/reflection/tests/bug38132.phpt | 13 +++++++------ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index d6a5f909ed..62d30956fb 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2643,19 +2643,13 @@ ZEND_METHOD(reflection_class, getStaticProperties) ulong num_index; if (zend_hash_get_current_key_ex(CE_STATIC_MEMBERS(ce), &key, &key_len, &num_index, 0, &pos) != FAILURE && key) { - zval_add_ref(value); + char *prop_name, *class_name; - if (*key == '\0') { - *key++; - key_len--; - - } - if (*key == '*' && *(key+1) == '\0') { - *(key+1) = *key++; - key_len--; - } + zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); + + zval_add_ref(value); - zend_hash_update(Z_ARRVAL_P(return_value), key, key_len, value, sizeof(zval *), NULL); + zend_hash_update(Z_ARRVAL_P(return_value), prop_name, strlen(prop_name)+1, value, sizeof(zval *), NULL); } zend_hash_move_forward_ex(CE_STATIC_MEMBERS(ce), &pos); } diff --git a/ext/reflection/tests/bug38132.phpt b/ext/reflection/tests/bug38132.phpt index eaaca850d8..aeb6246b89 100755 --- a/ext/reflection/tests/bug38132.phpt +++ b/ext/reflection/tests/bug38132.phpt @@ -12,22 +12,23 @@ class foo { $class = new ReflectionClass('foo'); $properties = $class->getStaticProperties(); var_dump($properties, array_keys($properties)); -var_dump(isset($properties['*bar'])); // false -var_dump(isset($properties["\0*\0bar"])); // true - +var_dump(isset($properties['*bar'])); +var_dump(isset($properties["\0*\0bar"])); +var_dump(isset($properties["bar"])); ?> --EXPECT-- array(2) { - ["*bar"]=> + ["bar"]=> string(3) "baz" ["a"]=> string(1) "a" } array(2) { [0]=> - string(4) "*bar" + string(3) "bar" [1]=> string(1) "a" } -bool(true) bool(false) +bool(false) +bool(true) -- 2.50.1