bug #25413 [HttpKernel] detect deprecations thrown by container initialization during tests (nicolas-grekas)
This PR was merged into the 3.3 branch.
Discussion
----------
[HttpKernel] detect deprecations thrown by container initialization during tests
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #24767
| License | MIT
| Doc PR | -
Commits
-------
81248bc855
[HttpKernel] detect deprecations thrown by container initialization during tests
This commit is contained in:
commit
d200185563
@ -536,7 +536,8 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
if (!$cache->isFresh()) {
|
||||
if ($this->debug) {
|
||||
$collectedLogs = array();
|
||||
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
|
||||
$previousHandler = defined('PHPUNIT_COMPOSER_INSTALL');
|
||||
$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;
|
||||
}
|
||||
@ -572,7 +573,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
$container = $this->buildContainer();
|
||||
$container->compile();
|
||||
} finally {
|
||||
if ($this->debug) {
|
||||
if ($this->debug && true !== $previousHandler) {
|
||||
restore_error_handler();
|
||||
|
||||
file_put_contents($this->getCacheDir().'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));
|
||||
|
Reference in New Issue
Block a user