From 3b8ed8afb94902494f0ecec4ad866d5d3ede3534 Mon Sep 17 00:00:00 2001 From: yf <291323003@qq.com> Date: Mon, 21 Jan 2019 13:43:30 +0800 Subject: [PATCH] up --- ...HandlerInterface.php => ContextItemHandlerInterface.php} | 2 +- src/Context/ContextManager.php | 6 +++--- ...textContextHandler.php => ContextContextItemHandler.php} | 4 ++-- tests/ContextTest.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename src/Context/{ContextHandlerInterface.php => ContextItemHandlerInterface.php} (83%) rename tests/{ContextContextHandler.php => ContextContextItemHandler.php} (78%) diff --git a/src/Context/ContextHandlerInterface.php b/src/Context/ContextItemHandlerInterface.php similarity index 83% rename from src/Context/ContextHandlerInterface.php rename to src/Context/ContextItemHandlerInterface.php index 0edcea6..0ba299f 100644 --- a/src/Context/ContextHandlerInterface.php +++ b/src/Context/ContextItemHandlerInterface.php @@ -9,7 +9,7 @@ namespace EasySwoole\Component\Context; -interface ContextHandlerInterface +interface ContextItemHandlerInterface { function onContextCreate(); function onDestroy($context); diff --git a/src/Context/ContextManager.php b/src/Context/ContextManager.php index a4d0820..4e5bf03 100644 --- a/src/Context/ContextManager.php +++ b/src/Context/ContextManager.php @@ -23,7 +23,7 @@ class ContextManager private $deferList = []; - public function registerItemHandler($key, ContextHandlerInterface $handler):ContextManager + public function registerItemHandler($key, ContextItemHandlerInterface $handler):ContextManager { $this->contextHandler[$key] = $handler; return $this; @@ -46,7 +46,7 @@ public function get($key,$cid = null) return $this->context[$cid][$key]; } if(isset($this->contextHandler[$key])){ - /** @var ContextHandlerInterface $handler */ + /** @var ContextItemHandlerInterface $handler */ $handler = $this->contextHandler[$key]; $this->context[$cid][$key] = $handler->onContextCreate(); return $this->context[$cid][$key]; @@ -59,7 +59,7 @@ public function unset($key,$cid = null) $cid = $this->getCid($cid); if(isset($this->context[$cid][$key])){ if(isset($this->contextHandler[$key])){ - /** @var ContextHandlerInterface $handler */ + /** @var ContextItemHandlerInterface $handler */ $handler = $this->contextHandler[$key]; $item = $this->context[$cid][$key]; unset($this->context[$cid][$key]); diff --git a/tests/ContextContextHandler.php b/tests/ContextContextItemHandler.php similarity index 78% rename from tests/ContextContextHandler.php rename to tests/ContextContextItemHandler.php index 509497c..9406895 100644 --- a/tests/ContextContextHandler.php +++ b/tests/ContextContextItemHandler.php @@ -9,10 +9,10 @@ namespace EasySwoole\Component\Tests; -use EasySwoole\Component\Context\ContextHandlerInterface; +use EasySwoole\Component\Context\ContextItemHandlerInterface; use EasySwoole\Utility\Random; -class ContextContextHandler implements ContextHandlerInterface +class ContextContextItemHandler implements ContextItemHandlerInterface { function onContextCreate() diff --git a/tests/ContextTest.php b/tests/ContextTest.php index 80ce54f..0d7f8d6 100644 --- a/tests/ContextTest.php +++ b/tests/ContextTest.php @@ -16,7 +16,7 @@ class ContextTest extends TestCase { function __construct(?string $name = null, array $data = [], string $dataName = '') { - ContextManager::getInstance()->registerItemHandler('handler',new ContextContextHandler()); + ContextManager::getInstance()->registerItemHandler('handler',new ContextContextItemHandler()); parent::__construct($name, $data, $dataName); }