Last active
September 9, 2019 21:22
-
-
Save yaredc/e231d33a2ff2caeabbd45f647cbcc858 to your computer and use it in GitHub Desktop.
Fix all PHP notices and warnings with this one simple trick!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
/* | |
* Convert all notices and warnings to errors. | |
* There is no point in warnings and notices. | |
*/ | |
set_error_handler(static function ($errno, $errstr, $errfile, $errline): bool { | |
switch ($errno) { | |
case E_WARNING: | |
case E_NOTICE: | |
throw new ErrorException($errstr, $errno, E_ERROR, $errfile, $errline); | |
break; | |
} | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment