Merge branch '3.3' into 3.4

* 3.3:
  Fix isolated error handling
This commit is contained in:
Nicolas Grekas 2017-10-25 10:01:59 +02:00
commit c98db6ae2e

View File

@ -251,15 +251,16 @@ class DeprecationErrorHandler
$deprecations = array();
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
return $previousErrorHandler ? $previousErrorHandler($type, $msg, $file, $line, $context) : false;
if ($previousErrorHandler) {
return $previousErrorHandler($type, $msg, $file, $line, $context);
}
$ErrorHandler = class_exists('PHPUnit_Util_ErrorHandler', false) ? 'PHPUnit_Util_ErrorHandler' : 'PHPUnit\Util\ErrorHandler';
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
}
$deprecations[] = array(error_reporting(), $msg);
});
// This can be registered before the PHPUnit error handler.
if (!$previousErrorHandler) {
$UtilPrefix = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_' : 'PHPUnit\Util\\';
$previousErrorHandler = $UtilPrefix.'ErrorHandler::handleError';
}
register_shutdown_function(function () use ($outputFile, &$deprecations) {
file_put_contents($outputFile, serialize($deprecations));