Netbeans AutoComplete Methods Zend Model Classes

我只是一个虾纸丫 提交于 2019-12-24 19:12:04

问题


I have the following models classes however netbeans 7.0.1 autocomplete doesn't work for row classes.

Model Class:

class Application_Model_DbTable_Payments extends Zend_Db_Table_Abstract {
    protected $_name = 'payments';
    protected $_rowClass = 'Application_Model_Payment';

}

Row Class:

class Application_Model_Payment extends Zend_Db_Table_Row_Abstract {
    public function setIdentifier($identifier = null){
        return $this->identifier = $identifier;
    }
}

Code:

$paymentsModel = new Application_Model_DbTable_Payments();
$payment = $paymentsModel->find(1)->current();// return an Application_Model_Payment Object 
$payment->setIdentifier();//doesn't appear on netbeans autocomplete, only Zend_Db_Table_Row methods appers

How could I make netbeans show row class methods?


回答1:


Because netbeans uses heavily the docblock comments (and in this case find is an inherited method), unless you explicitly put the return type in the comment block for a method, Netbeans hasn't really got a clue what to do.

You can give it a hand though by doing adding a block like this:

/* @var $variable ClassName */

like so in your code

$paymentsModel = new Application_Model_DbTable_Payments();

/* @var $payment Application_Model_Payment */
$payment = $paymentsModel->find(1)->current();// return an Application_Model_Payment Object 
$payment->setIdentifier();

It will 'hint' netbeans as to what the variable is.

UPDATE: Here is an example of doing it from the class/method declaration. In this example $something is instantiation of Application_Model_Token.

class User
{
  /**
   * @return Application_Model_Token
   */
  public function reset()
  {
    //Some code etc
    return $something
  }
}


来源:https://stackoverflow.com/questions/7506194/netbeans-autocomplete-methods-zend-model-classes

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