From 6851a2f432c77d7a282ff71f0f4bab68fdf1dbac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 9 Aug 2021 11:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Http/Context.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/HttpServer/Http/Context.php b/HttpServer/Http/Context.php index aef21255..20872ad0 100644 --- a/HttpServer/Http/Context.php +++ b/HttpServer/Http/Context.php @@ -39,9 +39,9 @@ class Context extends BaseContext public static function increment($id, int $value = 1, $coroutineId = null): bool|int { if (!isset(Coroutine::getContext($coroutineId)[$id])) { - return Coroutine::getContext($coroutineId)[$id] += $value; + Coroutine::getContext($coroutineId)[$id] = 0; } - return false; + return Coroutine::getContext($coroutineId)[$id] += $value; } /** @@ -52,13 +52,10 @@ class Context extends BaseContext */ public static function decrement($id, int $value = 1, $coroutineId = null): bool|int { - if (!static::hasContext($id)) { - return false; + if (!isset(Coroutine::getContext($coroutineId)[$id])) { + Coroutine::getContext($coroutineId)[$id] = 0; } - if (isset(Coroutine::getContext($coroutineId)[$id])) { - return Coroutine::getContext($coroutineId)[$id] -= $value; - } - return false; + return Coroutine::getContext($coroutineId)[$id] -= $value; } /**