member variables and @var phpdoc type hinting

I've been using inline @var declarations for type hinting PHP to use the prediction and reference jumping in Eclipse but what is the structure when it is a member variable like in the example below? (the below does not seem to work)

/* @var $this->obj AbcObj */
$this->obj = Factory::get(...);

*Assume a wide variety of object types can come out of the factory.


In the class declaration that $this represents, if you have declared $obj as a class variable, then put a docblock on it:

class Foo
{
    /**
     * @var AbcObj
     */
    $obj = null;
}

That should give you exactly what you're after. That inline /** @var thing was something that evolved out in the wild to give this behavior to local non-class variables, based on wanting that autocompletion that exists for class variables.

链接地址: http://www.djcxy.com/p/58622.html

上一篇: 使用is进行测试后,PhpStorm类型提示对象阵列失败

下一篇: 成员变量和@var phpdoc类型提示