Bug #71321 [Com]: User __debugInfo method ignored for internal classes
Edit report at https://bugs.php.net/bug.php?id=71321&edit=1
ID: 71321
Comment by: zerterone at gmail dot com
Reported by: zaq178miami at gmail dot com
Summary: User __debugInfo method ignored for internal classes
Status: Open
Type: Bug
Package: *General Issues
Operating System: Debian GNU/Linux 8.2 (jessie)
PHP Version: 7.0.2
Block user comment: N
Private report: N
New Comment:
duplicate of #69264
Previous Comments:
------------------------------------------------------------------------
[2016-01-09 16:22:57] zaq178miami at gmail dot com
This is not about just SPL (https://bugs.php.net/bug.php?id=69264), but about all internal classes
that set their get_debug_info.
------------------------------------------------------------------------
[2016-01-09 16:20:27] zaq178miami at gmail dot com
Description:
------------
When user class extends internal class with get_debug_info object handler set and defined userland
__debugInfo() method, that method totally ignored.
As a workaround, Z_OBJDEBUG macro may be changed to looks like
#define
Z_OBJDEBUG(zval,tmp) (Z_OBJCE(zval)->__debugInfo?std_object_handlers.get_debug_info(&(zval),&tmp):(Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&tmp):(tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL)))
From Bob Weinand notes:
Then comes a question about parent::__debugInfo() in userland __debugInfo()
comes: should it be accessible? Should it return what get_debug_info returns? Or should
get_debug_info moved to ce->__debugInfo (internally too)? BC?
Test script:
---------------
class CustomSplStorage extends SplObjectStorage {
public function __debugInfo()
{
return ['this is' => 'annoying'];
}
}
var_dump(new CustomSplStorage());
debug_zval_dump(new CustomSplStorage());
Expected result:
----------------
object(CustomSplStorage)#1 (1) {
["this is"]=>
string(8) "annoying"
}
object(CustomSplStorage)#1 (1) refcount(1){
["storage":"SplObjectStorage":private]=>
["this is"]=>
string(8) "annoying" refcount(2)
}
Actual result:
--------------
object(CustomSplStorage)#1 (1) {
["storage":"SplObjectStorage":private]=>
array(0) {
}
}
object(CustomSplStorage)#1 (1) refcount(1){
["storage":"SplObjectStorage":private]=>
array(0) refcount(1){
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71321&edit=1
Thread (6 messages)