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 @@ -24,6 +24,10 @@ PHP                                                                        NEWS
2424- Random:
2525  . Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)
2626
27+ - SimpleXML:
28+   . Partially fixed bug GH-16317 (SimpleXML does not allow __debugInfo() overrides
29+     to work). (nielsdos)
30+ 
2731- XMLReader:
2832  . Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available.
2933    (nielsdos)
Original file line number Diff line number Diff line change @@ -1202,12 +1202,12 @@ static HashTable *sxe_get_properties(zend_object *object) /* {{{ */
12021202}
12031203/* }}} */ 
12041204
1205- static  HashTable  *  sxe_get_debug_info (zend_object  * object , int  * is_temp ) /* {{{ */ 
1205+ /* This custom handler exists because the var_dump adds a pseudo "@attributes" key. */ 
1206+ PHP_METHOD (SimpleXMLElement , __debugInfo )
12061207{
1207- 	* is_temp   =   1 ;
1208- 	return   sxe_get_prop_hash (object , 1 );
1208+ 	ZEND_PARSE_PARAMETERS_NONE () ;
1209+ 	RETURN_ARR ( sxe_get_prop_hash (Z_OBJ_P ( ZEND_THIS ) , 1 ) );
12091210}
1210- /* }}} */ 
12111211
12121212static  int  sxe_objects_compare (zval  * object1 , zval  * object2 ) /* {{{ */ 
12131213{
@@ -2682,7 +2682,6 @@ PHP_MINIT_FUNCTION(simplexml)
26822682	sxe_object_handlers .compare  =  sxe_objects_compare ;
26832683	sxe_object_handlers .cast_object  =  sxe_object_cast ;
26842684	sxe_object_handlers .count_elements  =  sxe_count_elements ;
2685- 	sxe_object_handlers .get_debug_info  =  sxe_get_debug_info ;
26862685	sxe_object_handlers .get_closure  =  NULL ;
26872686	sxe_object_handlers .get_gc  =  sxe_get_gc ;
26882687
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