Siz*_*ode 55 php codeigniter phpstorm
我已经在我的codeigniter库文件夹中点燃了数据表库.
图书馆的一些代码
class Datatables
{
/**
* Global container variables for chained argument results
*
*/
protected $ci;
protected $table;
protected $distinct;
protected $group_by;
protected $select = array();
protected $joins = array();
protected $columns = array();
protected $where = array();
protected $filter = array();
protected $add_columns = array();
protected $edit_columns = array();
protected $unset_columns = array();
/**
* Copies an instance of CI
*/
public function __construct()
{
$this->ci =& get_instance();
}
Run Code Online (Sandbox Code Playgroud)
然后我在模型中调用了库
class Common_Model extends MY_Model{
function __construct(){
parent::__construct();
$this->load->library('Datatables.php');
}
Run Code Online (Sandbox Code Playgroud)
然后我试图调用库函数
function select_fields_joined_DT($data, $PTable, $joins = '', $where = '', $addColumn = '',$unsetColumn='')
{
/**
*
*/
$this->datatables->select($data);
if ($unsetColumn != '') {
unset_column($unsetColumn);
}
$this->datatables->from($PTable);
if ($joins != '') {
foreach ($joins as $k => $v) {
//$this->datatables->join($v['table'], $v['condition'], $v['type']);
}
}
if ($addColumn != '') {
$this->datatables->add_column("Actions", $addColumn);
}
$result = $this->datatables->generate();
return $result;
}
Run Code Online (Sandbox Code Playgroud)
一切正常,除了phpstorm告诉我错误
Field Accessed via magic method
Run Code Online (Sandbox Code Playgroud)

我试图用文档注释删除此错误,但无法弄清楚我该怎么做..任何帮助将不胜感激.
chr*_*san 86
如果你想删除此文件没有评论,你可以取消通知有关访问通过魔术方法字段这是在发现
项目设置 > 检查 > PHP > 未定义 > 未定义字段

Emi*_*ron 34
您必须
@property在属于该类的PHPDoc注释中声明它们.
/**
* @property string $bar
*/
class Foo {
public function __get($name) {
if ($name == 'bar') {
return 'bar';
}
return NULL;
}
}
Run Code Online (Sandbox Code Playgroud)
来自Dmitry Dulepov的文章"快速提示:魔术方法和PhpStorm".
小智 5
如果您不想禁用整个项目的检查,并且无法修改类文件以添加标签@property,则可以在使用它的位置抑制警告:
/** @noinspection PhpUndefinedFieldInspection */
Run Code Online (Sandbox Code Playgroud)
只需将其添加到使用魔法场的行之前的新行中即可。