turn 'Use of undefined constant' into an error

This commit is contained in:
Shish 2020-06-24 12:44:17 +01:00
parent 1c216e8d51
commit eecd35d175

View file

@ -582,6 +582,15 @@ date and you should plan on moving elsewhere.
if (DEBUG) {
error_reporting(E_ALL);
}
set_error_handler(function ($errNo, $errStr) {
// Should we turn ALL notices into errors? PHP allows a lot of
// terrible things to happen by default...
if (strpos($errStr, 'Use of undefined constant ') === 0) {
throw new Exception("PHP Error#$errNo: $errStr");
} else {
return false;
}
});
// The trace system has a certain amount of memory consumption every time it is used,
// so to prevent running out of memory during complex operations code that uses it should