Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Zend/tests/property_hooks/gh25265.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
GH-25265: Hooked property in a subclass of an internal class with virtual properties
--EXTENSIONS--
dom
--FILE--
<?php

class Test extends DOMDocument {
public int $prop { set => $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)
3 changes: 3 additions & 0 deletions Zend/zend_property_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading