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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ianbytchek at gmail dot com
New email:
PHP Version: OS:

 

 [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-2019 The PHP Group
All rights reserved.
Last updated: Sun Oct 20 08:01:26 2019 UTC