【问题标题】:How to set PhpStorm recognize variable's class如何设置 PhpStorm 识别变量的类
【发布时间】:2015-11-03 10:21:13
【问题描述】:

我在 PhpStorm 中遇到了一个问题。我有一个代码:

/**
 * $this->data['rows'] My_Class[]
 */
public function countRows(){
    foreach($this->data['rows'] as $row){
        $row->(here i want to get all functions in a class with autocomplete)
    }
}

在这里,我尝试使用 PhpStorm 自动完成助手来访问类函数,但这不起作用。

如何使用 PHPDoc 定义一些变量的确切类或类型?

【问题讨论】:

    标签: php phpstorm phpdoc


    【解决方案1】:

    您可以直接使用/** @var MyClass $row */ PHPDoc 注释输入提示$row 变量:

    foreach($this->data['rows'] as $row){
        /** @var MyClass $row */
        $row->(here i want to get all functions in a class with autocomplete)
    }
    

    【讨论】:

    • 谢谢!这正是我想要的!
    猜你喜欢
    • 2016-07-29
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-16
    • 2017-04-14
    • 1970-01-01
    相关资源
    最近更新 更多