dongzhou1865 2010-06-30 10:54
浏览 52

如何在Zend Studio 7(Eclipse)中生成camelized getter和setter?

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.

  • 写回答

2条回答 默认 最新

  • douduiyun6125 2010-06-30 11:20
    关注

    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)

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?