Bug #65871 [NEW]: debug_backtrace missing 'file' & 'line' indices for reflection-invoked methods
| From: | jbeall at heraldic dot us | Date: | Wed, 09 Oct 2013 15:13:44 +0000 |
| Subject: | Bug #65871 [NEW]: debug_backtrace missing 'file' & 'line' indices for reflection-invoked methods | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-182102@lists.php.net to get a copy of this message | ||
From: jbeall at heraldic dot us
Operating system: Windows 8 & Ubuntu Linux
PHP version: 5.4.20
Package: Reflection related
Bug Type: Bug
Bug description:debug_backtrace missing 'file' & 'line' indices for
reflection-invoked methods
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 bug report at https://bugs.php.net/bug.php?id=65871&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65871&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65871&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65871&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65871&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65871&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65871&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65871&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65871&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65871&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65871&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=65871&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=65871&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65871&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65871&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65871&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65871&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65871&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65871&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65871&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65871&r=mysqlcfg