mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 06:28:46 +02:00
N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)
* Update Symfony lib to version ~6.4.0 * Update code missing return type * Add an iTop general configuration entry to store application secret (Symfony mandatory parameter) * Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
@@ -29,29 +29,27 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
/**
|
||||
* @var TraceableAdapter[]
|
||||
*/
|
||||
private $instances = [];
|
||||
private array $instances = [];
|
||||
|
||||
public function addInstance(string $name, TraceableAdapter $instance)
|
||||
public function addInstance(string $name, TraceableAdapter $instance): void
|
||||
{
|
||||
$this->instances[$name] = $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null): void
|
||||
{
|
||||
$empty = ['calls' => [], 'config' => [], 'options' => [], 'statistics' => []];
|
||||
$empty = ['calls' => [], 'adapters' => [], 'config' => [], 'options' => [], 'statistics' => []];
|
||||
$this->data = ['instances' => $empty, 'total' => $empty];
|
||||
foreach ($this->instances as $name => $instance) {
|
||||
$this->data['instances']['calls'][$name] = $instance->getCalls();
|
||||
$this->data['instances']['adapters'][$name] = get_debug_type($instance->getPool());
|
||||
}
|
||||
|
||||
$this->data['instances']['statistics'] = $this->calculateStatistics();
|
||||
$this->data['total']['statistics'] = $this->calculateTotalStatistics();
|
||||
}
|
||||
|
||||
public function reset()
|
||||
public function reset(): void
|
||||
{
|
||||
$this->data = [];
|
||||
foreach ($this->instances as $instance) {
|
||||
@@ -59,14 +57,11 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
}
|
||||
}
|
||||
|
||||
public function lateCollect()
|
||||
public function lateCollect(): void
|
||||
{
|
||||
$this->data['instances']['calls'] = $this->cloneVar($this->data['instances']['calls']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'cache';
|
||||
@@ -90,14 +85,20 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
|
||||
/**
|
||||
* Method returns all logged Cache call objects.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCalls()
|
||||
public function getCalls(): mixed
|
||||
{
|
||||
return $this->data['instances']['calls'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns all logged Cache adapter classes.
|
||||
*/
|
||||
public function getAdapters(): array
|
||||
{
|
||||
return $this->data['instances']['adapters'];
|
||||
}
|
||||
|
||||
private function calculateStatistics(): array
|
||||
{
|
||||
$statistics = [];
|
||||
@@ -114,7 +115,7 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
/** @var TraceableAdapterEvent $call */
|
||||
foreach ($calls as $call) {
|
||||
++$statistics[$name]['calls'];
|
||||
$statistics[$name]['time'] += $call->end - $call->start;
|
||||
$statistics[$name]['time'] += ($call->end ?? microtime(true)) - $call->start;
|
||||
if ('get' === $call->name) {
|
||||
++$statistics[$name]['reads'];
|
||||
if ($call->hits) {
|
||||
@@ -136,10 +137,8 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
$statistics[$name]['misses'] += $call->misses;
|
||||
} elseif ('hasItem' === $call->name) {
|
||||
++$statistics[$name]['reads'];
|
||||
if (false === $call->result) {
|
||||
++$statistics[$name]['misses'];
|
||||
} else {
|
||||
++$statistics[$name]['hits'];
|
||||
foreach ($call->result ?? [] as $result) {
|
||||
++$statistics[$name][$result ? 'hits' : 'misses'];
|
||||
}
|
||||
} elseif ('save' === $call->name) {
|
||||
++$statistics[$name]['writes'];
|
||||
|
||||
Reference in New Issue
Block a user