[RFC] debug_backtrace_depth(int $limit=0): int

From: Date: Sat, 13 Mar 2021 17:29:41 +0000
Subject: [RFC] debug_backtrace_depth(int $limit=0): int
Groups: php.internals 
Request: Send a blank email to internals+get-113502@lists.php.net to get a copy of this message
Hi internals,

I've created a new RFC https://wiki.php.net/rfc/debug_backtrace_depth
to return the depth of the current stack trace.

Inspecting the current stack trace depth is occasionally useful for
1. Manually debugging with temporary debug statements
2. Checking for potential infinite recursion or investigating reproducible reports of infinite
recursion
3. Checking if code is likely to hit stack frame limits when run in environments using extensions
such as Xdebug
    (https://xdebug.org/docs/all_settings#max_nesting_level , which also checks for potential
infinite recursion)
    (note that Xdebug is a debugger - running php under xdebug is significantly slower than without
Xdebug)

It is currently possible to compute the depth through
count(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $limit=0)),
but this is verbose, inefficient, and harder to read compared to returning the depth directly.

Thoughts?

Thanks,
- Tyson


Thread (3 messages)

« previous php.internals (#113502) next »