Hello internals, I want to start a discussion on an RFC to add a declare() statement to convert all errors triggered within a file to exceptions.
Currently, the only way to handle notices/warnings in an exception-like manner is via set_error_handler, (for example, example #1 on https://www.php.net/errorexception) - however this has several disadvantages (in particular, it cannot be safely used in libraries without affecting other libraries). The declare() would only affect code on the particular PHP file for which the declare was set to 1, in the same way that strict_types only affects code on a particular PHP file. I have listed error_exception, error_exceptions, and strict_errors as potential names for the declare(), although I don't feel that any of them clearly and succinctly describe what is happening here (if anyone has a better name I'm certainly interested). As I do not have wiki karma, I have posted a draft RFC here: https://github.com/iggyvolz/php-rfcs/blob/master/error-exceptions.txt. A partially complete patch is linked at the bottom of the draft (very much based off the strict_types patch). Thanks, Katie Volz