Formatter Preferences
Zend Studio can auto-format scripts to organize them into an easily readable format. The Formatter Preferences page allows you to customize the way it is formatted.
The Formatter Preferences Preferences page is accessed from Window | Preferences | PHP | Code Style | Formatter.
Creating Your Own Set of Configuration Settings
The default formatting settings are based on the PHP Conventions settings.
Click Show to see these settings.
|
|
|
To create your own set of configuration settings:
These are described in more detail below.
|
The new configuration will be added to the list. |
The Options Available in the Formatter Tabs
These options are available by clicking Show in the Formatter Preferences page.
Indentation
The Indentation tab allows you to configure the indentation size and select which elements should be indented.
The Indentation tab contains the following options:
General Settings
-
Tab Policy - Select Tab or Spaces from the drop-down list to set the indentation size for a tab.
-
Indentation size - If you select spaces, enter the number of spaces to be created.
- Tab size - Define the number of character spaces a tab contains.
- Default indentation for array initializers - Enter the default indentation for array initializers (in characters).
Indent
Select the elements to be indented by marking the relevant checkbox from the following options:
-
Declarations within class body
-
Statements within method/function body
-
Statements within blocks
-
Statements within 'switch' body
-
Statements within 'case' body
-
'break statements
-
Empty lines
Braces
The Braces tab allows you to configure brace positions.
Choose the brace positions (Same line, Next line or Next line indented) for the following:
-
Class or interface declaration
-
Method declaration
-
Blocks
-
'switch' statement
White Space
The White Space tab allows you to configure where spaces should be entered for declarations, control statements, expressions and arrays.
Expand each category by clicking on the + sign to configure which items are applied
to each instruction.
Standing on an item will display a list of possible syntax conditions in which white
spaces will be inserted. Select the required conditions by marking the relevant checkboxes.
Choosing 'sort options by Syntax element' from the drop down list will sort the list
of by syntax conditions rather than by element.
Blank Lines
The Blank Lines tab allows you to set the number of blank lines to be created in various conditions.
Enter the number of blank lines (between 0-32) to be created in the following conditions:
Blank Lines
-
Before class declarations
-
Before constant declarations
-
Before field declarations
-
Before function/method declarations
-
At beginning of function / method / body
Existing Blank Lines
-
Number of empty lines to preserve
New Lines
The New Lines tab allows you to select when new lines will be created.
The Options in the New Lines tab
Insert New Line
Select whether to insert a new line in the following conditions:
-
In empty class body
-
In empty method body
-
In empty block
-
Insert new line after method invocation, when chaining at least - When chaining at least the number of methods you specify here, a new line will be inserted after the method invocation.
Array Initializers
Select whether to:
-
Insert new line after opening parenthesis of array initializer
-
Insert new line before closing parenthesis of array initializer
Empty statements
Select whether to put empty statements on a new line.
Control Statements
The Control Statements tab allows you to configure the line formatting for Control Statements.
The Control Statements tab contains the following options:
General
-
Insert new line before 'else' and 'elseif' in an 'if' statement
-
Insert new line before 'catch' in a 'try' statement
-
Insert new line before 'while' in a 'do' statement
'if else'
-
Keep 'then' statement on same line
-
Keep simple 'if' on one line
-
Keep 'else' statement on same line
-
Keep 'else if' on one line
-
Keep 'return' or 'throw' clause on one line
Line Wrapping
The Line Wrapping tab allows you to configure Line Wrapping properties.
The Line Wrapping tab contains the following options:
Line Width and Indentation Levels
-
Maximum Line Width - Enter the maximum line width (in characters).
-
Default indentation for wrapped lines - Enter the default indentation for wrapped lines (in characters).
Line Wrapping and Indentation Policies
To set line wrapping and indentation wrapping policies for a specific element, select an element from the collapsible list and select an option from the 'Line wrapping policy' and 'Indentation policy' drop-down lists.
The elements for which the line and indentation policies can be applied are :
-
Class Declarations
-
'implements' clause'
-
Method Declarations
-
Parameters
-
Function Calls
-
Arguments
-
Object allocation arguments
-
Expressions
-
Binary expressions
-
Array Initializers
Comments
The Comments tab allows you to configure line comment formatting.
Off/On Tags
The Off/On Tags tab allows you to enable the Off/On tags. Off/On tags can be used in any comments to turn the formatter off and on in a source file.
Importing an Existing Formatting Configuration
|
|
|
To import an existing formatting configuration:
|
The new configuration will be added to the list. |
Exporting a Configuration File to an XML File
|
|
|
To export a configuration file to an XML file:
|
|
Formatter Preferences page
Applying Formatter Preferences Settings to a Specific Project
|
|
|
To apply Formatter Preferences settings to a specific project only:
|
|