Re: [RFC] Reclassifying engine warnings
| From: | Theodore Brown | Date: | Fri, 30 Aug 2019 04:24:21 +0000 |
| Subject: | Re: [RFC] Reclassifying engine warnings | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106809@lists.php.net to get a copy of this message | ||
On Wed, Aug 28, 2019 at 4:33 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
> I think it's time to take a look at our existing warnings & notices in the
> engine, and think about whether their current classification is still
> appropriate. Error conditions like "undefined variable" only generating a
> notice is really quite mind-boggling.
>
> I've prepared an RFC with some suggested classifications, though there's
> room for bikeshedding here...
>
> https://wiki.php.net/rfc/engine_warnings
Nikita,
Thank you for your effort in putting together this RFC and explaining
the rationale for each change. From my perspective, converting more
error conditions from a notice/warning to an exception as proposed
will be a welcome step forward for the language.
I've frequently used PHP to write one-time scripts for migrating data
between services, or scripting changes to thousands of items via an
API. The lack of exceptions for things like undefined variables and
using a scalar value as an array has bitten me on multiple occasions.
There have even been times when simple mistakes like a typo in a
variable name have led to data loss, since instead of causing the
script to halt it just output a notice and continued running with
bad data.
In my experience, PHP's historical lax treatment of errors, far from
making it faster and easier to write scripts, *actually makes it take
longer* since I have to add extra assertions and boilerplate custom
error handling code in order to ensure that scripts don't keep
running in a broken state when one of these errors occurs.
So in summary, I think the proposed RFC is a solid step forward which
will help prevent expensive mistakes and make it simpler to write
robust code.
With appreciation,
Theodore