I am fixing a site of php errors down to notice. They way I am doing this is by enabling error_reporting and walking through the site, spotting errors and fixing them. I have noticed however, that this way I'm missing errors that are in unseen parts of a page, ie hidden inputs, invisible divs etc. Searching the source doesn't feel very convenient nor reliable.
I thought of creating an error handler either mailing me the errors or throwing an exception. The former would create a mess, the latter will only allow to spot one error and sometimes still will require viewing the source.
The point here is there's thousands of these errors, so even saving a couple of second on each would add up to a substantial time saving.
The question is if there's software that would highlight these errors for me, for instance a FF/Chrome extension?
Ok, setting up a custom error handler and piping error to FirePHP seems to do the trick. This shows me error from referenced files as well.
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
$br = php_sapi_name() == 'cli' ? '' : '<br>';
switch ($errno) {
case E_NOTICE: $errorType = 'Notice'; break;
case E_WARNING: $errorType = 'Warning'; break;
default: $errorType = 'Error'; break;
}
$message = "$errorType: $errstr $br
in $errfile $br
on line $errline";
if (php_sapi_name() == 'cli') {
throw new Exception($message);
} else {
\FirePHP::getInstance(true)->error($message);
}
});