8000 [HttpKernel] detect deprecations thrown by container initialization d… · symfony/symfony@e83d11b · GitHub
[go: up one dir, main page]

Skip to content

Commit e83d11b

Browse files
[HttpKernel] detect deprecations thrown by container initialization during tests
1 parent 50644d0 commit e83d11b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ protected function initializeContainer()
536536
if (!$cache->isFresh()) {
537537
if ($this->debug) {
538538
$collectedLogs = array();
539-
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
539+
$previousHandler = 6 < count(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 7));
540+
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
540541
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
541542
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
542543
}
@@ -572,7 +573,7 @@ protected function initializeContainer()
572573
$container = $this->buildContainer();
573574
$container->compile();
574575
} finally {
575-
if ($this->debug) {
576+
if ($this->debug && true !== $previousHandler) {
576577
restore_error_handler();
577578

578579
file_put_contents($this->getCacheDir().'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));

0 commit comments

Comments
 (0)
0