2012-01-05 52 views
2

在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) 

我怎麼能sugest的$this->someThing類型的Netbeans和/或phpStorm?

+1

是 '對象A' 一個神奇的財產? – 2012-01-06 07:33:57

+0

@Nikolay Matveev沒有魔法,簡單的「private $ objectA;」在課堂上定義。 – frnhr 2012-01-07 12:48:58

回答

5

使用以下PHPDoc的註解:

MyClass類{

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

}