for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Hhxsv5\LaravelS\Components\Prometheus;
use Hhxsv5\LaravelS\Components\Prometheus\Collectors\SwooleWorkerCollector;
use Hhxsv5\LaravelS\Swoole\Process\CustomProcessInterface;
use Swoole\Http\Server;
use Swoole\Process;
use Swoole\Timer;
class PrometheusCollectorProcess implements CustomProcessInterface
{
private static $timerId;
public static function callback(Server $swoole, Process $process)
/**@var \Hhxsv5\LaravelS\Components\Prometheus\PrometheusCollector $collector */
$collector = app(SwooleWorkerCollector::class);
app
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$collector = /** @scrutinizer ignore-call */ app(SwooleWorkerCollector::class);
$workerNum = $swoole->setting['worker_num'];
$taskWorkerNum = isset($swoole->setting['task_worker_num']) ? $swoole->setting['task_worker_num'] : 0;
$totalNum = $workerNum + $taskWorkerNum - 1;
$workerIds = range(0, $totalNum);
$runJob = function () use ($swoole, $workerIds, $collector) {
foreach ($workerIds as $workerId) {
$swoole->sendMessage($collector, $workerId);
}
};
$interval = config('prometheus.collect_metrics_interval', 10) * 1000;
config
$interval = /** @scrutinizer ignore-call */ config('prometheus.collect_metrics_interval', 10) * 1000;
self::$timerId = Timer::tick($interval, $runJob);
public static function onReload(Server $swoole, Process $process)
Timer::clear(self::$timerId);
public static function onStop(Server $swoole, Process $process)
$swoole
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public static function onStop(/** @scrutinizer ignore-unused */ Server $swoole, Process $process)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$process
public static function onStop(Server $swoole, /** @scrutinizer ignore-unused */ Process $process)