比如我的mysql数据库操作类中有这样一些方法是通过 __call 方法实现的,代码如下:
/**
* 一些特殊操作的方法
* @param string $method
* @param array $arguments
* @return mixed|string
*/
final public function __call($method, $arguments) {
switch ($method) {
case 'count':
case 'sum':
case 'min':
case 'max':
case 'avg':
/**
* 示例
* 1. $db->max('notice', 'add_time', ['type' => 1]); 获取 notice 表当 type 值为 1 的时候的 add_time 值最大的值
* 2. $db->sum('finance', 'num'); 获取 finance 表 num 字段值的和
*/ $result = $this->getOne($arguments[0], sprintf('%s(`%s`)', strtoupper($method), $arguments[1]), isset($arguments[2]) ? $arguments[2] : '', '', '', MYSQLI_NUM);
return $result[0];
case 'table':
break;
}
}
我改如何实现我在调用类似 max 方法的时候,phpstorm 也能给出方法调用提示呢?
定义之前加一下注释: