diff --git a/Zend/tests/property_hooks/gh25265.phpt b/Zend/tests/property_hooks/gh25265.phpt new file mode 100644 index 000000000000..dc63d9617e8e --- /dev/null +++ b/Zend/tests/property_hooks/gh25265.phpt @@ -0,0 +1,26 @@ +--TEST-- +GH-25265: Hooked property in a subclass of an internal class with virtual properties +--EXTENSIONS-- +dom +--FILE-- + $value; } +} + +$doc = new Test; +$doc->prop = 42; +var_dump(get_object_vars($doc)); +foreach ($doc as $key => $value) { + var_dump($key, $value); +} + +?> +--EXPECT-- +array(1) { + ["prop"]=> + int(42) +} +string(4) "prop" +int(42) diff --git a/Zend/zend_property_hooks.c b/Zend/zend_property_hooks.c index 57e22f23ad7b..bd875d579eea 100644 --- a/Zend/zend_property_hooks.c +++ b/Zend/zend_property_hooks.c @@ -81,6 +81,9 @@ static zend_array *zho_build_properties_ex(zend_object *zobj, bool check_access, if (prop_info->flags & ZEND_ACC_STATIC) { continue; } + if (!prop_info->hooks && (prop_info->flags & ZEND_ACC_VIRTUAL)) { + continue; + } zend_string *property_name = prop_info->name; /* When promoting properties from protected to public, use the unmangled name to preserve order. */ if (prop_info->flags & ZEND_ACC_PROTECTED) {