22 +----------------------------------------------------------------------+
33 | Xdebug |
44 +----------------------------------------------------------------------+
5- | Copyright (c) 2002-2024 Derick Rethans |
5+ | Copyright (c) 2002-2025 Derick Rethans |
66 +----------------------------------------------------------------------+
77 | This source file is subject to version 1.01 of the Xdebug license, |
88 | that is bundled with this package in the file LICENSE, and is |
@@ -141,6 +141,7 @@ typedef struct
141141 int name_len ;
142142 unsigned long index_key ;
143143 zval * zv ;
144+ zend_object * zobj ;
144145} xdebug_object_item ;
145146
146147static void merged_hash_object_item_dtor (zval * data )
@@ -150,14 +151,15 @@ static void merged_hash_object_item_dtor(zval *data)
150151 xdfree (item );
151152}
152153
153- static int object_item_add_to_merged_hash (zval * zv_nptr , zend_ulong index_key , zend_string * hash_key , HashTable * merged , int object_type )
154+ static int object_item_add_to_merged_hash (zval * zv_nptr , zend_ulong index_key , zend_string * hash_key , HashTable * merged , int object_type , zend_object * zobj )
154155{
155156 zval * * zv = & zv_nptr ;
156157 xdebug_object_item * item ;
157158
158159 item = xdcalloc (1 , sizeof (xdebug_object_item ));
159160 item -> type = object_type ;
160161 item -> zv = * zv ;
162+ item -> zobj = zobj ;
161163
162164 if (hash_key ) {
163165 item -> name = (char * ) HASH_APPLY_KEY_VAL (hash_key );
@@ -173,7 +175,7 @@ static int object_item_add_to_merged_hash(zval *zv_nptr, zend_ulong index_key, z
173175 return 0 ;
174176}
175177
176- static int object_item_add_zend_prop_to_merged_hash (zend_property_info * zpp , HashTable * merged , int object_type , zend_class_entry * ce )
178+ static int object_item_add_zend_prop_to_merged_hash (zend_property_info * zpp , HashTable * merged , int object_type , zend_object * zobj , zend_class_entry * ce )
177179{
178180 xdebug_object_item * item ;
179181
@@ -184,6 +186,7 @@ static int object_item_add_zend_prop_to_merged_hash(zend_property_info *zpp, Has
184186 item = xdmalloc (sizeof (xdebug_object_item ));
185187 item -> type = object_type ;
186188 item -> zv = & CE_STATIC_MEMBERS (ce )[zpp -> offset ];
189+ item -> zobj = zobj ;
187190 item -> name = (char * ) STR_NAME_VAL (zpp -> name );
188191 item -> name_len = STR_NAME_LEN (zpp -> name );
189192
@@ -406,7 +409,44 @@ static int xdebug_object_element_export_xml_node(xdebug_object_item *item_nptr,
406409 }
407410
408411 xdebug_xml_add_child (parent , node );
412+
413+ #if PHP_VERSION_ID >= 80400
414+ {
415+ zval tmp_for_is_ptr ;
416+ zval * tmp_value_for_ptr = NULL ;
417+
418+ if (Z_TYPE_P ((* item )-> zv ) == IS_PTR ) {
419+ // IS_PTR is for properties with hooks
420+ zend_property_info * prop_info = Z_PTR_P ((* item )-> zv );
421+ const char * unmangled_name_cstr ;
422+ zend_string * unmangled_name ;
423+
424+ if ((prop_info -> flags & ZEND_ACC_VIRTUAL ) && !prop_info -> hooks [ZEND_PROPERTY_HOOK_GET ]) {
425+ return 0 ;
426+ }
427+
428+ unmangled_name_cstr = zend_get_unmangled_property_name (prop_info -> name );
429+ unmangled_name = zend_string_init (unmangled_name_cstr , strlen (unmangled_name_cstr ), false);
430+
431+ tmp_value_for_ptr = zend_read_property_ex (prop_info -> ce , (* item )-> zobj , unmangled_name , /* silent */ true, & tmp_for_is_ptr );
432+
433+ zend_string_release_ex (unmangled_name , false);
434+ if (EG (exception )) {
435+ return 0 ;
436+ }
437+
438+ xdebug_var_export_xml_node (& tmp_value_for_ptr , tmp_fullname ? tmp_fullname : NULL , node , options , level + 1 );
439+
440+ if (tmp_value_for_ptr == & tmp_for_is_ptr ) {
441+ zval_ptr_dtor (tmp_value_for_ptr );
442+ }
443+ } else {
444+ xdebug_var_export_xml_node (& ((* item )-> zv ), tmp_fullname ? tmp_fullname : NULL , node , options , level + 1 );
445+ }
446+ }
447+ #else
409448 xdebug_var_export_xml_node (& ((* item )-> zv ), tmp_fullname ? tmp_fullname : NULL , node , options , level + 1 );
449+ #endif
410450
411451 if (tmp_name ) {
412452 xdebug_str_free (tmp_name );
@@ -606,7 +646,7 @@ void xdebug_var_export_xml_node(zval **struc, xdebug_str *name, xdebug_xml_node
606646#endif
607647
608648 ZEND_HASH_FOREACH_PTR (& ce -> properties_info , zpi_val ) {
609- object_item_add_zend_prop_to_merged_hash (zpi_val , merged_hash , (int ) XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY , ce );
649+ object_item_add_zend_prop_to_merged_hash (zpi_val , merged_hash , (int ) XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY , Z_OBJ_P ( * struc ), ce );
610650 } ZEND_HASH_FOREACH_END ();
611651
612652 xdebug_zend_hash_apply_protection_end (& ce -> properties_info );
@@ -641,7 +681,7 @@ void xdebug_var_export_xml_node(zval **struc, xdebug_str *name, xdebug_xml_node
641681 }
642682 }
643683#endif
644- object_item_add_to_merged_hash (tmp_val , num , key , merged_hash , flags );
684+ object_item_add_to_merged_hash (tmp_val , num , key , merged_hash , flags , Z_OBJ_P ( * struc ) );
645685 } ZEND_HASH_FOREACH_END ();
646686
647687 xdebug_zend_hash_apply_protection_end (myht );
0 commit comments