diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index a94034d55af..82d47e320b3 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -484,7 +484,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, const count = 0; if (properties && zend_hash_num_elements(properties)) { - ZEND_HASH_MAP_FOREACH_STR_KEY(properties, prop_name) { + ZEND_HASH_FOREACH_STR_KEY(properties, prop_name) { if (prop_name && ZSTR_LEN(prop_name) && ZSTR_VAL(prop_name)[0]) { /* skip all private and protected properties */ if (!zend_hash_exists(&ce->properties_info, prop_name)) { count++; diff --git a/ext/reflection/tests/gh16187.phpt b/ext/reflection/tests/gh16187.phpt new file mode 100644 index 00000000000..64aec52de93 --- /dev/null +++ b/ext/reflection/tests/gh16187.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-16187 (ReflectionClass::__toString() with unpacked properties) +--EXTENSIONS-- +simplexml +--FILE-- +'; +$simplexml = simplexml_load_string($xml); +$reflector = new ReflectionObject($simplexml['name']); +$reflector->__toString(); +?> +DONE +--EXPECT-- +DONE