Generating Getters and Setters
Zend Studio can
automatically create getter and setter functions in order for 'Get' and
'Set' function calls to be easily created.
This procedure describes how to generate getter and setter functions
for all variables within a class.
To generate getters and setters:
In a PHP file,
place your cursor within the class for which you would like
to generate the getters and setters.
the class's source code and select Source
| Generate Getters and Setters -Or- from the Menu Bar
go to Source | Generate Getters
-Or- Right-click the required class in PHP Explorer view and
select Source | Generate
Getters and Setters
Getters and Setters' dialog will open, displaying all variables
that might require a getter/setter.
getters and Setters dialog
Which variables getter and setter functions should be
Expand the list under each function by clicking the + icon
in order to select to generate only a getter or a setter for
If your cursor was originally placed on a certain variable,
this will automatically be selected.
Insertion Point - Select the location in the class where
you want the entries to be added from the drop-down list.
First method - Getters and setters will be placed
as the first methods within the class.
Last method - Getters and setters will be placed
as the last methods within the class.
Cursor position - Getters and setters will be placed
at the cursor position (only available if cursor
was placed in a valid position).
After function ... - Getters and setters will be
placed after the selected function (depending on the functions
available within the class).
Sort by - Determine the order in which the entries are
The options are:
First getters, then setters - All the getters will
be grouped together, followed by the setters.
Fields in getter/setter pairs - Pairs of getters
and setters relating to the same variable will be generated
Access modifier (Not available in PHP 4 projects) -
Selects whether the functions will be public, protected, private
Generate method comments - Select whether to generate
a PHP Docblock for each entry.
relevant getter and setter functions will be generated for the
getter and Setter