Customize formatting
Many companies have coding guidelines when creating source code. Our PHP formatter can be highly customized to follow those guidelines.
Fully customizable formatter is available for PREMIUM users. Community version users can setup the formatter through php.format.codestyle
settings.
php.format.codestyle
setting serves as a base and each formatting option you specify will override the particular behaviour.
Note: The list of options grows each release, please let us know what option are you missing.
Indentation
Setting: php.format.rules.indentBraces
IndentBraces: Gets value indicating whether to indent braces
true | false |
|
|
Spacing
Setting: php.format.rules.spaceAfterCast
Space after cast: Insert a space after a cast operator.
true | false |
|
|
Setting: php.format.rules.spaceAfterUnaryNot
Space after unary not !
:
Insert a space after a unary not operator.
true | false |
|
|
Setting: php.format.rules.spaceAroundConcatenation
Space around concatenation .
:
Insert a space around concatenation operator.
true | false |
|
|
Setting: php.format.rules.spaceBeforeColonInControlStatements
Space before colon :
in control flow statements:
Insert a space before colon in control flow blocks.
true | false |
|
|
Setting: php.format.rules.spaceBeforeColonInReturnType
Space before colon :
in return type:
Insert a space before colon in a return type
true | false |
|
|
Setting: php.format.rules.spaceBeforeParenthesesInArrowFunctions
Space before parentheses in arrow functions: Insert a space before arrow function parentheses.
true | false |
|
|
Setting: php.format.rules.spaceBeforeParenthesesInCalls
Space before parentheses in function calls: Insert a space before parentheses in method, function and constructor call parentheses.
true | false |
|
|
Setting: php.format.rules.spaceBeforeParenthesesInControlStatements
Space before parentheses in control statements: Insert a space before parentheses in control statements.
true | false |
|
|
Setting: php.format.rules.spaceBeforeParenthesesInDeclarations
Space before parentheses in declarations: Insert a space before parentheses in method, function and constructor declaration parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinArrayInitilizersParens
Space within array initializer parentheses: Insert a space within array initializer parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinBrackets
Space within brackets []
:
Insert a space within brackets.
true | false |
|
|
Setting: php.format.rules.spaceWithinBracketsAroundExpression
Space within brackets []
around expression:
Insert a space within brackets around expression.
true | false |
|
|
Setting: php.format.rules.spaceWithinCallParens
Space within call parentheses: Insert a space within method, function and constructor call parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinCatchParens
Space within catch
parentheses:
Insert a space within catch
statement header parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinDeclParens
Space within declaration parentheses: Insert a space within method, function and constructor declaration parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinExpressionParens
Space within parentheses around expression: Insert a space within parentheses around expression.
true | false |
|
|
Setting: php.format.rules.spaceWithinForParens
Space within for
parentheses:
Insert a space within for
statement header parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinForeachParens
Space within foreach
parentheses:
Insert a space within foreach
statement header parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinIfParens
Space within if
parentheses:
Insert a space within if
statement header parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinSwitchParens
Space within switch
parentheses:
Insert a space within switch
statement header parentheses.
true | false |
|
|
Setting: php.format.rules.spaceWithinWhileParens
Space within while
parentheses:
Insert a space within while
statement header parentheses.
true | false |
|
|
NewLines
Setting: php.format.rules.catchOnNewLine
catch
on a new line:
Place catch
on a new line.
true | false |
|
|
Setting: php.format.rules.elseOnNewLine
else
on a new line:
Place else
on a new line.
true | false |
|
|
Setting: php.format.rules.endWithNewLine
Insert final newline: Inserts final newline at the end of a file.
Setting: php.format.rules.finallyOnNewLine
finally
on a new line:
Place finally
on a new line.
true | false |
|
|
Setting: php.format.rules.openBraceOnNewLineForAnonymousClasses
Open brace on a new line for anonymous classes:
Place open brace {
on a new line for anonymous classes.
true | false |
|
|
Setting: php.format.rules.openBraceOnNewLineForBlocks
Open brace on a new line for blocks:
Place open brace {
on a new line for all types of code blocks, except for those controlled by other formatting rules.
true | false |
|
|
Setting: php.format.rules.openBraceOnNewLineForFunctions
Open brace on a new line for functions:
Place open brace {
on a new line for methods, functions and constructors.
true | false |
|
|
Setting: php.format.rules.openBraceOnNewLineForLambdas
Open brace on a new line for lambda functions:
Place open brace {
on a new line for lambda functions.
true | false |
|
|
Setting: php.format.rules.openBraceOnNewLineForNamespaces
Open brace on a new line for namespaces:
Place open brace {
on a new line for namespace declarations.
true | false |
|
|
Setting: php.format.rules.openBraceOnNewLineForTypes
Open brace on a new line for types:
Place open brace {
on a new line for types.
true | false |
|
|
Wrapping
Setting: php.format.rules.alignConsecutiveAssignments
Align consecutive = assignments.:
Automatically align consecutive =
assignments.
true | false |
|
|
Setting: php.format.rules.alignConstants
Align constants: Automatically align constant declarations
true | false |
|
|
Setting: php.format.rules.alignEnumCases
Align enum cases: Automatically align assigned values in backed enumerations
true | false |
|
|
Setting: php.format.rules.alignMatchArmBodies
Align match
arm bodies:
Automatically align the bodies (results) within match
expression arms
true | false |
|
|
Setting: php.format.rules.arrayInitializersAlignKeyValuePairs
Align key-value pairs:
Automatically align =>
operators.
true | false |
|
|
Setting: php.format.rules.arrayInitializersNewLineAfterLastElement
New line after last element: Place a new line after the last element when wrapping.
true | false |
|
|
Setting: php.format.rules.arrayInitializersNewLineBeforeFirstElement
New line before first element: Place a new line before the first array element when wrapping.
true | false |
|
|
Setting: php.format.rules.arrayInitializersWrap
Wrap: Defines wrapping behavior for array initializers.
Off
- No wrapping is appliedOn every item
- When this option is selected each item is placed on a new line and properly indented if the array initializer is split across multiple lines.
Setting: php.format.rules.callParametersNewLineAfterLeftParen
New line after (
:
Place a new line after the left opening parenthesis (
when wrapping.
true | false |
|
|
Setting: php.format.rules.callParametersNewLineBeforeRightParen
New line before )
:
Place a new line before the right closing parenthesis )
when wrapping.
true | false |
|
|
Setting: php.format.rules.callParametersWrap
Wrap: Defines wrapping behavior for method, function and constructor call parameters.
Off
- No wrapping is appliedOn every item
- When this option is selected each item is placed on a new line and properly indented if the call arguments are split across multiple lines.
Setting: php.format.rules.chainedMethodCallsSemicolonOnNewLine
;
on a new line:
Place ;
on a new line after the last element in the chained method call when wrapping.
true | false |
|
|
Setting: php.format.rules.chainedMethodCallsWrap
Wrap: Defines wrapping behavior for chained method calls.
Off
- No wrapping is appliedAlways
- When this option is selected each method call is placed on a new line and properly indented.
Setting: php.format.rules.declCompactEmptyBody
Compact empty body into {}
:
Transform empty body into {}
and keep it at the same line as a previous symbol, separated by single space.
true | false |
|
|
Setting: php.format.rules.declKeepRightParenAndOpenBraceOnOneLine
Keep )
and {
on one line:
Keep the right closing parenthesis )
of a function or method declaration header on the one line as opening brace of the body {
.
true | false |
|
|
Setting: php.format.rules.declParametersNewLineAfterLeftParen
New line after (
:
Place a new line after the left opening parenthesis (
of function or method declaration header when wrapping.
true | false |
|
|
Setting: php.format.rules.declParametersNewLineBeforeRightParen
New line before )
:
Place a new line before the right closing parenthesis )
of a function or method declaration header when wrapping.
true | false |
|
|
Setting: php.format.rules.declParametersWrap
Wrap: Defines wrapping behavior for method or function declaration parameters.
Off
- No wrapping is appliedOn every item
- When this option is selected each declaration parameter is placed on a new line and properly indented if the arguments are split across multiple lines.
Setting: php.format.rules.forStatementNewLineAfterLeftParen
New line after (
:
Place a new line after the left opening parenthesis (
in a for
statement header if it's split across multiple lines.
true | false |
|
|
Setting: php.format.rules.forStatementNewLineBeforeRightParen
New line before )
:
Place a new line after the right closing parenthesis )
in a for
statement header if it's split across multiple lines.
true | false |
|
|
Setting: php.format.rules.forStatementWrap
Wrap:
Defines wrapping behavior for for
statement.
Off
- No wrapping is appliedOn every item
- When this option is selected each item infor
statement is placed on a new line and properly indented if they are split across multiple lines.
Setting: php.format.rules.groupUseNewLineBeforeFirstDeclaration
New line before first group use
declaration:
Place a new line before first group use
declaration if the list of declarations is split across multiple lines.
true | false |
|
|
Setting: php.format.rules.groupUseWrap
Wrap:
Defines wrapping behavior for group use
list in type declarations.
Off
- No wrapping is appliedOn every item
- When this option is selected each declaration in groupuse
list is placed on a new line and properly indented if they are split across multiple lines.
Setting: php.format.rules.ifStatementNewLineAfterLeftParen
New line after (
:
Place a new line after the left opening parenthesis (
in a if
or elseif
statement header if it's split across multiple lines.
true | false |
|
|
Setting: php.format.rules.ifStatementNewLineBeforeRightParen
New line before )
:
Place a new line after the right closing parenthesis )
in a if
or elseif
statement header if it's split across multiple lines.
true | false |
|
|
Setting: php.format.rules.implementsListWrap
Wrap:
Defines wrapping behavior for implements
list in type declarations.
Off
- No wrapping is appliedOn every item
- When this option is selected each interface inimplements
list is placed on a new line and properly indented if they are split across multiple lines.
Setting: php.format.rules.keepClassesOnOneLine
Keep classes on one line: Clasess are kept on one line.
true | false |
|
|
Setting: php.format.rules.keepControlStatementsOnOneLine
Keep control statements on one line: Control statements are kept on one line.
true | false |
|
|
Setting: php.format.rules.keepFunctionsOnOneLine
Keep functions on one line: Functions and methods are kept on one line.
true | false |
|
|
Setting: php.format.rules.newLineAfterImplements
New line after implements
:
Place a new line after implements
in type declaration if the list of interfaces is split across multiple lines.
true | false |
|
|
Setting: php.format.rules.switchStatementNewLineAfterLeftParen
New line after (
:
Place a new line after the left opening parenthesis (
in a switch
statement header if it's split across multiple lines.
true | false |
|
|
Setting: php.format.rules.switchStatementNewLineBeforeRightParen
New line before )
:
Place a new line after the right closing parenthesis )
in a switch
statement header if it's split across multiple lines.
true | false |
|
|
Setting: php.format.rules.whileStatementNewLineAfterLeftParen
New line after (
:
Place a new line after the left opening parenthesis (
in a while
statement header if it's split across multiple lines.
true | false |
|
|
Setting: php.format.rules.whileStatementNewLineBeforeRightParen
New line before )
:
Place a new line after the right closing parenthesis )
in a while
statement header if it's split across multiple lines.
true | false |
|
|
Conversions
Setting: php.format.rules.addCommaAfterLastArrayElement
Add a comma after the last array element: Automatically adds a comma after the last array element if it's not on a single line.
Setting: php.format.rules.addCommaAfterLastCallParameter
Add a comma after the last function call parameters: Automatically adds a comma after the last function call parameter if it's not on a single line.
Setting: php.format.rules.addCommaAfterLastDeclParameter
Add a comma after the last function declaration parameters: Automatically adds a comma after the last function or method declaration parameter if it's not on a single line.
Setting: php.format.rules.booleanConstantCasing
Boolean constant casing:
Defines casing for true
and false
constants.
uppercase
- Changes the casing to upper caselowercase
- Changes the casing to lower casekeep
- Keeps the original casing
lowercase | uppercase |
|
|
Setting: php.format.rules.nullConstantCasing
Null constant casing:
Defines casing for null
constant.
uppercase
- Changes the casing to upper caselowercase
- Changes the casing to lower casekeep
- Keeps the original casing
lowercase | uppercase |
|
|
Setting: php.format.rules.removeReduntandClosingTag
Remove Redundant Closing Tag:
The closing ?>
tag should be omitted from files containing only PHP.
true | false |
|
|