-
Notifications
You must be signed in to change notification settings - Fork 8k
Adds possibility to include called object in exception backtrace #20599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,116 @@ | |||
| --TEST-- | |||
| Exceptions providing object | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am personally interested in this to be able to inspect the called Closures. If this PR will allow this, please add a test like https://3v4l.org/YqFcG (my usecase it is to able to extract $this and use variable in catch clause of the called closure).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mvorisek I have updated the testcase to include a closure as well. Variables use'd are not part of the trace as the closure object points to the object the closure is bind to.
|
One thing to note is that enabling |
91ced6a to
cebe433
Compare
True, and the same is true for objects referenced in arguments. I have added a note to |
This needs a discussion on the internals list at least. If somebody objects, it will need an RFC.
New features should not target patches, see https://wiki.php.net/rfc/release_cycle_update#disallow_new_features_in_release_candidates_and_bug_fix_releases.
IMO, that part would definitely require an RFC. |
This patch adds the ability to populate the called
objectinto exception backtraces.Previously, only
debug_backtrace()could include the called object in its frames, butException::getTrace()could not. This change alignsException::getTrace()withdebug_backtrace()by introducing a new INI directive:zend.exception_provide_object (boolean)This directive is analogous to the existing
zend.exception_ignore_argsoption, but controls whether theobjectfield is included in exception backtraces.Behavior:
object(where applicable).Defaults:
zend.exception_provide_object = Offphp.ini-production:zend.exception_provide_object = Offphp.ini-development:zend.exception_provide_object = OnUse cases and considerations:
This feature is primarily intended for development and debugging.
Provides richer diagnostic information by exposing the actual object on which methods were invoked.
Can help track down state-dependent bugs that depend on specific object properties.
However, it is not recommended for production environments, because:
For production systems,
zend.exception_provide_objectshould remain disabled.Open questions:
zend.exception_provide_objectbe enabled by default inrun-tests.php(similar tozend.exception_ignore_args=0)