|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-11-03 11:52 UTC] felipe@php.net
-Package: Reflection related
+Package: Documentation problem
[2013-11-08 07:25 UTC] krakjoe@php.net
-Package: Documentation problem
+Package: Reflection related
[2013-11-08 07:25 UTC] krakjoe@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 17:00:01 2025 UTC |
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 ( ) ) ) )