diff --git a/src/Mongodb.php b/src/Mongodb.php index 83c5ad5..104b570 100644 --- a/src/Mongodb.php +++ b/src/Mongodb.php @@ -205,7 +205,7 @@ class Mongodb * @return bool * @throws MongoDBException */ - public function insertOne($namespace, array $data = []) + public function insertOne($namespace, array $data = []): bool { try { /** @@ -220,12 +220,13 @@ class Mongodb /** * 插入批量数据 + * * @param $namespace * @param array $data - * @return bool|string + * @return array * @throws MongoDBException */ - public function insertMany($namespace, array $data) + public function insertMany($namespace, array $data): array { if (count($data) == count($data, 1)) { throw new MongoDBException('data is can only be a two-dimensional array'); @@ -397,10 +398,10 @@ class Mongodb * * @param string $namespace * @param array $filter - * @return bool + * @return int * @throws MongoDBException */ - public function count(string $namespace, array $filter = []) + public function count(string $namespace, array $filter = []): int { try { /** @@ -421,7 +422,7 @@ class Mongodb * @throws MongoDBException * @throws Exception */ - public function command(string $namespace, array $filter = []) + public function command(string $namespace, array $filter = []): bool { try { /** diff --git a/src/Pool/MongoDBPool.php b/src/Pool/MongoDBPool.php index 3778d88..9006d93 100644 --- a/src/Pool/MongoDBPool.php +++ b/src/Pool/MongoDBPool.php @@ -9,7 +9,9 @@ use Hyperf\Mongodb\MongodbConnection; use Hyperf\Pool\Pool; use Hyperf\Utils\Arr; use InvalidArgumentException; +use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; +use Psr\Container\NotFoundExceptionInterface; class MongoDBPool extends Pool { @@ -23,6 +25,12 @@ class MongoDBPool extends Pool */ protected $config; + /** + * @param ContainerInterface $container + * @param string $name + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ public function __construct(ContainerInterface $container, string $name) { $this->name = $name; diff --git a/src/Pool/PoolFactory.php b/src/Pool/PoolFactory.php index f9f9753..c3c0733 100644 --- a/src/Pool/PoolFactory.php +++ b/src/Pool/PoolFactory.php @@ -5,7 +5,9 @@ namespace Hyperf\Mongodb\Pool; use Hyperf\Di\Container; use Hyperf\Di\Exception\NotFoundException; +use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; +use Psr\Container\NotFoundExceptionInterface; use Swoole\Coroutine\Channel; class PoolFactory @@ -26,9 +28,15 @@ class PoolFactory } /** + * getPool + * + * @param string $name + * @return MongoDBPool|mixed|Channel * @throws NotFoundException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ - public function getPool(string $name): Channel + public function getPool(string $name) { if (isset($this->pools[$name])) { return $this->pools[$name];