问题
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