【发布时间】:2016-09-16 05:17:38
【问题描述】:
如何让我的 IDE 注册此方法正在返回参数的实例?
所以我可以这样做:
Class::models()->getModel('newModel')->newModelMethodHere()?
代码有效,但 PHPStorm 中的自动完成功能无效。
/**
* Returns the object of the model
*
* @var $this->_models[$model] $model
* @param string object $model
* @throws Exception
* @return object
*/
public function getModel($model)
{
if (array_key_exists($model, $this->_models) && class_exists($model) && is_object($this->_models[$model])
&& $this->_models[$model] instanceof $model) {
if (is_a($this->_models[$model], $model)) {
/* @var $this->_models[$model] $model */
return ($this->_models[$model]);
}
}
throw new Exception('Model ' . (string)$model . ' is not registered correctly.');
}
【问题讨论】:
-
元数据应该会有所帮助(它仅适用于这种情况):confluence.jetbrains.com/display/PhpStorm/…stackoverflow.com/q/17666699/783119