Example:
protected $_labelName = null;
Should generate
public function getLabelName()
{
$this->_labelName;
}
public function setLabelName($labelName)
{
$this->_labelName = $labelName;
return $this;
}
But it is generates
public function get_la开发者_如何学GobelName()
{
return $this->_labelName;
}
public function set_labelName($_labelName)
{
$this->_labelName = $_labelName;
return $this;
}
As you could see - it looks different but i didn't found the way how to change the method name and to trim the set method param name.
A simple workaround : name your var $labelName, then generate getters and setters, and finally refactor/rename the var so it becomes $_labelName. Works in Zend Studio 7.2 (just downloaded the trial to check it :p).
You can change the method body (and comment) by clicking
Window > Preferences > PHP > Editor > Templates
I don't think you can change the method signature though. I'll open a ticket with Zend and ask for a way to change it. It's kinda annoying that the premier IDE for Zend Framework generates getters and setters that are not in compliance with the ZF code convention.
EDIT This was fixed in Zend Studio 8. When you generate Getters/Setters, they will not include the the leading underscore indicating private or protected visibility. Any underscores later in the member name will be kept, e.g. $_foo
will generate getFoo()
and setFoo($_foo)
, while $_foo_bar
(which is invalid by ZF convention) will generate getFoo_bar()
and setFoo_bar($_foo_bar)
精彩评论