leeoniya / dump_r.php

a cleaner, leaner mix of print_r() and var_dump()
121 stars 17 forks source link

allow reference unfolding via cloneNode #41

Open leeoniya opened 9 years ago

leeoniya commented 9 years ago

array, object and closure references [*],{*},(*) should be unfoldable via DOM cloneNode

raveren commented 9 years ago

hey, quick question, do you take into consideration that while the reference to the object might be the same, the object itself might have changed between displayed positions - especially when displaying trace, but not only then..?

leeoniya commented 9 years ago

no, i do not.

that is a valid point though. definitely something that would require recursion to be detected differently than simply 're-dumping', as is done now.

leeoniya commented 9 years ago

i'm going to push a one-liner fix for this by clearing Type::$dic entirely @ https://github.com/leeoniya/dump_r.php/blob/master/src/dump_r/Core.php#L17. this way there will not be cross-dump referencing. thanks for the note.

leeoniya commented 9 years ago

the irony here being that i actually reset it manually in the test/example file in 3 places [1],[2],[3] to prevent cross-dump refs from screwing up multiple dumps of the same object. while not specifically the situation you pointed out, this fix will help that, too.

[1] https://github.com/leeoniya/dump_r.php/blob/master/test/index.php#L26 [2] https://github.com/leeoniya/dump_r.php/blob/master/test/index.php#L32 [3] https://github.com/leeoniya/dump_r.php/blob/master/test/index.php#L39

leeoniya commented 9 years ago

the following will now work as expected:

$obj = new stdClass;
$obj->self = &$obj;

dump_r($obj);

$obj->x = 'sss';

dump_r($obj);