bobbingwide / oik-bwtrace

debug trace for WordPress
https://www.oik-plugins.com/oik-plugins/oik-bwtrace-debug-trace-for-wordpress/
GNU General Public License v2.0
6 stars 1 forks source link

Support tracing of Closures and protected fields in bw_trace_obsafe_print_r() #23

Closed bobbingwide closed 8 years ago

bobbingwide commented 8 years ago

I recently started working on a system developed in Laravel and decided to make my trace logic available to that platform. I ported the basic logic but found I needed to change the routine to use bw_trace_obsafe_print_r() to cater for objects and needed to improve to handle Closures. Subsequently I realised that the routine did not print protected fields. Tracing the values of an object only printed the public fields. I improved the function to cater for protected fields. It's significantly more useful.

This issue is to apply those changes to the WordPress version.

bobbingwide commented 8 years ago

When tracing uses print_r() the output for an object of class withprotected will look something like this

withprotected Object
(
    [athis] => 1
    [that:protected] => that
    [theother:withprotected:private] => theother
    [close_ure] => Closure Object
        (
            [this] => withprotected Object
 *RECURSION*
        )
)

when the output is produced with bw_trace_obsafe_print_r() it will be like this

withprotected Object

    [athis] => (integer) 1
    [ * that] => (string) "that"
    [ withprotected theother] => (string) "theother"
    [close_ure] => Closure