Edit report at http://bugs.php.net/bug.php?id=40918&edit=1

 ID:                 40918
 Updated by:         johan...@php.net
 Reported by:        rquadl...@php.net
 Summary:            Enhance debug_backtrace to supply the name of
                     parameters.
-Status:             Open
+Status:             Bogus
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   n/a
 PHP Version:        4.4.5
 Block user comment: N
 Private report:     N

 New Comment:

You can easily grab the parameters using reflection nowadays. Doing this
automatically is relatively expensive and won't work always (varargs)


Previous Comments:
------------------------------------------------------------------------
[2007-03-26 09:35:28] rquadl...@php.net

Description:
------------
Currently, debug_backtrace() supplies details of parameters to the
function/method calls in the current call stack. This is extremely
useful for debugging.



I feel that this could be enhanced by adding the name of the parameters
passed to a function/method.



Currently I have to read the file associated with the function and then
regexp the line to extract the parameters. This is getting more and more
complicated trying to support different users coding practices.



I've supplied an contrived example with the expected output for the new
functionality.



I initially thought that the keys of the 'args' array could be the
parameters, but this would be a BC as currently they are numeric, so a
new array of 'params' (Hmmm - not a great name - would need a better
one), could hold the parameter text. If the parameter is a function
call, then the param value would be the function call with its
parameters.



The main purpose is that you can show the actual parameter names the
code is using in addition to the the values.



Reproduce code:
---------------
<?php

function func($m_Param1, $m_Param2)

        {

        var_export(debug_backtrace());

        return True;

        }



$s_Foo = 'Foo';

$s_Bar = 'Bar';

func($s_Foo, $s_Bar, func($s_Foo, $s_Bar));

?>

Expected result:
----------------
array (

  0 =>

  array (

    'file' => 'C:\\va.php',

    'line' => 10,

    'function' => 'func',

    'args' =>

    array (

      0 => 'Foo',

      1 => 'Bar',

    ),

    'params' =>

    array (

      0 => '$s_Foo',

      1 => '$s_Bar',

    ),

  ),

)array (

  0 =>

  array (

    'file' => 'C:\\va.php',

    'line' => 10,

    'function' => 'func',

    'args' =>

    array (

      0 => 'Foo',

      1 => 'Bar',

      2 => true,

    ),

    'params' =>

    array (

      0 => '$s_Foo',

      1 => '$s_Bar',

      2 => 'func($s_Foo, $s_Bar)',

    ),

  ),

)

Actual result:
--------------
array (

  0 =>

  array (

    'file' => 'C:\\va.php',

    'line' => 10,

    'function' => 'func',

    'args' =>

    array (

      0 => 'Foo',

      1 => 'Bar',

    ),

  ),

)array (

  0 =>

  array (

    'file' => 'C:\\va.php',

    'line' => 10,

    'function' => 'func',

    'args' =>

    array (

      0 => 'Foo',

      1 => 'Bar',

      2 => true,

    ),

  ),

)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=40918&edit=1

Reply via email to