PHP RFC: Recoverably fatal exceptions in undeterministic contexts
- Version: 0.1
- Date: 2015-02-13
- Author: Bob Weinand, firstname.lastname@example.org
- Status: Draft
- First Published at: http://wiki.php.net/rfc/undeterministic_exceptions
Exceptions thrown from undeterministic contexts, like destructors, signal handlers, tick handlers etc. shouldn't throw exceptions into the scope from which they were called.
That may lead to weird behavior, like unexpected types of exceptions. (For example a catch all handler for one specific task receives an exception thrown from a destructor due to garbage collection occurring. It will handle the error in an inappropriate way.)
Make uncaught exceptions, thrown from functions called from these undeterministic contexts, call the exception handler, and, if not handled, throw an E_RECOVERABLE_ERROR.
As undeterministic context counts everything which is not explicitly or implicitly called by direct use of an operator or function. (No, unset() only decrements the refcount, the calling of the destructor is a side-effect)
Backward Incompatible Changes
That would break code relying on destructors to be called in a specific context. Which shouldn't be relied on. It only works in special cases like no cyclic references.
Proposed PHP Version(s)
Next minor PHP version to come (7.0 in this case).
Proposed Voting Choices
This vote doesn't affect the language itself, so it requires a 50%+1 majority.