生成 getter 和 setter (Zend Studio for Eclipse)

发布于 2024-07-06 12:17:46 字数 376 浏览 8 评论 0原文

我正在使用 Zend Studio for Eclipse (Linux),并且尝试在 PHP 类中生成 getter 和 setters 方法。

我尝试这样做:http://files.zend。 com/help/Zend-Studio-Eclipse-Help/creating_getters_and_setters.htm 但我在源菜单中没有“生成 Getters 和 Setters”选项,它被错过了!

你能帮我吗? 谢谢!

I'm using Zend Studio for Eclipse (Linux), and I'm trying to generate getter and setters methods in a PHP class.

I try to do this: http://files.zend.com/help/Zend-Studio-Eclipse-Help/creating_getters_and_setters.htm
but I haven't "Generate Getters and Setters" option in Source Menu, it's missed!

Could u help me? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

狠疯拽 2024-07-13 12:17:46

就像万能的说的,你可以使用模板来做到这一点。 我使用的是:

/**
 * @var ${PropertyType} 
 */
private $m${PropertyName};
${cursor}

/**
 *  Getter for ${PropertyName}
 *
 * @author ${user}
 * @since ${date} ${time}
 * @return ${PropertyType} private variable $m_${PropertyName}
 */
public function get${PropertyName}() 
{
  return $this->m_${PropertyName};
}

/**
 * Setter for ${PropertyName}
 *
 * @author ${user}
 * @since ${date} ${time}
 * @param ${PropertyType} $Value
*/
public function set${PropertyName}($Value) 
{
  $this->m_${PropertyName} = $Value;
}

要创建模板,只需转到首选项。 然后在 PHP/Templates 中您将看到模板列表。

Like Omnipotent say, you can use templates to do this. Here what I use:

/**
 * @var ${PropertyType} 
 */
private $m${PropertyName};
${cursor}

/**
 *  Getter for ${PropertyName}
 *
 * @author ${user}
 * @since ${date} ${time}
 * @return ${PropertyType} private variable $m_${PropertyName}
 */
public function get${PropertyName}() 
{
  return $this->m_${PropertyName};
}

/**
 * Setter for ${PropertyName}
 *
 * @author ${user}
 * @since ${date} ${time}
 * @param ${PropertyType} $Value
*/
public function set${PropertyName}($Value) 
{
  $this->m_${PropertyName} = $Value;
}

To create the template just go to the preferences. Then in PHP/Templates you will have your list of templates.

风吹雨成花 2024-07-13 12:17:46

它必须位于 Eclipse 菜单 - 源代码下。 您能否提供您的 Eclipse 快照以供验证。
编辑:我想在您的版本中不可能自动生成 getter 和 setter,尽管您可以为其创建模板并根据您的要求使用它。 无所不能 (0 秒前)

It has to be there under the menu - source in Eclipse. Could you provide a snapshot of your Eclipse to verify.
EDITED: I guess it is not possible to generate getters and setters automatically in your version, though you would be able to create templates for the same and use it as per your requirements. Omnipotent (0 seconds ago)

瀞厅☆埖开 2024-07-13 12:17:46

我还没有看到有人提到 Zend Studio ctrl+3 快捷方式/搜索:

ctrl+3 并搜索...

我输入“setters”,菜单上的第一个选项是“生成 Getters 和 Setters”向导。

I haven't seen anyone mention the Zend Studio ctrl+3 shortcut/search:

ctrl+3 and search...

I type "setters", and first option on the menu is the "Generate Getters and Setters" wizard.

颜漓半夏 2024-07-13 12:17:46

如果有“重构”菜单,也请在那里查看。 在 Eclipse 的更高版本中,许多这些方法已移至“重构”菜单,如果 Zend 最近更新但未更新其文档,则这些项目可能遇到了未记录的移动。

If there is a 'Refactor' menu, check in there as well. A lot of those methods have been moved to the 'Refactor' menu in later versions of eclipse and if Zend has updated recently and not updated it's documentation, the items may have encountered an undocumented move.

可遇━不可求 2024-07-13 12:17:46

@Omnipot它是Zend Studio v6.01,“生成getter和setter”功能应该可用。 我可以在帮助内容中看到有关它的文档。

顺便说一句,我会尝试更新到 v6.1

无论如何,谢谢!

编辑:模板和代码辅助工作正常,但作为“生成 getter 和 setter”没有用处。

@Omnipotent It's Zend Studio v6.01, "generate getters and setters" feature should be available. I can see doc about it in Help Contents.

By the way i'll try updating to v6.1

Thanks anyway!

EDITED: Templates and Code Assist works fine but are not usefull as "Generate getters and setters".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文