[HttpKernel] Clarify error handler restoring process again

This commit is contained in:
Thomas Calvet 2019-08-08 08:39:07 +02:00
parent 48859fd125
commit 4ee54f0e84
1 changed files with 3 additions and 4 deletions

View File

@ -597,10 +597,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
return;
}
if ($this->debug) {
if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
$collectedLogs = [];
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
}
@ -636,7 +635,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$container = $this->buildContainer();
$container->compile();
} finally {
if ($this->debug && true !== $previousHandler) {
if ($collectDeprecations) {
restore_error_handler();
file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));