2

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_labelName()
{
    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.

sneas
  • 924
  • 6
  • 23

2 Answers2

0

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)

Gordon
  • 312,688
  • 75
  • 539
  • 559
  • That is because you don't follow the ZF naming conventions for variables : `As with function names (see section 3.3) variable names must always start with a lowercase letter and follow the "camelCaps" capitalization convention.` (http://framework.zend.com/manual/en/coding-standard.naming-conventions.html) – wimvds Jun 30 '10 at 12:29
  • @wimvds read the whole chapter please :) we're talking about instance variables. – Gordon Jun 30 '10 at 12:51
  • Oops, indeed, mea culpa. The workaround I posted does work however, so you could use that until they fix it. – wimvds Jun 30 '10 at 13:04
  • @wimvds no problem. unfortunately your approach is indeed the only way right now. – Gordon Jun 30 '10 at 13:09
0

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

wimvds
  • 12,790
  • 2
  • 41
  • 42