phpdoc suggesting type for $this->someField

余生颓废 提交于 2019-12-07 23:49:14

问题


In Netbeans and phpStorm, this works as expected:

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

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

This does not:

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)

How can I sugest type of $this->someThing to Netbeans and/or phpStorm?


回答1:


Use the following PHPDoc annotation:

class MyClass {

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

}



来源:https://stackoverflow.com/questions/8750156/phpdoc-suggesting-type-for-this-somefield

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!