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.
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. |
These options are available by clicking Show in the Formatter Preferences page.
The Indentation tab allows you to configure the indentation size and select which elements should be indented.
The Indentation tab contains the following options:
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.
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
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
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.
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:
Before class declarations
Before constant declarations
Before field declarations
Before function/method declarations
At beginning of function / method / body
Number of empty lines to preserve
The New Lines tab allows you to select when new lines will be created.
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.
Select whether to:
Insert new line after opening parenthesis of array initializer
Insert new line before closing parenthesis of array initializer
Select whether to put empty statements on a new line.
The Control Statements tab allows you to configure the line formatting for Control Statements.
The Control Statements tab contains the following options:
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
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
The Line Wrapping tab allows you to configure Line Wrapping properties.
The Line Wrapping tab contains the following options:
Maximum Line Width - Enter the maximum line width (in characters).
Default indentation for wrapped lines - Enter the default indentation for wrapped lines (in characters).
Default indentation for array initializers - Enter the default indentation for array initializers (in characters).
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
The Comments tab allows you to configure line comment formatting.
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.
|
|
|
To import an existing formatting configuration:
|
The new configuration will be added to the list. |
|
|
|
To export a configuration file to an XML file:
|
|
Formatter Preferences page
|
|
|
To apply Formatter Preferences settings to a specific project only:
|
|
|
|
|
Related Links: |
|
|
©1999-2012 Zend Technologies LTD. All rights reserved.