jävi
jävi

Reputation:

Generate getters and setters (Zend Studio for Eclipse)

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!

Upvotes: 0

Views: 5450

Answers (5)

Will
Will

Reputation: 11

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.

Upvotes: 1

Eric Hogue
Eric Hogue

Reputation: 8920

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.

Upvotes: 4

jävi
jävi

Reputation:

@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".

Upvotes: 0

Omnipotent
Omnipotent

Reputation: 28207

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)

Upvotes: 3

workmad3
workmad3

Reputation: 25707

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.

Upvotes: 0

Related Questions