我有类Load
,其中我有方法model
来加载模型。方法模型将需要文件并创建具有名称的启动对象。
所以输出将是
require_once 'path_to_file/modelname.php';
$model = new Modelname_Model();
用法:
<?php
$m = $this->load->model('test');
$m->__here_should_be_autosugestion_for_model__
如何设置或编辑代码以phpstorm为我提供从变量返回的对象方法的自动搜索?
这是Load
类
class Load
{
/**
* Load model by name
* @param $name name of model
* @return object
*/
public function model($name)
{
if (!class_exists($name . '_Model')) {
require_once APP_DIR . '/models/' . strtolower($name) . '.php';
}
$model_name = ucfirst($name) . '_Model';
$model = new $model_name;
return $model;
}
我知道的唯一方法是使用内联类型注释来做到这一点
/**
* @var Test_Model $m
*/
$m = $this->load->model('test');
$m->__here_should_be_autosugestion_for_model__