Donnerstag, 21. Februar 2013

Y Kant Debuggers Show Return Values?

Only recently, a colleague complained that people use chains of methods like

$xyz = $this->getRequest()->getParam('xyz');

His complaint was not about the Law of Demeter though, but about the lack of debuggability. Regardless of whether you "step into" those methods, or "step over" the line, you'll never see the return value of getRequest().

Of course, it is questionable whether

$request = $this->getRequest();
$xyz = $request->getParam('xyz');

is really more desirable from a readability perspective (I think nay; he thinks yay).

But apart from that, the question arises why debuggers are not able (or unwilling) to show me the last return value, or even a stack thereof, so I can "step into" getRequest() and see what it returns to my calling function.

Is this technically impossible for some reason? Or is that feature indeed available, and I just have not found it yet? It doesn't seem to appear in the netbeans php debugger, nor in gdb or any other debugger I've used; or at least it has never presented itself to me in a way that I was able to recognize.

Questions upon questions!