File tree Expand file tree Collapse file tree 5 files changed +38
-6
lines changed Expand file tree Collapse file tree 5 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ PHP NEWS
2222- Random:
2323 . Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)
2424
25+ - SimpleXML:
26+ . Partially fixed bug GH-16317 (SimpleXML does not allow __debugInfo() overrides
27+ to work). (nielsdos)
28+
2529- XMLReader:
2630 . Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available.
2731 (nielsdos)
Original file line number Diff line number Diff line change @@ -1225,12 +1225,12 @@ static HashTable *sxe_get_properties(zend_object *object) /* {{{ */
12251225}
12261226/* }}} */
12271227
1228- static HashTable * sxe_get_debug_info (zend_object * object , int * is_temp ) /* {{{ */
1228+ /* This custom handler exists because the var_dump adds a pseudo "@attributes" key. */
1229+ PHP_METHOD (SimpleXMLElement , __debugInfo )
12291230{
1230- * is_temp = 1 ;
1231- return sxe_get_prop_hash (object , 1 );
1231+ ZEND_PARSE_PARAMETERS_NONE () ;
1232+ RETURN_ARR ( sxe_get_prop_hash (Z_OBJ_P ( ZEND_THIS ) , 1 ) );
12321233}
1233- /* }}} */
12341234
12351235static int sxe_objects_compare (zval * object1 , zval * object2 ) /* {{{ */
12361236{
@@ -2733,7 +2733,6 @@ PHP_MINIT_FUNCTION(simplexml)
27332733 sxe_object_handlers .compare = sxe_objects_compare ;
27342734 sxe_object_handlers .cast_object = sxe_object_cast ;
27352735 sxe_object_handlers .count_elements = sxe_count_elements ;
2736- sxe_object_handlers .get_debug_info = sxe_get_debug_info ;
27372736 sxe_object_handlers .get_closure = NULL ;
27382737 sxe_object_handlers .get_gc = sxe_get_gc ;
27392738
Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ public function getName(): string {}
5151
5252 public function __toString (): string {}
5353
54+ public function __debugInfo (): ?array {}
55+
5456 /** @tentative-return-type */
5557 public function count (): int {}
5658
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-16317 (SimpleXML does not allow __debugInfo() overrides to work)
3+ --FILE--
4+ <?php
5+
6+ class MySXE extends SimpleXMLElement {
7+ public function __debugInfo (): array {
8+ echo "invoked \n" ;
9+ return ['x ' => 1 ];
10+ }
11+ }
12+
13+ $ sxe = simplexml_load_string ('<root><a/></root> ' , MySXE::class);
14+ var_dump ($ sxe );
15+
16+ ?>
17+ --EXPECT--
18+ invoked
19+ object(MySXE)#1 (1) {
20+ ["x"]=>
21+ int(1)
22+ }
You can’t perform that action at this time.
0 commit comments