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
6 changes: 6 additions & 0 deletions ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ static int dom_property_exists(zend_object *object, zend_string *name, int check
}
/* }}} */

/* This custom handler is necessary to avoid a recursive construction of the entire subtree. */
static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */
{
dom_object *obj = php_dom_obj_from_obj(object);
Expand All @@ -411,6 +412,11 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
dom_prop_handler *entry;
zend_string *object_str;

/* As we have a custom implementation, we must manually check for overrides. */
if (object->ce->__debugInfo) {
return zend_std_get_debug_info(object, is_temp);
}

*is_temp = 1;

std_props = zend_std_get_properties(object);
Expand Down
20 changes: 20 additions & 0 deletions ext/dom/tests/gh16317.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
GH-16317 (DOM classes do not allow __debugInfo() overrides to work)
--FILE--
<?php

class Demo extends DOMNode {
public function __construct() {}
public function __debugInfo(): array {
return ['x' => 'y'];
}
}

var_dump(new Demo());

?>
--EXPECT--
object(Demo)#1 (1) {
["x"]=>
string(1) "y"
}
Loading