JosephLenton / PHP-Error

Better error reporting for PHP, and prettier too!
1.35k stars 151 forks source link

Thoughts on having a whitelist? #86

Open jamesshannon opened 10 years ago

jamesshannon commented 10 years ago

Hi. I use concrete5, which probably has more "minor code errors" than wordpress (in fact, I see you have a "sloppy concrete5" option).

However, when I'm developing, I want my sloppiness to be called out.

I think there are two ways of doing this, and I'd like to hear your thoughts. One is to whitelist the entire core directory, which should be easy enough. Only my custom code will get "handled" by php error, and everything else can be discarded, or only sent to the log. (When I say discarded, I mean the types of errors that would otherwise not be reported at all (E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED)).

However, I see two problems. One of which is that I might use an API call incorrectly which causes an notice/warning to get called (though I guess you can look at the entire trace). The other of which is that this doesn't allow for development of the core (or at least keeping me honest). All in all, whitelisting the core directory seems a bit sloppy.

The alternative is to build a whitelist of known and "accepted" errors. You can put php error in "learning mode" and click around on a freshly installed site and it'll log all error signatures (code, line, and file, maybe for the next on the stack, too), and create a hash which, if matched, gets skipped. Alternatively (or in addition), you can choose to permanently silence an error that's thrown (through some link, which adds to the whitelist.

Thoughts? Any novel approach that you'd recommend?

James