updated-packages
This commit is contained in:
@@ -26,7 +26,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
private $optionalsEnabled = false;
|
||||
private $onlyOptionalsEnabled = false;
|
||||
|
||||
public function __construct(iterable $warmers = array(), bool $debug = false, string $deprecationLogsFilepath = null)
|
||||
public function __construct(iterable $warmers = [], bool $debug = false, string $deprecationLogsFilepath = null)
|
||||
{
|
||||
$this->warmers = $warmers;
|
||||
$this->debug = $debug;
|
||||
@@ -50,21 +50,20 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
*/
|
||||
public function warmUp($cacheDir)
|
||||
{
|
||||
if ($this->debug) {
|
||||
$collectedLogs = array();
|
||||
$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) {
|
||||
if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||
$collectedLogs = [];
|
||||
$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;
|
||||
}
|
||||
|
||||
if (isset($collectedLogs[$message])) {
|
||||
++$collectedLogs[$message]['count'];
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
$backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
// Clean the trace by removing first frames added by the error handler itself.
|
||||
for ($i = 0; isset($backtrace[$i]); ++$i) {
|
||||
if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) {
|
||||
@@ -73,14 +72,16 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
}
|
||||
}
|
||||
|
||||
$collectedLogs[$message] = array(
|
||||
$collectedLogs[$message] = [
|
||||
'type' => $type,
|
||||
'message' => $message,
|
||||
'file' => $file,
|
||||
'line' => $line,
|
||||
'trace' => $backtrace,
|
||||
'count' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,12 +97,14 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
$warmer->warmUp($cacheDir);
|
||||
}
|
||||
} finally {
|
||||
if ($this->debug && true !== $previousHandler) {
|
||||
if ($collectDeprecations) {
|
||||
restore_error_handler();
|
||||
|
||||
if (file_exists($this->deprecationLogsFilepath)) {
|
||||
$previousLogs = unserialize(file_get_contents($this->deprecationLogsFilepath));
|
||||
$collectedLogs = array_merge($previousLogs, $collectedLogs);
|
||||
if (\is_array($previousLogs)) {
|
||||
$collectedLogs = array_merge($previousLogs, $collectedLogs);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($this->deprecationLogsFilepath, serialize(array_values($collectedLogs)));
|
||||
@@ -114,7 +117,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
*
|
||||
* @return bool always false
|
||||
*/
|
||||
public function isOptional()
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user