> 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).
> Katie Volz
I did a similar PoC last summer (see:
where Nikita commented that a lot of those warnings could/should be promoted
to error regardless, and this is what myself and a couple of other people
been during for the past year.
There are still extensions which didn't receive this treatment mostly due
of time and hands, so if you want to join on this feel free to send a PR to
Due to the work already done, I personally see less interest in such a
Mostly because doing a promotion of these warnings, which are usually tied
in to a failure return value such as null or false, allows us in some
"clean" up the return value, but only if it's done on the extension
Now I do acknowledge the number of E_WARNINGs still present on master is
large, but I'd personally prefer to focus on making the language better for
everyone and let legit warnings be warnings mostly due to the legacy
for I/O operations.
George P. Banyard