For PHP 5.1.1, I added an additional field $frame['object'] to the result array of debug_backtrace() that contains a reference to the respective object when the frame was called from an object.
What I did not think of at the time, unfortunately, is the fact that unconditionally including $frame['object'] in the result array can get in the way of using print_r(debug_backtrace()), for instance, for debugging purposes. With the patch below, I propose the addition of an optional parameter $provide_object to debug_backtrace() that toggles the inclusion of $frame['object'] in the result array. The value of $provide_object defaults to 1 so as not to break BC. Index: zend_builtin_functions.c =================================================================== RCS file: /repository/ZendEngine2/zend_builtin_functions.c,v retrieving revision 1.277.2.12.2.23 diff -u -B -r1.277.2.12.2.23 zend_builtin_functions.c --- zend_builtin_functions.c 8 Aug 2007 13:32:46 -0000 1.277.2.12.2.23 +++ zend_builtin_functions.c 21 Aug 2007 06:31:32 -0000 @@ -2093,15 +2093,17 @@ /* }}} */ -/* {{{ proto array debug_backtrace(void) +/* {{{ proto array debug_backtrace([bool provide_object]) Return backtrace as array */ ZEND_FUNCTION(debug_backtrace) { - if (ZEND_NUM_ARGS()) { - ZEND_WRONG_PARAM_COUNT(); + zend_bool provide_object = 1; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &provide_object) == FAILURE) { + return; } - zend_fetch_debug_backtrace(return_value, 1, 1 TSRMLS_CC); + zend_fetch_debug_backtrace(return_value, 1, provide_object TSRMLS_CC); } /* }}} */ -- Sebastian Bergmann http://sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php