Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,14 @@ static HashTable *sxe_get_properties(zend_object *object) /* {{{ */
}
/* }}} */

/* This custom handler exists because the var_dump adds a pseudo "@attributes" key. */
static HashTable * sxe_get_debug_info(zend_object *object, int *is_temp) /* {{{ */
{
/* 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;
return sxe_get_prop_hash(object, 1);
}
Expand Down
22 changes: 22 additions & 0 deletions ext/simplexml/tests/gh16317.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
GH-16317 (SimpleXML does not allow __debugInfo() overrides to work)
--FILE--
<?php

class MySXE extends SimpleXMLElement {
public function __debugInfo(): array {
echo "invoked\n";
return ['x' => 1];
}
}

$sxe = simplexml_load_string('<root><a/></root>', MySXE::class);
var_dump($sxe);

?>
--EXPECT--
invoked
object(MySXE)#1 (1) {
["x"]=>
int(1)
}
Loading