Determine if inspected objects are same or different instances

Sorry if this was answered before but it's difficult to google. When using step debugger, is there a way to determine if two given variables correspond to the same object instance?

Good old var_dump() displays a sequential number as ID, but they all look identical to me in the "Variables" pane.

$a = (object)null;
$b = $a;
$c = clone $b;
var_dump($a, $b, $c);
object(stdClass)#1 (0) {
}
object(stdClass)#1 (0) {
}
object(stdClass)#2 (0) {
}


2 comments
Comment actions Permalink

Hi there,

I'm not sure: better ask Xdebug author if such info can be sent at all.

If you enable Xdebug log and try to debug, you will see what commands the IDE uses and what data Xdebug sends in return.

This is what I see when execution is stopped at breakpoint at var_dump($a, $b, $c); line:

[16780] [Step Debug] <- context_get -i 14 -d 0 -c 0
[16780] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="14" context="0"><property name="$a" fullname="$a" type="object" classname="stdClass" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$b" fullname="$b" type="object" classname="stdClass" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$c" fullname="$c" type="object" classname="stdClass" children="0" numchildren="0" page="0" pagesize="100"></property></response>

Right now I see nothing here that would allow to differentiate these objects.

1
Comment actions Permalink

It'd be very useful when working with Doctrine but I see it can't happen. Thank you!

0

Please sign in to leave a comment.