From daa1822bc5f71216b68aa0548683e6255d44ff82 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 2 Apr 2022 19:20:47 +0800 Subject: [PATCH] fix the rest problem code to phpstan-level-1 --- phpstan.neon | 2 +- src/ZM/DB/UpdateBody.php | 2 +- src/ZM/Utils/CoMessage.php | 7 ++----- src/ZM/Utils/MessageUtil.php | 7 ++++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index d2324dce..d049a7bc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,6 @@ parameters: reportUnmatchedIgnoredErrors: false - level: 0 + level: 1 paths: - ./src/ ignoreErrors: diff --git a/src/ZM/DB/UpdateBody.php b/src/ZM/DB/UpdateBody.php index 0d36664e..a25c5ef7 100644 --- a/src/ZM/DB/UpdateBody.php +++ b/src/ZM/DB/UpdateBody.php @@ -44,7 +44,7 @@ class UpdateBody $msg[] = $k . ' = ?'; $arr[] = $v; } - if (($msg ?? []) == []) { + if ($msg == []) { throw new DbException('update value sets can not be empty!'); } $line = 'UPDATE ' . $this->table->getTableName() . ' SET ' . implode(', ', $msg); diff --git a/src/ZM/Utils/CoMessage.php b/src/ZM/Utils/CoMessage.php index a1dc8d6d..1199f6ba 100644 --- a/src/ZM/Utils/CoMessage.php +++ b/src/ZM/Utils/CoMessage.php @@ -14,10 +14,9 @@ use ZM\Utils\Manager\WorkerManager; class CoMessage { /** - * @param int $timeout * @return mixed */ - public static function yieldByWS(array $hang, array $compare, $timeout = 600) + public static function yieldByWS(array $hang, array $compare, int $timeout = 600) { $cid = Coroutine::getuid(); $api_id = ZMAtomic::get('wait_msg_id')->add(1); @@ -43,9 +42,7 @@ class CoMessage unset($sess[$api_id]); LightCacheInside::set('wait_api', 'wait_api', $sess); SpinLock::unlock('wait_api'); - if (isset($id)) { - swoole_timer_clear($id); - } + swoole_timer_clear($id); if ($result === null) { return false; } diff --git a/src/ZM/Utils/MessageUtil.php b/src/ZM/Utils/MessageUtil.php index 33d4b87d..11edbc49 100644 --- a/src/ZM/Utils/MessageUtil.php +++ b/src/ZM/Utils/MessageUtil.php @@ -22,12 +22,13 @@ class MessageUtil /** * 下载消息中 CQ 码的所有图片,通过 url * @param $msg - * @param null $path * @return array|false */ - public static function downloadCQImage($msg, $path = null) + public static function downloadCQImage($msg, ?string $path = null) { - $path = $path ?? DataProvider::getDataFolder() . 'images/'; + if ($path === null) { + $path = DataProvider::getDataFolder() . 'images/'; + } if (!is_dir($path)) { @mkdir($path); }