[xdebug-general] Re: Patch for #416 - Add return value to computer readable trace format

From: Wim Godden <wim[@]godden.net>
Date: Fri, 13 Aug 2010 14:53:51 +0200

BTW : I'm not sure if this is by design, but it seems return values are
not in the trace if the return value is not used in the calling function.

For example :
<?php
class Lame
{
    /**
     * foo
     * @var int $bla Just a parameter
     */
    public function foo($bla)
    {
        if (isset($bla)) {
            if (in_array($bla, array(1, 2, 3))) {
                return "yes";
            } else {
                return "no";
            }
        }
    }
}

$lame = new Lame();
$lame->foo(5);

The result is (in human-readable format) :

TRACE START [2010-08-13 12:50:48]
    0.0014 327848 -> Lame->foo(long) /home/wgodden/development/paramtest/lame.php:35
    0.0017 328208 -> in_array(long, array(3)) /home/wgodden/development/paramtest/lame.php:25
>=> FALSE
    0.0019 8200
TRACE END [2010-08-13 12:50:48]

So in_array() gets a return, but Lame->foo() doesn't get a return,
although the return is clearly there in the code.

As soon as I replace :
$lame->foo(5);
by
$x = $lame->foo(5);

the result becomes :

TRACE START [2010-08-13 12:50:35]
    0.0013 327936 -> Lame->foo(long) /home/wgodden/development/paramtest/lame.php:35
    0.0014 328296 -> in_array(long, array(3)) /home/wgodden/development/paramtest/lame.php:25
>=> FALSE
>=> 'no'
    0.0018 8200
TRACE END [2010-08-13 12:50:35]

Is this expected behaviour ?

Kind regards,

Wim Godden
Cu.be Solutions
http://techblog.wimgodden.be

Wim Godden wrote:
> Hi,
>
> Quick patch update, since there was a bug in the patch (newline
> missing in the computerized return if no return value was present).
> Patch is attached.
>
> Kind regards,
>
> Wim Godden
> Cu.be Solutions
> http://techblog.wimgodden.be
>
>
>
> Wim Godden wrote:
>> Hi,
>>
>> Just redid the patch I wrote for Xdebug 2.0 last year. It fixes bug
>> #416,
>> adding a return value in computer readable trace format.
>>
>> Patch is attached.
>>
>> Kind regards,
>>
>> Wim Godden
>> Cu.be Solutions
>> http://techblog.wimgodden.be
>>
Received on Fri Aug 13 2010 - 13:54:05 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST