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

 ID:                 62325
 Comment by:         hanskrentel at yahoo dot de
 Reported by:        anfurny22 at gmail dot com
 Summary:            Debug Backtrace gives no handle to anonymous
                     functions
 Status:             Open
 Type:               Feature/Change Request
 Package:            *General Issues
 Operating System:   Windows
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

I think the naming can be improved. Reference is quite generic, why not to 
return 
some reflection object if asked for?


Previous Comments:
------------------------------------------------------------------------
[2012-06-14 17:25:19] anfurny22 at gmail dot com

Description:
------------
Debug backtrace traditionally gives several pieces of information about the 
call 
stack, including file name, line number, and function name. However, with 
anonymous functions it simply gives "{closure}". This makes anonymous functions 
received through debug_backtrace inaccesible through reflection because there 
is 
no reference to them.

I propose that debug_backtrace always provide an additional key "reference" 
which 
is a reference to the actual function. This will let the function be called or 
provided to the reflection API.

Test script:
---------------
<?PHP

$anon = function() {
 $name = (debug_backtrace[0]['name']); // yields {closure}
 $refl = new ReflectionFunction($name); // works great except with closures!
 echo $refl->getDocComment(); // fails
}

$anon();



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



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

Reply via email to