style:代码格式化

This commit is contained in:
zyimm 2023-07-31 17:26:22 +08:00
parent b40a526ad7
commit 179f3b07ac
3 changed files with 93 additions and 73 deletions

View File

@ -27,12 +27,12 @@ class MongodbConnection extends Connection implements ConnectionInterface
/** /**
* @var Manager * @var Manager
*/ */
protected $connection; protected Manager $connection;
/** /**
* @var array * @var array
*/ */
protected $config; protected array $config;
/** /**
* @throws MongoDBException * @throws MongoDBException
@ -125,6 +125,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
/** /**
* @param Throwable $e * @param Throwable $e
*
* @return bool * @return bool
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -173,6 +174,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
* @param array $options * @param array $options
*
* @return array * @return array
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -204,6 +206,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
* @param array $options * @param array $options
*
* @return array * @return array
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -235,6 +238,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param int $currentPage * @param int $currentPage
* @param array $filter * @param array $filter
* @param array $options * @param array $options
*
* @return array * @return array
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -244,7 +248,8 @@ class MongodbConnection extends Connection implements ConnectionInterface
int $currentPage = 0, int $currentPage = 0,
array $filter = [], array $filter = [],
array $options = [] array $options = []
): array { ): array
{
// 查询数据 // 查询数据
$data = $result = []; $data = $result = [];
//每次最多返回10条记录 //每次最多返回10条记录
@ -256,6 +261,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* *
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
*
* @return int * @return int
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -285,6 +291,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
* @param array $options * @param array $options
*
* @return array * @return array
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -321,6 +328,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
* @param array $options * @param array $options
*
* @return array * @return array
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -351,6 +359,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param int $currentPage * @param int $currentPage
* @param array $filter * @param array $filter
* @param array $options * @param array $options
*
* @return array * @return array
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -360,7 +369,8 @@ class MongodbConnection extends Connection implements ConnectionInterface
int $currentPage = 0, int $currentPage = 0,
array $filter = [], array $filter = [],
array $options = [] array $options = []
): array { ): array
{
if (!empty($filter['_id']) && !($filter['_id'] instanceof ObjectId)) { if (!empty($filter['_id']) && !($filter['_id'] instanceof ObjectId)) {
$filter['_id'] = new ObjectId($filter['_id']); $filter['_id'] = new ObjectId($filter['_id']);
} }
@ -380,6 +390,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* *
* @param string $namespace * @param string $namespace
* @param array $data * @param array $data
*
* @return string * @return string
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -410,6 +421,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* *
* @param string $namespace * @param string $namespace
* @param array $data * @param array $data
*
* @return array * @return array
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -448,6 +460,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
* @param array $newObj * @param array $newObj
*
* @return bool * @return bool
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -485,6 +498,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
* @param array $newObj * @param array $newObj
*
* @return bool * @return bool
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -522,6 +536,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
* @param array $newObj * @param array $newObj
*
* @return bool * @return bool
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -563,6 +578,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
* @param array $newObj * @param array $newObj
*
* @return bool * @return bool
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -596,6 +612,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* *
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
*
* @return bool * @return bool
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -621,6 +638,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* *
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
*
* @return bool * @return bool
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -646,6 +664,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* *
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
*
* @return bool * @return bool
* @throws MongoDBException * @throws MongoDBException
*/ */
@ -674,6 +693,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
* *
* @param string $namespace * @param string $namespace
* @param array $filter * @param array $filter
*
* @return bool * @return bool
* @throws Exception * @throws Exception
* @throws MongoDBException * @throws MongoDBException

View File

@ -18,12 +18,12 @@ class MongoDBPool extends Pool
/** /**
* @var string * @var string
*/ */
protected $name; protected string $name;
/** /**
* @var array * @var array
*/ */
protected $config; protected mixed $config;
/** /**
* @param ContainerInterface $container * @param ContainerInterface $container

View File

@ -15,12 +15,12 @@ class PoolFactory
/** /**
* @var ContainerInterface * @var ContainerInterface
*/ */
protected $container; protected ContainerInterface $container;
/** /**
* @var Channel[] * @var Channel[]
*/ */
protected $pools = []; protected array $pools = [];
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -36,7 +36,7 @@ class PoolFactory
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function getPool(string $name) public function getPool(string $name): mixed
{ {
if (isset($this->pools[$name])) { if (isset($this->pools[$name])) {
return $this->pools[$name]; return $this->pools[$name];