phpdoc建议$ this-> someField的类型

时间:2012-01-05 21:33:58

标签: netbeans phpdoc phpstorm

在Netbeans和phpStorm中, 这按预期工作:

public function someMethod() {
    $objectA = uberEnterprisyFactory('someclassA');
    /* @var $objectA TheClassA */

    // $objectA-> (autocomplete for TheClassA is displayed, good)

这不是:

public function someMethod() {
    $this->objectA = uberEnterprisyFactory('somemodelA');
    /* @var $this->objectA TheClassA */

    // $this->objectA-> (no autocomplete here, not good, $this->objectA is inferred to be null)

如何向Netbeans和/或phpStorm提取$this->someThing类型?

1 个答案:

答案 0 :(得分:5)

使用以下PHPDoc注释:

  

类MyClass {

/**
 * @var MyPropertyClass
 */
private $myProperty
     

}