Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

注释和参数类型完善 #646

Open
wants to merge 2 commits into
base: 3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DbManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected function getConnectionConfig(string $name): array
/**
* 创建连接.
*
* @param $name
* @param string $name
*
* @return ConnectionInterface
*/
Expand Down Expand Up @@ -295,7 +295,7 @@ protected function createConnection(string $name): ConnectionInterface
* 使用表达式设置数据.
*
* @param string $value 表达式
*
* @param array $bind 绑定参数
* @return Raw
*/
public function raw(string $value, array $bind = []): Raw
Expand Down
8 changes: 4 additions & 4 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ public function dec(string $field, float $step = 1)
/**
* 保存当前数据对象
*
* @param array|object $data 数据
* @param string $sequence 自增序列名
* @param array|object $data 数据
* @param string|null $sequence 自增序列名
*
* @return bool
*/
Expand Down Expand Up @@ -754,7 +754,7 @@ protected function updateData(): bool
/**
* 新增写入数据.
*
* @param string $sequence 自增名
* @param string|null $sequence 自增名
*
* @return bool
*/
Expand Down Expand Up @@ -1115,7 +1115,7 @@ public function offsetGet(mixed $name): mixed
/**
* 设置不使用的全局查询范围.
*
* @param array $scope 不启用的全局查询范围
* @param array|null $scope 不启用的全局查询范围
*
* @return Query
*/
Expand Down
12 changes: 6 additions & 6 deletions src/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ public function __construct($items, int $listRows, int $currentPage = 1, ?int $t
}

/**
* @param mixed $items
* @param int $listRows
* @param int $currentPage
* @param int $total
* @param bool $simple
* @param array $options
* @param mixed $items
* @param int $listRows
* @param int $currentPage
* @param int|null $total
* @param bool $simple
* @param array $options
*
* @return Paginator
*/
Expand Down
4 changes: 2 additions & 2 deletions src/db/BaseQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1445,8 +1445,8 @@ public function select(array $data = []): Collection
/**
* 查找单条记录.
*
* @param mixed $data 主键数据
* @param Closure $closure 闭包数据
* @param mixed $data 主键数据
* @param Closure|null $closure 闭包数据
*
* @throws Exception
* @throws ModelNotFoundException
Expand Down
6 changes: 3 additions & 3 deletions src/db/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CacheItem
/**
* 缓存tag.
*
* @var string
* @var string|array|null
*/
protected $tag;

Expand Down Expand Up @@ -104,7 +104,7 @@ public function getExpire()
/**
* 获取缓存Tag.
*
* @return string|array
* @return string|array|null
*/
public function getTag()
{
Expand Down Expand Up @@ -149,7 +149,7 @@ public function set($value)
/**
* 为此缓存项设置所属标签.
*
* @param string|array $tag
* @param string|array|null $tag
*
* @return $this
*/
Expand Down
4 changes: 2 additions & 2 deletions src/db/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ public function getLastSql(): string;
/**
* 获取最近插入的ID.
*
* @param BaseQuery $query 查询对象
* @param string $sequence 自增序列名
* @param BaseQuery $query 查询对象
* @param string|null $sequence 自增序列名
*
* @return mixed
*/
Expand Down
4 changes: 2 additions & 2 deletions src/db/Fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ public function save(array $data = [], bool $forceInsert = false): string
/**
* 批量插入记录.
*
* @param array $dataSet 数据集
* @param int $limit 每次写入数据限制
* @param array $dataSet 数据集
* @param int|null $limit 每次写入数据限制
*
* @return string
*/
Expand Down
14 changes: 7 additions & 7 deletions src/db/Mongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class Mongo extends BaseQuery
/**
* 执行指令 返回数据集.
*
* @param Command $command 指令
* @param string $dbName
* @param ReadPreference $readPreference readPreference
* @param string|array $typeMap 指定返回的typeMap
* @param Command $command 指令
* @param string $dbName
* @param ReadPreference|null $readPreference readPreference
* @param string|array $typeMap 指定返回的typeMap
*
* @throws AuthenticationException
* @throws InvalidArgumentException
Expand Down Expand Up @@ -102,7 +102,7 @@ public function listCollections(string $db = '')
/**
* COUNT查询.
*
* @param string $field 字段名
* @param string|null $field 字段名
*
* @return int
*/
Expand Down Expand Up @@ -457,8 +457,8 @@ public function slaveOk(bool $slaveOk)
/**
* 指定查询数量.
*
* @param int $offset 起始位置
* @param int $length 查询数量
* @param int $offset 起始位置
* @param int|null $length 查询数量
*
* @return $this
*/
Expand Down
10 changes: 5 additions & 5 deletions src/db/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ public function getTableFields($tableName): array
/**
* 获取数据表字段类型.
*
* @param mixed $tableName 数据表名
* @param string $field 字段名
* @param mixed $tableName 数据表名
* @param string|null $field 字段名
*
* @return array|string
*/
Expand Down Expand Up @@ -705,7 +705,7 @@ public function execute(string $sql, array $bind = []): int
*
* @param BaseQuery $query 查询对象
* @param mixed $sql sql指令
* @param bool $master 主库读取
* @param bool|null $master 主库读取
*
* @throws DbException
*
Expand Down Expand Up @@ -1733,8 +1733,8 @@ public function getLastSql(): string
/**
* 获取最近插入的ID.
*
* @param BaseQuery $query 查询对象
* @param string $sequence 自增序列名
* @param BaseQuery $query 查询对象
* @param string|null $sequence 自增序列名
*
* @return mixed
*/
Expand Down
2 changes: 1 addition & 1 deletion src/db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function exp(string $field, string $value)
/**
* 表达式方式指定当前操作的数据表.
*
* @param mixed $table 表名
* @param string $table 表名
*
* @return $this
*/
Expand Down
36 changes: 18 additions & 18 deletions src/db/concern/JoinAndViewQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ trait JoinAndViewQuery
/**
* 查询SQL组装 join.
*
* @param array|string|Raw $join 关联的表名
* @param mixed $condition 条件
* @param string $type JOIN类型
* @param array $bind 参数绑定
* @param array|string|Raw $join 关联的表名
* @param string|null $condition 条件
* @param string $type JOIN类型
* @param array $bind 参数绑定
*
* @return $this
*/
Expand All @@ -47,9 +47,9 @@ public function join(array | string | Raw $join, ?string $condition = null, stri
/**
* LEFT JOIN.
*
* @param array|string|Raw $join 关联的表名
* @param mixed $condition 条件
* @param array $bind 参数绑定
* @param array|string|Raw $join 关联的表名
* @param string|null $condition 条件
* @param array $bind 参数绑定
*
* @return $this
*/
Expand All @@ -61,9 +61,9 @@ public function leftJoin(array | string | Raw $join, ?string $condition = null,
/**
* RIGHT JOIN.
*
* @param array|string|Raw $join 关联的表名
* @param mixed $condition 条件
* @param array $bind 参数绑定
* @param array|string|Raw $join 关联的表名
* @param string|null $condition 条件
* @param array $bind 参数绑定
*
* @return $this
*/
Expand All @@ -75,9 +75,9 @@ public function rightJoin(array | string | Raw $join, ?string $condition = null,
/**
* FULL JOIN.
*
* @param array|string|Raw $join 关联的表名
* @param mixed $condition 条件
* @param array $bind 参数绑定
* @param array|string|Raw $join 关联的表名
* @param string|null $condition 条件
* @param array $bind 参数绑定
*
* @return $this
*/
Expand All @@ -90,8 +90,8 @@ public function fullJoin(array | string | Raw $join, ?string $condition = null,
* 获取Join表名及别名 支持
* ['prefix_table或者子查询'=>'alias'] 'table alias'.
*
* @param array|string|Raw $join JION表名
* @param string $alias 别名
* @param array|string|Raw $join JOIN表名
* @param string|null $alias 别名
*
* @return string|array
*/
Expand Down Expand Up @@ -137,9 +137,9 @@ protected function getJoinTable(array | string | Raw $join, ?string &$alias = nu
*
* @param array|string|Raw $join 数据表
* @param string|array|bool $field 查询字段
* @param string $on JOIN条件
* @param string $type JOIN类型
* @param array $bind 参数绑定
* @param string|null $on JOIN条件
* @param string $type JOIN类型
* @param array $bind 参数绑定
*
* @return $this
*/
Expand Down
12 changes: 6 additions & 6 deletions src/db/concern/ModelRelationQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@
/**
* 设置数据字段获取器.
*
* @param string|array $name 字段名
* @param callable $callback 闭包获取器
* @param string|array $name 字段名
* @param callable|null $callback 闭包获取器
*
* @return $this
*/
Expand Down Expand Up @@ -334,7 +334,7 @@
}

/**
* 关联预载入 In方式.
* 关联预载入 In 方式.
*
* @param array|string $with 关联方法名称
*
Expand All @@ -352,7 +352,7 @@
}

/**
* 关联预载入 JOIN方式.
* 关联预载入 JOIN 方式.
*
* @param array|string $with 关联方法名
* @param string $joinType JOIN方式
Expand Down Expand Up @@ -408,7 +408,7 @@
*
* @return $this
*/
protected function withAggregate(string | array $relations, string $aggregate = 'count', $field = '*', bool $subQuery = true)
protected function withAggregate(string | array $relations, string $aggregate = 'count', string $field = '*', bool $subQuery = true)

Check warning on line 411 in src/db/concern/ModelRelationQuery.php

View check run for this annotation

Codecov / codecov/patch

src/db/concern/ModelRelationQuery.php#L411

Added line #L411 was not covered by tests
{
if (empty($this->model)) {
return $this;
Expand All @@ -435,7 +435,7 @@
* @param string|array|bool $relation 关联方法名
* @param mixed $key 缓存key
* @param int|\DateTime $expire 缓存有效期
* @param string $tag 缓存标签
* @param string|null $tag 缓存标签
*
* @return $this
*/
Expand Down
6 changes: 3 additions & 3 deletions src/db/concern/ParamsBind.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function bind(array $value)
/**
* 单个参数绑定.
*
* @param mixed $value 绑定变量值
* @param int $type 绑定类型
* @param string $name 绑定标识
* @param mixed $value 绑定变量值
* @param int|null $type 绑定类型
* @param string|null $name 绑定标识
*
* @return string
*/
Expand Down
6 changes: 3 additions & 3 deletions src/db/concern/ResultOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ trait ResultOperation
/**
* 设置数据处理(支持模型).
*
* @param callable $filter 数据处理Callable
* @param string $index 索引(唯一)
* @param callable $filter 数据处理 Callable
* @param string|null $index 索引(唯一)
*
* @return $this
*/
Expand Down Expand Up @@ -155,7 +155,7 @@ protected function getResultAttr(array &$result, array $withAttr = []): void

/**
* 处理空数据.
* @param Closure $closure 闭包数据
* @param Closure|null $closure 闭包数据
* @throws DbException
* @throws ModelNotFoundException
* @throws DataNotFoundException
Expand Down
14 changes: 7 additions & 7 deletions src/db/concern/WhereQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ public function whereOrJsonContains(string $field, $condition)
/**
* 比较两个字段.
*
* @param string $field1 查询字段
* @param string $operator 比较操作符
* @param string $field2 比较字段
* @param string $logic 查询逻辑 and or xor
* @param string $field1 查询字段
* @param string $operator 比较操作符
* @param string|null $field2 比较字段
* @param string $logic 查询逻辑 and or xor
*
* @return $this
*/
Expand Down Expand Up @@ -601,9 +601,9 @@ public function removeWhereField(string $field, string $logic = 'AND')
/**
* 条件查询.
*
* @param mixed $condition 满足条件(支持闭包)
* @param Closure|array $query 满足条件后执行的查询表达式(闭包或数组)
* @param Closure|array $otherwise 不满足条件后执行
* @param mixed $condition 满足条件(支持闭包)
* @param Closure|array $query 满足条件后执行的查询表达式(闭包或数组)
* @param Closure|array|null $otherwise 不满足条件后执行
*
* @return $this
*/
Expand Down
Loading
Loading