TP6 模型类 在PhpStorm中没有方法提示

审核中 Thinkphp6 未结 已结 置顶 精帖
删除 置顶 取消置顶 加精 取消加精
66 0
yswl
yswl VIP3 2021-09-04 10:28:32
悬赏:60金币 编辑此贴

用惯了 Phpstorm 的话,敲代码没方法提示令人不适,TP6模型类没方法提示因为缺少文档注释,可以将 tp5.1 的注释拿到tp6.0中,使其有方法提示


第一步:找到tp5.1框架的模型类文件


文件路径:

thinkphp\library\think\Model.php


复制 \think\Model 文档注释中的 @method

 * @method $this where(mixed $field, string $op = null, mixed $condition = null) static 查询条件
 * @method $this whereRaw(string $where, array $bind = []) static 表达式查询
 * @method $this whereExp(string $field, string $condition, array $bind = []) static 字段表达式查询
 * @method $this when(mixed $condition, mixed $query, mixed $otherwise = null) static 条件查询
 * @method $this join(mixed $join, mixed $condition = null, string $type = 'INNER') static JOIN查询
 * @method $this view(mixed $join, mixed $field = null, mixed $on = null, string $type = 'INNER') static 视图查询
 * @method $this with(mixed $with) static 关联预载入
 * @method $this count(string $field) static Count统计查询
 * @method $this min(string $field) static Min统计查询
 * @method $this max(string $field) static Max统计查询
 * @method $this sum(string $field) static SUM统计查询
 * @method $this avg(string $field) static Avg统计查询
 * @method $this field(mixed $field, boolean $except = false) static 指定查询字段
 * @method $this fieldRaw(string $field, array $bind = []) static 指定查询字段
 * @method $this union(mixed $union, boolean $all = false) static UNION查询
 * @method $this limit(mixed $offset, integer $length = null) static 查询LIMIT
 * @method $this order(mixed $field, string $order = null) static 查询ORDER
 * @method $this orderRaw(string $field, array $bind = []) static 查询ORDER
 * @method $this cache(mixed $key = null , integer $expire = null) static 设置查询缓存
 * @method mixed value(string $field) static 获取某个字段的值
 * @method array column(string $field, string $key = '') static 获取某个列的值
 * @method $this find(mixed $data = null) static 查询单个记录
 * @method $this[] select(mixed $data = null) static 查询多个记录
 * @method $this get(mixed $data = null,mixed $with =[],bool $cache= false) static 查询单个记录 支持关联预载入
 * @method $this getOrFail(mixed $data = null,mixed $with =[],bool $cache= false) static 查询单个记录 不存在则抛出异常
 * @method $this findOrEmpty(mixed $data = null,mixed $with =[],bool $cache= false) static 查询单个记录  不存在则返回空模型
 * @method $this[] all(mixed $data = null,mixed $with =[],bool $cache= false) static 查询多个记录 支持关联预载入
 * @method \think\Model withAttr(array $name,\Closure $closure) 动态定义获取器


第二步:刚复制的 @method 粘贴到 TP6.0 的 \think\Model 中


文件路径:

vendor\topthink\think-orm\src\Model.php


粘贴到此处

image

image


有方法提示了

image