rfc:debug_backtrace_depth
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:debug_backtrace_depth [2021/03/13 17:11] – created tandre | rfc:debug_backtrace_depth [2021/03/13 18:10] – tandre | ||
---|---|---|---|
Line 9: | Line 9: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Inspecting the current stack trace depth is occasionally useful for manually debugging, checking for potential infinite recursion, or for checking if code would hit stack frame limits in extensions such as XDebug | + | Inspecting the current stack trace depth is occasionally useful for manually debugging, checking for potential infinite recursion, or for checking if code would hit stack frame limits in extensions such as Xdebug |
===== Proposal ===== | ===== Proposal ===== | ||
Line 24: | Line 24: | ||
When '' | When '' | ||
- | Internally, PHP's stack frames are represented like a linked list (i.e. to count them, you need to iterate through the frames), and this RFC does not change that representation. The amount of time needed to compute the depth is proportional to the depth, which is why this RFC supports the optional '' | + | Internally, PHP's stack frames are represented like a singly |
==== Example use cases ==== | ==== Example use cases ==== | ||
Line 53: | Line 53: | ||
=== Checking for compatibility with extensions with stack trace limits === | === Checking for compatibility with extensions with stack trace limits === | ||
- | For example, in XDebug | + | For example, in Xdebug |
<code php> | <code php> | ||
Line 59: | Line 59: | ||
function my_common_function() { | function my_common_function() { | ||
if (is_running_as_unit_test() && debug_backtrace_depth(250) >= 250) { | if (is_running_as_unit_test() && debug_backtrace_depth(250) >= 250) { | ||
- | throw new TestFrameworkError(" | + | throw new TestFrameworkError(" |
} | } | ||
// body of my_common_function() | // body of my_common_function() | ||
Line 107: | Line 107: | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
The behavior of '' | The behavior of '' | ||
+ | |||
+ | ===== Proposed PHP Version ===== | ||
+ | 8.1 | ||
+ | |||
+ | ===== Proposed Voting Choices ===== | ||
+ | |||
+ | Yes/No, requiring a 2/3 majority |
rfc/debug_backtrace_depth.txt · Last modified: 2021/06/02 02:05 by tandre