Bug #65871 [Opn]: debug_backtrace missing 'file' & 'line' indices for reflection-invoked methods
| From: | krakjoe@php.net | Date: | Fri, 08 Nov 2013 07:25:03 +0000 |
| Subject: | Bug #65871 [Opn]: debug_backtrace missing 'file' & 'line' indices for reflection-invoked methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182650@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65871&edit=1
ID: 65871
Updated by: krakjoe@php.net
Reported by: jbeall at heraldic dot us
Summary: debug_backtrace missing 'file' & 'line' indices for
reflection-invoked methods
Status: Open
Type: Bug
-Package: Documentation problem
+Package: Reflection related
Operating System: Windows 8 & Ubuntu Linux
PHP Version: 5.4.20
Block user comment: N
Private report: N
New Comment:
This is expected behaviour, however, I'm not sure it's impossible to avoid. So before I go
changing the documentation, can someone that works on reflection let me know if this can be fixed or
if it should be documented ?
Previous Comments:
------------------------------------------------------------------------
[2013-10-09 15:13:44] jbeall at heraldic dot us
Description:
------------
When using the debug_backtrace function, the resulting array will be missing 'file' and
'line' indices for any stack frames that were invoked via reflection.
The documentation for debug_backtrace does not indicate that stack frames for methods invoked via
reflection will be missing any information. If this is not a bug, the documentation should have a
clear warning that this behavior is intentional.
Test script:
---------------
class SampleClass {
public function printBacktrace() {
print_r(debug_backtrace());
}
}
$obj1 = new SampleClass();
echo "Invoked directly: ";
$obj1->printBacktrace();
$rm = new ReflectionMethod($obj1,'printBacktrace');
echo "\n\nInvoked via reflection: ";
$rm->invoke($obj1);
Expected result:
----------------
The stack frame for SampleClass->printBacktrace should include file and line number information
regardless of whether the method was invoked via reflection.
Actual result:
--------------
Stack frames for methods invoked via reflection are missing file and line number information.
Here's the output of the sample script:
Invoked directly: Array
(
[0] => Array
(
[file] => /home/lamplighter/.apps/http/__default__/0/llpdn/1.0-zdc/public/test.php
[line] => 15
[function] => printBacktrace
[class] => SampleClass
[object] => SampleClass Object
(
)
[type] => ->
[args] => Array
(
)
)
)
Invoked via reflection: Array
(
[0] => Array
(
[function] => printBacktrace
[class] => SampleClass
[object] => SampleClass Object
(
)
[type] => ->
[args] => Array
(
)
)
[1] => Array
(
[file] => /home/lamplighter/.apps/http/__default__/0/llpdn/1.0-zdc/public/test.php
[line] => 20
[function] => invoke
[class] => ReflectionMethod
[object] => ReflectionMethod Object
(
[name] => printBacktrace
[class] => SampleClass
)
[type] => ->
[args] => Array
(
[0] => SampleClass Object
(
)
)
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65871&edit=1