Re: [RFC] Reclassifying engine warnings

From: Date: Sat, 14 Sep 2019 21:18:20 +0000
Subject: Re: [RFC] Reclassifying engine warnings
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-107095@lists.php.net to get a copy of this message
https://jaxenter.com/php-tiobe-sept-2019-162096.html I think this is one of those things we get from voting no... I might be wrong anyways :-? On Sat, Sep 14, 2019, 12:43 AM Kosit Supanyo <webdevxp.com@gmail.com> wrote: > Hi internals > > This maybe a little bit late but I would like to propose alternative to > this RFC. > > What if we add strict_errors declare to make every > function/method in > files that declared strict_errors throw ErrorException on > Notice/Warning. > > Example: > > File: Test.php > <?php > declare(strict_errors=1); // does not support block declare like > 'strict_type' > > class Test { > public function __construct() > { > echo $a; // ErrorException will be thrown from here > } > } > > File: main.php > <?php > require 'Test.php'; > $test = new Test(); // Fatal error: Uncaught ErrorException: Undefined > variable: a > > But if set_error_handler() is in use nothing will happen. > > File: main.php > <?php > require 'Test.php'; > set_error_handler(function () { > > }); > $test = new Test(); // silent > > I've just made a naive implementation to demonstrate this approach at > https://github.com/webdevxp/php-src. > What I've done was just adding new ZEND_ACC_STRICT_ERRORS flag to top level > function and modified php_error_cb to check if there is a > caller with > strict_errors defined. (by simply checking > EG(current_execute_data) and > its all prev_execute_data) > > I think this approach might satify both 'strict camp' and 'bc camp'. > > P.S. I myself agree with this RFC and would vote YES if I can vote. And I'm > grateful for Nikita's (and others) contributions that make PHP awesome > today. > > Cheers :) > > On Wed, Aug 28, 2019 at 4:33 PM Nikita Popov <nikita.ppv@gmail.com> wrote: > > > Hi internals, > > > > 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 > > > > Regards, > > Nikita > > >

« previous php.internals (#107095) next »