php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68615 Faster / slimmer alternative to debug_backtrace
Submitted: 2014-12-17 08:31 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ianbytchek at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-12-17 08:31 UTC] ianbytchek at gmail dot com
Description:
------------
debug_backtrace is a really useful and powerful thing, but often its purpose ends with debugging-related tasks. I stumble across use-cases where it can be just as useful, but the performance is dragging it down. One of such use cases is (semi) automatic dependency injection implemented by referencing caller objects. E.g., when a controller implements an `InjectionAwareInterface` a model instantiated within the call tree can find the closest `InjectionAwareInterface` and use dependencies from there. Having the ability to quickly and efficiently extract the caller information would allow to produce cleaner and more robust code.

Please consider providing the new `get_backtrace_objects()` function, which would return only an array of caller objects without repetitive duplicates, i.e., when different methods are called from a single class, both get into `debug_backtrace` with the same object value, with `get_backtrace_objects` this would be a single entry.

I understand the functionality is already present in the `debug_backtrace`, however using that to get the list of caller objects adds a massive overhead for also generating other debug-related information. Extracting the objects makes it even slower.


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC