Bug #65875 [Com]: Stack trace and reflection failure on include/require.

From: Date: Tue, 10 Mar 2015 23:33:11 +0000
Subject: Bug #65875 [Com]: Stack trace and reflection failure on include/require.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191298@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65875&edit=1 ID: 65875 Comment by: kenorb at gmail dot com Reported by: RQuadling at GMail dot com Summary: Stack trace and reflection failure on include/require. Status: Open Type: Bug Package: Reflection related Operating System: n/a PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Still happening in PHP 5.4.19 Previous Comments: ------------------------------------------------------------------------ [2013-10-10 14:57:08] RQuadling at GMail dot com Description: ------------ Hi. debug_backtrace() contains 'function' or 'class' and 'function' entries to help you determine where the code came from. No problem with that. Except. If the backtrace includes 'include' or 'require' (and their 'once' variants'), these are reported as 'function' in the backtrace. Again, no problem so far. Ish. If you use ReflectionFunction or ReflectionMethod to gather and report additional information about the trace, you get an error when dealing with the include/require entries. Uncaught exception 'ReflectionException' with message 'Function require_once() does not exist'. What is also interesting is that the output is slightly different for include/require. For a normal method/function, the order of the elements in the backtrace are : 'file' => 'SomeClass.php', 'line' => 121, 'function' => 'SomeMethod', 'class' => 'SomeClass', 'type' => '->', 'args' => array ( ), But for include/require, ... 'file' => 'SomeFile.php', 'line' => 4, 'args' => array ( 0 => '/incluldes/SomeClass.php', ), 'function' => 'require_once', So, some specialisation already exists in the backtrace for these non-functions. This is confirmed at https://github.com/php/php-src/blob/91a9569d8525d2893c83199ac83f973fb91e243b/Zend/zend_builtin_functions.c#L2345. If the debug_backtrace could include a marker indicating that the element in the trace is not reflected, OR, allow reflection of include/require (and if there was a way for eval also), then this could improve things a bit. Though, I think, just a documentation upgrade in ReflectionXXX and debug_xxx to indicate that code constructs are not reflected could cover this. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65875&edit=1

« previous php.bugs (#191298) next »