public static function PHPUnit_Util_ErrorHandler::handleErrorOnce in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpunit/phpunit/src/Util/ErrorHandler.php \PHPUnit_Util_ErrorHandler::handleErrorOnce()
Registers an error handler and returns a function that will restore the previous handler when invoked
Parameters
int $severity PHP predefined error constant:
Throws
Exception if event of specified severity is emitted
1 call to PHPUnit_Util_ErrorHandler::handleErrorOnce()
- PHPUnit_Util_Regex::pregMatchSafe in vendor/
phpunit/ phpunit/ src/ Util/ Regex.php
File
- vendor/
phpunit/ phpunit/ src/ Util/ ErrorHandler.php, line 93
Class
- PHPUnit_Util_ErrorHandler
- Error handler that converts PHP errors and warnings to exceptions.
Code
public static function handleErrorOnce($severity = E_WARNING) {
$terminator = function () {
static $expired = false;
if (!$expired) {
$expired = true;
// cleans temporary error handler
return restore_error_handler();
}
};
set_error_handler(function ($errno, $errstr) use ($severity) {
if ($errno === $severity) {
return;
}
return false;
});
return $terminator;
}