Skip to content

Commit 8c32212

Browse files
GH-16187: fix ReflectionClass::__toString() with packed properties hash table
1 parent b26e610 commit 8c32212

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
477477

478478
count = 0;
479479
if (properties && zend_hash_num_elements(properties)) {
480-
ZEND_HASH_MAP_FOREACH_STR_KEY(properties, prop_name) {
480+
ZEND_HASH_FOREACH_STR_KEY(properties, prop_name) {
481481
if (prop_name && ZSTR_LEN(prop_name) && ZSTR_VAL(prop_name)[0]) { /* skip all private and protected properties */
482482
if (!zend_hash_exists(&ce->properties_info, prop_name)) {
483483
count++;

ext/reflection/tests/gh16187.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-16187 (ReflectionClass::__toString() with unpacked properties)
3+
--EXTENSIONS--
4+
simplexml
5+
--FILE--
6+
<?php
7+
$xml = '<form name="test"></form>';
8+
$simplexml = simplexml_load_string($xml);
9+
$reflector = new ReflectionObject($simplexml['name']);
10+
$reflector->__toString();
11+
?>
12+
DONE
13+
--EXPECT--
14+
DONE

0 commit comments

Comments
 (0)