Skip to content

Commit

Permalink
code quality improvements
Browse files Browse the repository at this point in the history
Code quality improvements at level 2 of PHPStan
  • Loading branch information
deminy committed Dec 9, 2023
1 parent b269e2b commit 26622c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#Call to an undefined static method Swoole\\Coroutine\\Socket::import\(\).#'
- '#Access to an undefined property Swoole\\Coroutine\\Socket::\$__ext_sockets_timeout.#'
- '#Access to an undefined property Swoole\\Coroutine\\Socket::\$__ext_sockets_nonblock.#'
- '#Access to an undefined property Swoole\\Coroutine\\Http\\ClientProxy::\$errCode.#'
4 changes: 3 additions & 1 deletion src/core/Server/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ public static function handlerGetServerMemoryUsage($server, $msg)
$total += $result['manager'];

$n = $server->setting['worker_num'] + $server->setting['task_worker_num'];
/** @var int $n */
for ($i = 0; $i < $n; $i++) {
$key = 'worker-' . $i;
$result[$key] = self::getProcessMemoryRealUsage($server->getWorkerPid($i));
Expand All @@ -973,7 +974,7 @@ public static function handlerGetServerMemoryUsage($server, $msg)
// TODO: Support other OS
if (PHP_OS_FAMILY === 'Linux') {
preg_match('#MemTotal:\s+(\d+) kB#i', file_get_contents('/proc/meminfo'), $match);
$result['memory_size'] = $match[1] * 1024;
$result['memory_size'] = intval($match[1]) * 1024;
}

return self::json($result);
Expand All @@ -997,6 +998,7 @@ public static function handlerGetServerCpuUsage($server, $msg)
$total += $result['manager'][1] ?? 0;

$n = $server->setting['worker_num'] + $server->setting['task_worker_num'];
/** @var int $n */
for ($i = 0; $i < $n; $i++) {
$key = 'worker-' . $i;
$result[$key] = self::getProcessCpuUsage($server->getWorkerPid($i))[1] ?? 0;
Expand Down

0 comments on commit 26622c2

Please sign in to comment.