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
9 changes: 4 additions & 5 deletions ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,12 +1225,12 @@ static HashTable *sxe_get_properties(zend_object *object) /* {{{ */
}
/* }}} */

static HashTable * sxe_get_debug_info(zend_object *object, int *is_temp) /* {{{ */
/* This custom handler exists because the var_dump adds a pseudo "@attributes" key. */
PHP_METHOD(SimpleXMLElement, __debugInfo)
{
*is_temp = 1;
return sxe_get_prop_hash(object, 1);
ZEND_PARSE_PARAMETERS_NONE();
RETURN_ARR(sxe_get_prop_hash(Z_OBJ_P(ZEND_THIS), 1));
}
/* }}} */

static int sxe_objects_compare(zval *object1, zval *object2) /* {{{ */
{
Expand Down Expand Up @@ -2733,7 +2733,6 @@ PHP_MINIT_FUNCTION(simplexml)
sxe_object_handlers.compare = sxe_objects_compare;
sxe_object_handlers.cast_object = sxe_object_cast;
sxe_object_handlers.count_elements = sxe_count_elements;
sxe_object_handlers.get_debug_info = sxe_get_debug_info;
sxe_object_handlers.get_closure = NULL;
sxe_object_handlers.get_gc = sxe_get_gc;

Expand Down
2 changes: 2 additions & 0 deletions ext/simplexml/simplexml.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function getName(): string {}

public function __toString(): string {}

public function __debugInfo(): ?array {}

/** @tentative-return-type */
public function count(): int {}

Expand Down
7 changes: 6 additions & 1 deletion ext/simplexml/simplexml_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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