# Code Style. PHP

> **TL;DR**
> `File | Settings | Editor | Code Style | PHP` for Windows and Linux
>
>
>
> `IntelliJ IDEA | Settings | Editor | Code Style | PHP` for macOS
>
>
>
> `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) ![the Settings icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.settings.svg)
>
>
>
> Required plugin: [PHP](https://plugins.jetbrains.com/plugin/6610-php) (IntelliJ IDEA Ultimate)

Use this page to configure formatting  options for PHP files. When you change these settings, the Preview pane shows how this will affect your code.

## Set from...

Click this link and choose the language to be used as the base for the current language code style. The list contains two options:

* Language: choose this option to inherit the coding style settings from another language. Select the source language from the list, that opens. Only the settings that are applicable to the current language are taken. All the other settings are not affected.

* Predefined code style: choose this option to use the coding standards defined for a specific framework. Select one of the following frameworks from the list: * [PEAR](https://pear.php.net/manual/en/standards.php) * [Zend](https://framework.zend.com/manual/1.11/en/coding-standard.coding-style.html) * [Symfony2](https://symfony.com/doc/current/contributing/code/standards.html). IntelliJ IDEA supports the official Symfony2 code style for [Twig](https://twig.symfony.com/doc/2.x/coding_standards.html) and automatically inserts one space after an opening pair of curvy braces and before a closing pair of curvy braces in Twig templates: `{{ some_variable }}`. * [PSR1](https://www.php-fig.org/psr/psr-1/) / [PSR-2](https://www.php-fig.org/psr/psr-2/) * [CodeIgniter](https://codeigniter.com/userguide2/general/styleguide.html) * [Laravel](https://laravel.com/docs/5.7/contributions#coding-style) * [PER-CS 2.0.0](https://github.com/php-fig/per-coding-style/blob/2.0.0/spec.md) * [PER-CS 3.0.0](https://www.php-fig.org/per/coding-style/) * [PSR-12](https://www.php-fig.org/psr/psr-12/). If the PSR-12 code style is set, IntelliJ IDEA will prompt you to automatically enable the [PSR-12-related code inspections](null). * [Drupal](https://drupal.org/coding-standards) * [Joomla!](https://www.joomla.org/) * [WordPress](https://make.wordpress.org/core/handbook/coding-standards/php/)

This link appears in the upper-right corner of the language-specific code style page, when applicable.

Click Reset to discard changes and return to the initial set of code style settings.

## Tabs and Indents

| Item | Description |
| --- | --- |
|  Use tab character |    Use the `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `Tab` (NetBeans), `Tab` (Visual Studio), `⇥` (Visual Studio (macOS)), `Tab` (Eclipse), `⇥` (Eclipse (macOS)) key for indentation. When the checkbox is cleared, IntelliJ IDEA uses spaces instead of tabs.      |
|  Smart tabs  |      * If this checkbox is selected, the indentation for nested code blocks will use tabs and spaces as needed, while alignment indentation will use only spaces. ![Code style with Smart Tabs on](https://resources.jetbrains.com.cn/help/img/idea/2026.2/php_code_style_smart_tabs_on.png)    * If this checkbox is cleared, only tabs are used. This means that a group of spaces that fits the specified tab size is automatically replaced with a tab, which may result in breaking fine alignment. ![Code style with Smart Tabs off](https://resources.jetbrains.com.cn/help/img/idea/2026.2/php_code_style_smart_tabs_off.png)     The Smart tabs checkbox is available if the Use tab character option is enabled.      |
|  Tab size  | In this field, specify the number of spaces included in a tab.  |
|  Indent  | In this field, specify the number of spaces to be inserted for each indent level.   |
|  Continuation indent  |      Specify the indentation for lines that continue from the previous line, making it clear that they are part of the same statement or block of code. Continuation indents are used when a single statement is too long to fit on one line.      |
|  Keep indents on empty lines  | If this checkbox is selected, IntelliJ IDEA will keep indents on the empty lines as if they contained some code.     If this checkbox is cleared, IntelliJ IDEA will delete the tab characters and spaces.     |
|  Indent code in PHP tags  | Select this checkbox to have the code enclosed in `<?php>` tags indented against the opening `<?php` tag. |

## Spaces

Select or clear the checkboxes to have spaces inserted, not inserted, or removed in various PHP contexts.

### Before parentheses

| Item | Description |
| --- | --- |
|                           Function declaration parentheses  |     If selected, a space is inserted before the opening parenthesis in function declarations. Otherwise, no space is inserted.      Selected:  ```PHP function foo ($x, $z) {} ```   Not selected:  ```PHP function foo($x, $z) {} ```     |
|  Function call parentheses  |     If selected, a space is inserted before the opening parenthesis in function calls. Otherwise, no space is inserted.      Selected:  ```PHP $obj->foo ()->bar (); ```   Not selected:  ```PHP $obj->foo()->bar(); ```     |
|  Anonymous function parentheses  |     If selected, a space is inserted before the opening parenthesis in anonymous function declarations. Otherwise, no space is inserted.      Selected:  ```PHP $example = function () {}; ```   Not selected:  ```PHP $example = function() {}; ```     |
|  'if' parentheses  |     If selected, a space is inserted before the opening parenthesis in `if` constructs. Otherwise, no space is inserted.      Selected:  ```PHP if ($x) {     echo $x; } ```   Not selected:  ```PHP if($x) {     echo $x; } ```     |
|  'for' parentheses  |     If selected, a space is inserted before the opening parenthesis in `for` loops. Otherwise, no space is inserted.      Selected:  ```PHP for ($i = 0; $i < $x; $i++) {     $y += $i; } ```   Not selected:  ```PHP for($i = 0; $i < $x; $i++) {     $y += $i; } ```     |
|  'while' parentheses  |     If selected, a space is inserted before the opening parenthesis in `while` loops. Otherwise, no space is inserted.      Selected:  ```PHP while ($x != $y) {     echo ($x * 2); } ```   Not selected:  ```PHP while($x != $y) {     echo ($x * 2); } ```     |
|  'switch' parentheses  |     If selected, a space is inserted before the opening parenthesis in `switch` statements. Otherwise, no space is inserted.      Selected:  ```PHP switch ($i) {     case 0:         echo "i equals 0";         break;     case 1:         echo "i equals 1";         break; } ```   Not selected:  ```PHP switch($i) {     case 0:         echo "i equals 0";         break;     case 1:         echo "i equals 1";         break; } ```     |
|  'catch' parentheses  |     If selected, a space is inserted before the opening parenthesis in `catch` constructs. Otherwise, no space is inserted.      Selected:  ```PHP try {     get($x); } catch (Exception $e) { } ```   Not selected:  ```PHP try {     get($x); } catch(Exception $e) { } ```     |
|  Array initializer parentheses  |     If selected, a space is inserted before the opening parenthesis in array declarations. Otherwise, no space is inserted.      Selected:  ```PHP $array = array (0 => "zero", 1 => "one"); ```   Not selected:  ```PHP $array = array(0 => "zero", 1 => "one"); ```     |
|  Arrow function parentheses  |     If selected, a space is inserted before the opening parenthesis in anonymous function declarations. Otherwise, no space is inserted.      Selected:  ```PHP $double = fn ($x) => $x * 2; ```   Not selected:  ```PHP $double = fn($x) => $x * 2; ```     |

### Around operators

| Item | Description |
| --- | --- |
|  Assignment operators (=, +=, ...)  |    If selected, spaces are inserted around assignment operators in assignment expressions. Otherwise, no spaces are inserted.      Selected:  ```PHP $var = f($a); ```   Not selected:  ```PHP $var=f($a); ```     |
|  Logical operators (&&, \|\|)  |     If selected, spaces are inserted around logical operators in logical expressions. Otherwise, no spaces are inserted.      Selected:  ```PHP $var = $a && $b; ```   Not selected:  ```PHP $var = $a&&$b; ```     |
|  Equality operators (==, !=)  |     If selected, spaces are inserted around equality operators in comparison expressions. Otherwise, no spaces are inserted.      Selected:  ```PHP if ($a == $b) {}; ```   Not selected:  ```PHP if ($a==$b) {}; ```     |
|  Relational operators (<, >, <=, >=)  |     If selected, spaces are inserted around relational operators in comparison expressions. Otherwise, no spaces are inserted.      Selected:  ```PHP if ($a > $b) {}; ```   Not selected:  ```PHP if ($a>$b) {}; ```     |
|  Bitwise operators (&, \|, ^)  |     If selected, spaces are inserted around bitwise operators. Otherwise, no spaces are inserted.      Selected:  ```PHP $var += ($var ^ 0x123); ```   Not selected:  ```PHP $var += ($var^0x123); ```     |
|  Additive operators (+, -)  |     If selected, spaces are inserted around additive operators. Otherwise, no spaces are inserted.      Selected:  ```PHP $var = $a + $b; ```   Not selected:  ```PHP $var = $a+$b; ```     |
|  Multiplicative operators (*, /, %, **)  |     If selected, spaces are inserted around multiplicative operators. Otherwise, no spaces are inserted.      Selected:  ```PHP $var = $a * $b; ```   Not selected:  ```PHP $var = $a*$b; ```     |
|  Shift operators (<<, >>, >>>)  |     If selected, spaces are inserted around bit shifting operators. Otherwise, no spaces are inserted.      Selected:  ```PHP $var = $a << 1; ```   Not selected:  ```PHP $var = $a<<1; ```     |
|  Unary additive operators (+,-,++,--)  |     If selected, spaces are inserted around unary additive operators. Otherwise, no spaces are inserted.      Selected:  ```PHP for ($i = 0; $i < $x; $i ++) {} ```   Not selected:  ```PHP for ($i = 0; $i < $x; $i++) {} ```     |
|  Concatenation (.)  |     If selected, spaces are inserted around the `.` concatenation operator. Otherwise, no spaces are inserted.      Selected:  ```PHP echo "The result is " . $i; ```   Not selected:  ```PHP echo "The result is ".$i; ```     |
|  Object access operator (->)  |     If selected, spaces are inserted around the `->` object access operator. Otherwise, no spaces are inserted.      Selected:  ```PHP $obj -> foo() -> bar(); ```   Not selected:  ```PHP $obj->foo()->bar(); ```     |
|  Null coalescing operator (??)  |     If selected, spaces are inserted around the `??` null coalescing operator. Otherwise, no spaces are inserted.      Selected:  ```PHP foo() ?? bar(); ```   Not selected:  ```PHP foo()??bar(); ```     |
|  Assignment in declare statement  |     If selected, spaces are inserted around the assignment operator in the `declare` statement. Otherwise, no spaces are inserted.      Selected:  ```PHP declare(strict_types = 1); ```   Not selected:  ```PHP declare(strict_types=1); ```     |

### Before left brace

| Item | Description |
| --- | --- |
|  Class left brace  |     If selected, a space is inserted between the class name and the opening brace in class declarations. Otherwise, no space is inserted.      Selected:  ```PHP class Class1 {     function Foo() {} } ```   Not selected:  ```PHP class Class1{     function Foo() {} } ```                         Selecting or clearing the checkbox is relevant only when Braces placement for In class declaration is set to End of line on the Wrapping and Braces tab.     |
|      Method left brace     |       If selected, a space is inserted between the method parameters' list closing parenthesis and the opening brace in method declarations. Otherwise, no space is inserted.      Selected:  ```PHP function foo() {} ```   Not selected:  ```PHP function foo(){} ```        Selecting or clearing the checkbox is relevant only when Braces placement for  In method declaration is set to End of line on the Wrapping and Braces tab.     |
|  'if' left brace  |     If selected, a space is inserted between the conditional expression's closing parenthesis and the opening brace in `if` statements. Otherwise, no space is inserted.      Selected:  ```PHP if ($x) {     echo $x; } ```   Not selected:  ```PHP if ($x){     echo $x; } ```                         Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |
|  'else' left brace  |     If selected, a space is inserted between the `else` keyword and the opening brace in `if-else` statements. Otherwise, no space is inserted.      Selected:  ```PHP if ($x) {     echo $x; } else {     echo $y; } ```   Not selected:  ```PHP if ($x) {     echo $x; } else{     echo $y; } ```                         Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |
|  'for' left brace  |     If selected, a space is inserted between the conditional expression's closing parenthesis and the opening brace in `for` loops. Otherwise, no space is inserted.      Selected:  ```PHP for ($i = 0; $i < $y; $i++) {     $str = $arr[$i]; } ```   Not selected:  ```PHP for ($i = 0; $i < $y; $i++){     $str = $arr[$i]; } ```                         Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |
|  'while' left brace  |     If selected, a space is inserted between the conditional expression's closing parenthesis and the opening brace in `while` loops. Otherwise, no space is inserted.      Selected:  ```PHP while ($var != $x) {     $var++; } ```   Not selected:  ```PHP while ($var != $x){     $var++; } ```                         Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |
|  'do' left brace  |     If selected, a space is inserted between the `do` keyword and the opening brace in `do-while` loops. Otherwise, no space is inserted.      Selected:  ```PHP do {     echo $var; } while ($var > 0); ```   Not selected:  ```PHP do{     echo $var; } while ($var > 0); ```                         Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |
|  'switch' left brace  |     If selected, a space is inserted between the conditional expression's closing parenthesis and the opening brace in `switch` statements. Otherwise, no space is inserted.      Selected:  ```PHP switch ($i) {     case 0:         $var = 'zero';         break;     default:         $var = 'other'; } ```   Not selected:  ```PHP switch ($i){     case 0:         $var = 'zero';         break; default:         $var = 'other'; } ```                         Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |
|  'try' left brace  |     If selected, a space is inserted between the `try` keyword and the opening brace in `try` blocks. Otherwise, no space is inserted.      Selected:  ```PHP try {     get($x); } catch (Exception $e) { } ```   Not selected:  ```PHP try{     get($x); } catch (Exception $e) { } ```                         Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |
|  'catch' left brace  |     If selected, a space is inserted between the `catch` statement argument list and the opening brace in `catch` blocks. Otherwise, no space is inserted.      Selected:  ```PHP try {     get($x); } catch (Exception $e) { } ```   Not selected:  ```PHP try{     get($x); } catch (Exception $e){ } ```                         Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |
|  'finally' left brace  |     If selected, a space is inserted between the `finally` keyword and the opening brace in `finally` blocks. Otherwise, no space is inserted.      Selected:  ```PHP try {     get($x); } catch (Exception $e) { } finally { } ```   Not selected:  ```PHP try {     get($x); } catch (Exception $e) { } finally{ } ```        Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.     |

### Before keywords

| Item | Description |
| --- | --- |
|  'else' keyword  |     If selected, a space is inserted between the closing brace of an `if` block and an `else`/`elseif` keyword. Otherwise, no space is inserted.      Selected:  ```PHP if ($x) {     echo $x; } else {     echo $y; } ```   Not selected:  ```PHP if ($x) {     echo $x; }else {     echo $y; } ```                               |
|  'while' keyword  |     If selected, a space is inserted between the closing brace of a `do` block and the `while` keyword in `do-while` loops. Otherwise, no space is inserted.      Selected:  ```PHP do {     echo $var; } while ($var > 0); ```   Not selected:  ```PHP do {     echo $var; }while ($var > 0); ```                               |
|  'catch' keyword  |     If selected, a space is inserted between the closing brace of a `try` block and the `catch` keyword. Otherwise, no space is inserted.      Selected:  ```PHP try {     get($x); } catch (Exception $e) { } ```   Not selected:  ```PHP try{     get($x); }catch (Exception $e) { } ```                               |
|  'finally' keyword  |     If selected, a space is inserted between the closing brace of a `catch` block and the `finally` keyword. Otherwise, no space is inserted.      Selected:  ```PHP try {     get($x); } catch (Exception $e) { } finally { } ```   Not selected:  ```PHP try {     get($x); } catch (Exception $e) { }finally { } ```                               |

### Within

| Item | Description |
| --- | --- |
|  Brackets  |     If selected, spaces within brackets are always inserted. Otherwise, spaces are never inserted.     |
|  Brackets around variable/expression  |     If selected, IntelliJ IDEA inserts spaces inside brackets during reformatting only if the brackets enclose a variable or an expression. This setting affects reformatting only if you have not configured force insertion of spaces inside brackets by selecting the Brackets checkbox under the Within node in the Spaces tab.       This option helps you keep your code in accordance with the [WordPress PHP Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/).       If the checkbox is cleared, the spaces insertion policy depends on the Brackets setting regardless of the type of content inside brackets.     |
|  Array initializer parentheses  |     If selected, spaces inside parentheses in array initializer expressions are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP $array = array( 0 => "zero", 1 => "one" ); ```   Not selected:  ```PHP $array = array(0 => "zero", 1 => "one"); ```     |
|  Grouping parentheses  |     If selected, spaces inside grouping parentheses in complex expressions are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP $var += ( $var ^ 0x123 ) << 2; ```   Not selected:  ```PHP $var += ($var ^ 0x123) << 2; ```     |
|  Function declaration parentheses  |     If selected, spaces inside parentheses in function declarations are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP function foo( $x, $z ) {} ```   Not selected:  ```PHP function foo($x, $z) {} ```     |
|  Function call parentheses  |     If selected, spaces inside parentheses in function calls are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP foo( $x, $z ); ```   Not selected:  ```PHP foo($x, $z) {}; ```     |
|  'if' parentheses  |     If selected, spaces inside parentheses in `if` statements are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP if ( $x ) {     echo $x; } ```   Not selected:  ```PHP if ($x) {     echo $x; } ```     |
|  'for' parentheses  |     If selected, spaces inside parentheses in `for` loops are always inserted. Otherwise, no spaces are inserted.      Before:  ```PHP for ( $i = 0; $i < $x; $i++ ) {     $y += $i; } ```   After:  ```PHP for ($i = 0; $i < $x; $i++) {     $y += $i; } ```     |
|  'while' parentheses  |     If selected, spaces inside parentheses in `while` loops are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP while ( $x != $y ) {     echo ($x * 2); } ```   Not selected:  ```PHP while ($x != $y) {     echo ($x * 2); } ```     |
|  'switch' parentheses  |     If selected, spaces inside parentheses in `switch` statements are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP switch ( $i ) {     default:         echo "i equals 0";         break; } ```   Not selected:  ```PHP switch($i) {     default:         echo "i equals 0";         break; } ```     |
|  'catch' parentheses  |     If selected, spaces inside parentheses in `catch` constructs are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP try {     get($x); } catch ( Exception $e ) { } ```   Not selected:  ```PHP try {     get($x); } catch (Exception $e) { } ```     |
|  <?= and ?>  |     If selected, spaces inside the opening and closing PHP tags (<?= and ?>) are always inserted. Otherwise, no spaces are inserted.      Selected:  ```PHP <div><?= echo foo(); ?></div> ```   Not selected:  ```PHP <div><?=echo foo();?></div> ```     |

### In ternary operator (?:)

| Item | Description |
| --- | --- |
|      Before '?'         After '?'         Before ':'         After ':'         Between '?' and ':'      |     Select the checkboxes in this section to have spaces automatically inserted around `?`, around `:`, and between `?` and `:` in [ternary                             (conditional) operators](https://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary) .       For example, if  Before '?'  and  After ':'  are selected, IntelliJ IDEA automatically inserts spaces before `?` and after `:` in ternary conditional expressions. Otherwise, no spaces are inserted.      Selected:  ```PHP $var = $x > 0 ?1: 2; ```   Not selected:  ```PHP $var = $x > 0?1:2; ```                               |

### Other

| Item | Description |
| --- | --- |
|  Before comma / After comma  |     If selected, spaces are automatically inserted before/after commas in parameter lists, argument lists, array declarations, and so on. Otherwise, no spaces are inserted.      Selected:  ```PHP function foo ($x , $z) {} ```   Not selected:  ```PHP function foo ($x,$z) {} ```     |
|  Before 'for' semicolon / After 'for' semicolon  |     If selected, spaces are automatically inserted before/after semicolons in `for` loops. Otherwise, no spaces are inserted.      Selected:  ```PHP for($i = 0 ; $i < $x ; $i++) {     $y += $i; } ```   Not selected:  ```PHP for($i = 0;$i < $x;$i++) {     $y += $i; } ```     |
|  After type cast  |     If selected, a space is automatically inserted after the closing parenthesis of a [cast](https://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting). Otherwise, no space is inserted and the casted variable sticks to the cast.      Selected:  ```PHP $fst = (string) $foo; ```   Not selected:  ```PHP $fst = (string)$foo; ```     |
|  Before colon in return type / After colon in return type  |     If selected, spaces are automatically inserted before/after colons in function return type declarations. Otherwise, no spaces are inserted.      Selected:  ```PHP function foo() : int {} ```   Not selected:  ```PHP function foo():int {} ```     |
|  Around \| in union type  |     If selected, spaces are automatically inserted around the pipe symbol `\|` in [union types'](https://wiki.php.net/rfc/union_types_v2) declarations. Otherwise, no spaces are inserted.      Selected:  ```PHP function returnNumber (     int \| float $number)     : int \| float {} ```   Not selected:  ```PHP function returnNumber (     int\|float $number)     : int\|float {} ```     |
|  Before colon in named argument / After colon in named argument  |     If selected, spaces are automatically inserted before/after colons in named arguments. Otherwise, no spaces are inserted.      Selected:  ```PHP foo(start : $a, end : $b); ```   Not selected:  ```PHP foo(start:$a, end:$b); ```     |
|  Before colon next to type declaration in backed enum / After colon next to type declaration in backed enum  |     If selected, spaces are automatically inserted before/after colons in [backed enums'](https://wiki.php.net/rfc/enumerations#backed_enums) type declarations. Otherwise, no spaces are inserted.      Selected:  ```PHP enum Suit : string {     case Hearts = 'H';     case Diamonds = 'D';     case Clubs = 'C';     case Spades = 'S'; } ```   Not selected:  ```PHP enum Suit:string {     case Hearts = 'H';     case Diamonds = 'D';     case Clubs = 'C';     case Spades = 'S'; } ```     |
|  Before unary Not (!) / After unary Not (!)  |     If selected, spaces are automatically inserted before/after unary Not `!` operators. Otherwise, no spaces are inserted.      Selected:  ```PHP if ( ! 0 > $x &&  ! $x < 10) {} ```   Not selected:  ```PHP if (!0 > $x && !$x < 10) {} ```     |

## Wrapping and Braces

### Common options

| Item | Description |
| --- | --- |
|  Hard wrap at  |  Use this  field to specify a margin space required on the right side of an element. If you select the Default option, then a value of the right margin from the [global settings](settings-code-style.html#rightMargin) is used.   |
|  Wrap on typing  |    Use these settings to specify how the edited text is fitted in the specified Hard wrap at:         * Default: in this case IntelliJ IDEA uses the Wrap on typing option that is specified in the [global settings](settings-code-style.html#wrapOnTyping).    * Yes : in this case IntelliJ IDEA uses the value specified in the Right Margin field.    * No : in this case this option is switched off and a line can exceed the value specified in the right margin.     |
|  Visual guides  |  Use this field to specify multiple right margins. You can leave a default value or enter the number of spaces for your margin. If you want to specify several margins, enter numbers separated by comma.  |

### Keep when reformatting

Use these settings to configure exceptions that IntelliJ IDEA will make when reformatting the source code.

| Item | Description |
| --- | --- |
|  Line breaks  |     If selected, line breaks will be kept after [reformatting](reformat-and-rearrange-code.html) the code. Otherwise, the lines that are shorter than a standard convention will be merged into one line.     |
|  Comment at first column  |     If selected, comments placed at the first column won't change their position after [reformatting](reformat-and-rearrange-code.html) the code. Otherwise, such comments will align with the next line of code.     |
|  Control statement in one line  |     If selected, control statements will be placed in line after [reformatting](reformat-and-rearrange-code.html) the code. Otherwise, they will be placed on multiple lines.      Selected:  ```PHP if (true) $x = 10; elseif ($y < 10) $x = 5; else if (true) $x = 5; ```   Not selected:  ```PHP if (true)     $x = 10; elseif ($y < 10)     $x = 5; else if (true)     $x = 5; ```     |
|  Simple methods in one line  |     If selected, simple methods will be kept in line after [reformatting](reformat-and-rearrange-code.html) the code. Otherwise, they will expand into multiple lines.      Selected:  ```PHP class Foo() {     public function bar() { } } ```   Not selected:  ```PHP class Foo() {     public function bar() {     } } ```     |
|  Simple classes in one line  |     If selected, simple classes will be kept in line after [reformatting](reformat-and-rearrange-code.html) the code. Otherwise, they will expand into multiple lines.      Selected:  ```PHP class Foo() { } ```   Not selected:  ```PHP class Foo() { } ```     |

### Braces placement

In this section, choose the position for opening braces in declarations of namespaces, classes, and functions, in loops, and in other constructs.

| Option | Description |
| --- | --- |
|  End of line  |  If selected, the opening brace is placed at the declaration line end.  |
|  Next line if wrapped  |  If selected, the opening brace is placed at the beginning of the line after the multiline declaration line.  |
|  Next line  |  If selected, the opening brace is placed at the beginning of the line after the declaration line.  |
|  Next line shifted  |  If selected, the opening brace is placed at the line after the declaration line being shifted to the corresponding indent level.  |
|  Next line, each shifted  |  If selected, the opening brace is placed at the line after the declaration line being shifted to the corresponding indent level, and have the next line shifted to the next indent level as well.  |

To configure the position of braces in empty classes or functions/methods, use the Place braces for empty classes on one line and Place braces for empty functions/methods on one line checkboxes.

### Extends/implements list

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  Align when multiline  |     If selected, each item in an `extends` or an `implements` list, which after wrapping starts on a new line, is aligned by the first item, which remains unwrapped.        When the checkbox is cleared, the position of each item in a wrapped list is determined by the chosen indentation level.       The status of the checkbox affects the formatting only if you have chosen to wrap lists, if the Do not wrap option is chosen, selecting or clearing the checkbox has no effect.       Selected:  ```PHP class Foo extends Class1 implements Class2,                   Class3,                   Class4 { } ```   Not selected:  ```PHP class Foo extends Class1 implements Class2, Class3, Class4 { } ```     |

### Extends/implements keyword

In this section, configure wrapping for the `extends` and `implements` keywords in class declarations.

If you select Do not wrap, no wrapping will be applied; if you select Wrap if long or Wrap always, each keyword and each item in an `extends` or `implements` list will be displayed on a new line.

Wrapped:

```PHP
abstract class Foo
    extends
    Class1
    implements
    Class2,
    Class3 {
}
```

Not wrapped:

```PHP
abstract class Foo extends Class1
    implements Class2, Class3 {
}
```

### Function declaration parameters

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  Align when multiline  |  If selected, each parameter in the parameter list which after wrapping starts on a new line, is aligned by the first parameter, which remains unwrapped.     When the checkbox is cleared, the position of each item in a wrapped list is determined by the chosen indentation level.       The status of the checkbox affects the formatting only if you have chosen to wrap lists, if the Do not wrap option is chosen, selecting or clearing the checkbox has no effect.       Selected:  ```PHP function bar($x,              $y,              int $z = 1) {} ```   Not selected:  ```PHP function bar($x,     $y,     int $z = 1) {} ```     |
|  New line after '('  |     If selected, parameters in function/method declarations are displayed on a new line after the opening parenthesis. Otherwise, they are displayed on the same line.        When the checkbox is cleared, the position of each item in a wrapped list is determined by the chosen indentation level.       The status of the checkbox affects the formatting only if you have chosen to wrap lists, if the Do not wrap option is chosen, selecting or clearing the checkbox has no effect.       Selected:  ```PHP function bar( $x, $y, int) {} ```   Not selected:  ```PHP function bar($x, $y, $z) {} ```     |
|  Place ')' on new line  |    If selected, the closing parenthesis in a function/method declaration is placed on a new line. Otherwise, it is displayed on the same line with the last parameter.      Selected:  ```PHP function bar(     $x,     $y,     int ) {} ```   Not selected:  ```PHP function bar(     $x,     $y,     int) {} ```     |
|  Keep ')' and '{' on one line  |     If selected, the opening curly brace is displayed on the same line as the function parameters. Otherwise, the opening curly brace is moved to the next line.      Selected:  ```PHP function Foo() { } ```   Not selected:  ```PHP function Foo() { } ```     |

### Function/constructor call arguments

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  Align when multiline  |     If selected, each argument in a function call which after wrapping starts on a new line, is aligned by the first argument, which remains unwrapped.        When the checkbox is cleared, the position of each item in a wrapped list is determined by the chosen indentation level.       The status of the checkbox affects the formatting only if you have chosen to wrap lists, if the Do not wrap option is chosen, selecting or clearing the checkbox has no effect.       Selected:  ```PHP $result = foo("arg1",               "arg2", true); ```   Not selected:  ```PHP $result = foo("arg1",     "arg2", true); ```     |
|  New line after '('  |     If selected, arguments in function calls are displayed on a new line after the opening parenthesis. Otherwise, they are displayed on the same line.      Selected:  ```PHP $result = foo("arg1", "arg2", true); ```   Not selected:  ```PHP $result = foo(     "arg1", "arg2", true); ```     |
|  Place ')' on new line  |     If selected, the closing parenthesis in a function call is placed on a new line. Otherwise, it is displayed on the same line with the last argument.      Selected:  ```PHP $result = foo("arg1",     "arg2",     true ); ```   Not selected:  ```PHP $result = foo("arg1", "arg2", true); ```     |
|  Place '()' for constructor  |     Choose whether IntelliJ IDEA should automatically add braces in construct statements without parameters during reformatting the code.        * As is: existing braces are preserved and no new ones are added.    * Always: braces are always added.    * Never: braces are always removed.     With braces:  ```PHP $var = new ExampleClass(); ```   Without braces:  ```PHP $var = new ExampleClass; ```     |
|  Align named arguments  |     If selected, named arguments in a function call are aligned against the rightmost one. Otherwise, they are aligned according to the indentation settings.      Selected:  ```PHP foo(     start : $a,       end : $b ); ```   Not selected:  ```PHP foo(     start : $a,     end : $b ); ```     |

### Chained method calls

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  Align when multiline  |     If selected, each called method, which after wrapping is positioned on a new line, is aligned by the first one, which remains unwrapped.        When the checkbox is cleared, the position of each item in a wrapped list is determined by the chosen indentation level.       The status of the checkbox affects the formatting only if you have chosen to wrap lists, if the Do not wrap option is chosen, selecting or clearing the checkbox has no effect.       Selected:  ```PHP $x = $x->one( "a", "b" )        ->two( "c", "d", "e" )        ->three( "fg" )        ->four(); ```   Not selected:  ```PHP $x = $x->one( "a", "b" )     ->two( "c", "d", "e" )     ->three( "fg" )     ->four(); ```     |
|  Place ';' on new line  |     If selected, the semicolon `;` is moved to a new line after the last item in a chained call. Otherwise, it is displayed on the same line.      Selected:  ```PHP $x = $x->one( "a", "b" )        ->two( "c", "d", "e" )        ->three( "fg" )        ->four() ; ```   Not selected:  ```PHP $x = $x->one( "a", "b" )        ->two( "c", "d", "e" )        ->three( "fg" )        ->four(); ```     |

### 'if()' statement

| Item | Description |
| --- | --- |
|  New line before first element  |     If selected, conditional expressions are moved to the next line after the opening parenthesis in `if` statements. Otherwise, they stay on the same line.      Selected:  ```PHP if (     $var == "one") { } ```   Not selected:  ```PHP if ($var == "one") { } ```     |
|  New line after last element  |     If selected, closing braces of conditional expressions in `if` statements are moved to the next line. Otherwise, they stay on the same line.      Selected:  ```PHP if ($var == "one"     ) { } ```   Not selected:  ```PHP if ($var == "one") { } ```     |
|  Force braces  |     Choose the braces introduction method for `if` statements:         * Do not force : select this option to suppress introducing braces automatically.    * When multiline : select this option to have braces introduced automatically if a statement occupies more than one line. Note that IntelliJ IDEA analyzes the number of lines in the entire statement but not only its condition. IntelliJ IDEA will insert braces automatically:    * Always : select this checkbox to have braces always introduced automatically.     |
|  'else' on new line  |    If selected, the `else` keyword is moved to a new line in `if-else` statements. Otherwise, it stays on the same line with a preceding statement.      Selected:  ```PHP if ($var == "one") { } else $var = true; ```   Not selected:  ```PHP if ($var == "one") { } else $var = true; ```     |
|  Special 'else if' treatment  |     If selected, `else if` constructs are treated specially and not split during reformatting. Otherwise, they are split into a nested `else-if` structure.       The status of the checkbox affects formatting only if you have chosen to force braces in `if` statements. If the Do not force option is selected, the Special 'else if' treatment checkbox has no effect.      Selected:  ```PHP if (true) $x = 10;     else if ($y < 10) $x = 5; else $x = 0; ```   Not selected:  ```PHP if (true) {     $x = 10; } else {     if ($y < 10) {         $x = 5;     } else $x = 0; ```     |

### for()/foreach() statements

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  Align when multiline  |     When the checkbox is selected and the New line before first element checkbox is cleared, each item in a `for` / `foreach` loop expression, which after wrapping starts on a new line, is aligned by the first item, which remains unwrapped.      Selected:  ```PHP for ($i = 0;      $i < $x;      $i++) {     $y += $i; } ```   Not selected:  ```PHP for ($i = 0;     $i < $x;     $i++) {     $y += $i; } ```     |
|  New line after '('  |    If selected, expressions in `for` / `foreach` loops are displayed on the next line after the opening parenthesis. Otherwise, they are displayed on the same line.      Selected:  ```PHP for (     $i = 0; $i < $a; $i++) {     $y += $i; } ```   Not selected:  ```PHP for ($i = 0; $i < $a; $i++) {     $y += $i; } ```     |
|  Place ')' on new line  |     If selected, closing braces in `for` / `foreach` loops are displayed on the next line after the expression. Otherwise, they are displayed on the same line.      Selected:  ```PHP for (     $i = 0; $i < $a; $i++ ) {     $y += $i; } ```   Not selected:  ```PHP for ($i = 0; $i < $a; $i++) {     $y += $i; } ```     |
|  Force braces  |     Choose the braces introduction method for `for` / `foreach` loops:         * Do not force : select this option to suppress introducing braces automatically.    * When multiline : select this option to have braces introduced automatically if a statement occupies more than one line. Note that IntelliJ IDEA analyzes the number of lines in the entire statement but not only its condition. IntelliJ IDEA will insert braces automatically:    * Always : select this checkbox to have braces always introduced automatically.     |

### 'while()' statement

| Item | Description |
| --- | --- |
|  Force braces  |     Choose the braces introduction method for `while` loops:         * Do not force : select this option to suppress introducing braces automatically.    * When multiline : select this option to have braces introduced automatically if a statement occupies more than one line. Note that IntelliJ IDEA analyzes the number of lines in the entire statement but not only its condition. IntelliJ IDEA will insert braces automatically:    * Always : select this checkbox to have braces always introduced automatically.     |

### 'do ... while()' statement

| Item | Description |
| --- | --- |
|  Force braces  |     Choose the braces introduction method for `do-while` loops:         * Do not force : select this option to suppress introducing braces automatically.    * When multiline : select this option to have braces introduced automatically if a statement occupies more than one line. Note that IntelliJ IDEA analyzes the number of lines in the entire statement but not only its condition. IntelliJ IDEA will insert braces automatically:    * Always : select this checkbox to have braces always introduced automatically.     |
|  'while' on new line  |     If selected, the `while` keyword is moved to the next line after a `do` block in `do-while` loops. Otherwise, it stays on the same line.      Selected:  ```PHP do {     echo $var; } while ($var > 0); ```   Not selected:  ```PHP do{     echo $var; } while ($var > 0); ```     |

### 'switch' statement

| Item | Description |
| --- | --- |
|  Indent 'case' branches  |     If selected, `case` statements are indented relative to the `switch` statement. Otherwise, they are placed at the same indent level.      Selected:  ```PHP switch ($i) {     case 0:         echo "i equals 0";         break;     case 1:         echo "i equals 1";         break; } ```   Not selected:  ```PHP switch ($i) { case 0:     echo "i equals 0";     break; case 1:     echo "i equals 1";     break; } ```     |
|  Indent 'break' from 'case'  |     If selected, `break` statements are indented relative to `case` statements. Otherwise, they are placed at the same indent level.      Selected:  ```PHP switch ($i) {     case 0:         echo "i equals 0";         break;     case 1:         echo "i equals 1";         break; } ```   Not selected:  ```PHP switch ($i) {     case 0:         echo "i equals 0";     break;     case 1:         echo "i equals 1";     break; } ```     |

### 'try' statement

| Item | Description |
| --- | --- |
|  'catch' on new line  |     If selected, `catch` statements are placed on the next line after the closing brace of a `try` block. Otherwise, they are placed on the same line.      Selected:  ```PHP try {     get($x); } catch (Exception $e) { } ```   Not selected:  ```PHP try {     get($x); } catch (Exception $e) { } ```     |
|  'finally' on new line  |     If selected, `finally` statements are placed on the next line after the closing brace of a `catch` block. Otherwise, they are placed on the same line.      Selected:  ```PHP try {     get($x); } catch (Exception $e) { } finally { } ```   Not selected:  ```PHP try {     get($x); } catch (Exception $e) { } finally { } ```     |

### Binary expressions

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  Align when multiline  |     If selected, each operand in a binary operation, which after wrapping starts on a new line, is aligned by the first item, which remains unwrapped. Otherwise, operands are indented according to the indentation settings.      Selected:  ```PHP function foo($a, $b, $c) {     return $a +            $b +            $c; } ```   Not selected:  ```PHP function foo($a, $b, $c) {     return $a +        $b +        $c; } ```     |
|  Operation sign on next line  |     If selected, operators in binary operations are moved to the next line together with the wrapped right operand. Otherwise, operators stay on the previous line together with the left operand.      Selected:  ```PHP function foo($a, $b, $c) {     return $a            + $b            + $c; } ```   Not selected:  ```PHP function foo($a, $b, $c) {     return $a +            $b +            $c; } ```     |
|  New line after '('  |     If selected, a new line is added after the opening parenthesis and the binary expression is moved to this line. Otherwise, an expression stays on the same line with the opening parenthesis.      Selected:  ```PHP $a = $b + (     $c + $d); ```   Not selected:  ```PHP $a = $b + ($c + $d); ```     |
|  Place ')' on new line  |     If selected, a closing parenthesis is moved to a new line after the binary expression. Otherwise, the parenthesis stays on the same line with the expression.      Selected:  ```PHP $a = $b + ($c + $d ); ```   Not selected:  ```PHP $a = $b + ($c + $d); ```     |

### Assignment statement

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  Assignment sign on next line  |     If selected, assignment signs in assignment statements are moved to the next line together with the wrapped right operand. Otherwise, operators stay on the previous line together with the left operand.      Selected:  ```PHP var $numbers     = array("one", "two", "three"); ```   Not selected:  ```PHP var $numbers =     array("one", "two", "three"); ```     |
|  Align consecutive assignments   |     If selected, the assignment signs in consecutive assignment statements are aligned by the rightmost one. Otherwise, no alignment is applied.      Selected:  ```PHP $y            = foo( $x ); $i = foo( $i ); $result       = $result . $y . $i; ```   Not selected:  ```PHP $y = foo( $x ); $i = foo( $i ); $result = $result . $y . $i; ```     |

### Class property/constant groups

| Item | Description |
| --- | --- |
|  Align properties in columns  |     If selected, class properties' declarations are aligned by the rightmost one. Otherwise, no alignment is applied.      Selected:  ```PHP class Foo {     public    $a;     protected $b;     private   $c } ```   Not selected:  ```PHP class Foo {     public $a;     protected $b;     private $c } ```     |
|  Align constants  |     If selected, grouped constants' declarations are aligned by the rightmost one. Otherwise, no alignment is applied.      Selected:  ```PHP class Foo {     const ONE   = 1;     const TWO   = 2;     const THREE = 3; } ```   Not selected:  ```PHP class Foo {     const ONE = 1;     const TWO = 2;     const THREE = 3; } ```     |
|  Align enum cases  |     If selected, assigned values in backed enumerations are aligned by the rightmost one. Otherwise, no alignment is applied.      Selected:  ```PHP enum Suit: string { case Clubs = '♣'; case Diamonds = '♦'; case Hearts = '♥'; case Spades = '♠'; } ```   Not selected:  ```PHP enum Suit: string { case Clubs    = '♣'; case Diamonds = '♦'; case Hearts   = '♥'; case Spades   = '♠'; } ```     |

### Ternary operation

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  '?' and ':' signs on next line  |     If selected, the `?` and `:` symbols are moved to the next line together with the wrapped right operand. Otherwise, they stay on the previous line together with the left operand.      Selected:  ```PHP echo ($result == 42)     ? "Passed"     : " Failed"; ```   Not selected:  ```PHP echo ($result == 42) ?     "Passed" :     " Failed"; ```     |

### Array initializer

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |
|  Align when multiline  |     If selected, each array element, which after wrapping is positioned on a new line, is aligned by the first one, which remains unwrapped. Otherwise, all the elements are aligned according to the indentation settings.      Selected:  ```PHP $arr = [0.1,         0.2,         0.3,         0.4 ]; ```   Not selected:  ```PHP $arr = [0.1,     0.2,     0.3,     0.4 ]; ```       Selecting or clearing the Align when multiline checkbox affects formatting only if you have chosen to wrap lists. If the Do not wrap option is chosen, the status of the checkboxes has no effect.     |
|  Align key-value pairs  |     If selected, all key-value array elements are aligned against the rightmost assignment operator `=>`. Otherwise, all the elements are aligned according to the indentation settings.      Selected:  ```PHP $arr = [0    => "value 1",         1234 => "value 2",         56   => "value 3" ]; ```   Not selected:  ```PHP $arr = [0 => "value 1",     1234 => "value 2",     56   => "value 3" ]; ```     |
|  New line before first element  |     If selected, the first element of the array is displayed on a new line and all the elements of the array are aligned according to the indentation settings, regardless of the status of the Align when multiline checkbox. Otherwise, the first element of the array remains on the same line, and the other elements are aligned according to the indentation settings.      Selected:  ```PHP $arr = [     "value 1",     "value 2",     "value 3" ]; ```   Not selected:  ```PHP $arr = ["value 1",         "value 2",         "value 3" ]; ```     |
|  New line after last element  |     If selected, the closing parenthesis is displayed on a separate line. Otherwise, it remains on the same line together with the last element of the array.      Selected:  ```PHP $arr = ["value 1",         "value 2",         "value 3" ]; ```   Not selected:  ```PHP $arr = ["value 1",         "value 2",         "value 3"]; ```     |

### Modifier list

| Item | Description |
| --- | --- |
|  Wrap after modifier list  |     If selected, the code is wrapped after a list of visibility modifiers. Otherwise, no wrapping is performed.      Selected:  ```PHP protected function Foo() { } ```   Not selected:  ```PHP protected function Foo() { } ```     |

### Function return type

| Item | Description |
| --- | --- |
|  Return type on new line  |     If selected, functions' return type declarations are placed on the next line. Otherwise, they stay on the same line.      Selected:  ```PHP function foo() : int { } ```   Not selected:  ```PHP function foo() : int { } ```     |

### Comments

| Item | Description |
| --- | --- |
|  Align inline comments  |     If selected, inline comments located on consecutive lines are aligned by the rightmost comment.      Selected:  ```PHP echo "one"; //one echo "two"; //two echo "three"; //three ```   Not selected:  ```PHP echo "one";   //one echo "two";   //two echo "three"; //three ```     |

### PHP opening tag

| Item | Description |
| --- | --- |
|  New line after '<?php' tag  |     If selected, the code is moved to the next line after the opening `<?php` tag. Otherwise, it stays on the same line.      Selected:  ```PHP <?php echo "Message"; ```   Not selected:  ```PHP <?php echo "Message"; ```     |

### 'match' expression

| Item | Description |
| --- | --- |
|  Align 'match' arm bodies  |     If selected, all expressions in `match` arms are aligned against the rightmost operator `=>`. Otherwise, the expressions are aligned according to the indentation settings.      Selected:  ```PHP match ($i) {     0       => 'zero',     42      => 'forty-two',     default => 'none' }; ```   Not selected:  ```PHP match ($i) {     0 => 'zero',     42 => 'forty-two',     default => 'none' }; ```     |

### Heredoc and nowdoc

| Item | Description |
| --- | --- |
|  Place on the same line as variable declaration  |     If selected, IntelliJ IDEA formats heredocs and nowdocs according to [PER Coding Style](https://www.php-fig.org/per/coding-style/#10-heredoc-and-nowdoc).       Heredocs and nowdocs are placed on the same line as the variable declarations they are being set against. Additionally, subsequent lines in the heredoc or nowdoc are indented four spaces past the scope indentation they are declared in.      Selected:  ```PHP $value = <<<EOD     Example of string     spanning multiple lines     using heredoc syntax.     EOD; ```   Not selected:  ```PHP $value = <<<EOD Example of string spanning multiple lines using heredoc syntax. EOD; ```     |

### Group 'use'

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.    |

### Attributes

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    |

### Attributes for parameters

| Item | Description |
| --- | --- |
|  Common wrapping options  |      * Do not wrap: when this option is selected, no special wrapping style is applied. With this option selected, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.    |

## Blank lines

Use this tab to define where and how many blank lines you want IntelliJ IDEA to retain and insert in your code after reformatting. For each type of location, specify the number of blank lines to be inserted. The results are displayed in the preview pane.

| Item | Description |
| --- | --- |
|   Keep maximum blank lines   | In this area, specify the number of blank lines to be kept after reformatting in the specified locations. |
|   Minimum blank lines   |    In this area, specify the number of blank lines to be present in the specified locations.      > **Warning:** > These settings do not influence the number of blank lines before the first and after the last item.    |

## PHPDoc

In this tab, configure the code style to be applied inside [PHPDoc](https://docs.phpdoc.org/3.0/guide/references/phpdoc/index.html#phpdoc-reference) comments. Learn more about documenting PHP code at [PHPDoc comments](https://www.jetbrains.com.cn/en-us/help/phpstorm/phpdoc-comments.html).

| Item | Description |
| --- | --- |
|  Keep blank lines  | Select this checkbox to suppress removing blank lines automatically. |
|  Blank line before the first tag  | Select this checkbox to have a blank line inserted above the first PHPDoc tag. |
|  Blank lines around parameters  | Select this checkbox to have a blank line inserted above and below the section with `@param` tags. |
|  Wrap long lines  | Select this checkbox to have the text that exceeds the right margin wrapped to the next line. |
|  Align parameter/property names  | Select this checkbox to have the `$<paramname>` elements aligned. |
|  Align tag comments  | Select this checkbox to have the `description` elements aligned. |
|  PHPDoc '@param' spaces  |     In this area, set the number of spaces for separating the `@param` tag elements.     |
|  Generated PHPDoc tags  |    In this area, configure the code style to be applied within generated PHP documentation blocks, refer to [PHPDoc comments](https://www.jetbrains.com.cn/en-us/help/phpstorm/phpdoc-comments.html).        * Use fully qualified class names: select this checkbox to have IntelliJ IDEA specify fully qualified class names for properties, function parameters, `return` and `throws` values, and so on.    * Place ‘null’ in types: select this checkbox to have product generate annotations for [nullable parameters and return types](https://wiki.php.net/rfc/nullable_types) and choose where the `null` indication should be placed (that is, `string\|null` or `null\|string`).    |
|  Sort PHPDoc tags  |     Select this checkbox to have the PHPDoc tags automatically sorted in the defined order when you [generate a PHPDoc block for a code                             construct](https://www.jetbrains.com.cn/en-us/help/phpstorm/phpdoc-comments.html#function).         * Use ![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) and ![the Remove button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg) to add or remove the PHPDoc tag entries from the list.    * Use ![the Up button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.general.arrowUp.svg) and ![the Down button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.general.arrowDown.svg) to arrange the PHPDoc tag entries order.     > **Note:** > The PHPDoc tags that are not added to the list are generated below the listed ones.     |

## Code Conversion

In this tab, configure the code style to be applied when performing automatic code conversion.

| Item | Description |
| --- | --- |
|  Convert True/False constants to  |     Select the desired option to have the `true` and `false` constants displayed either in the upper or the lower case.     |
|  Convert Null constant to  |     Select the desired option to have the `null` constants displayed either in the upper or the lower case.     |
|  Convert else if/elseif to  |     Select the desired option to have `else if` and `elseif` constants displayed uniformly as `else if` or `elseif`.     |
|  Sort 'use' statements  |     Select the desired option to have the `use` statements sorted either alphabetically or by length when you [optimize imports](creating-and-optimizing-imports.html#optimize-imports).     |
| Add a comma after last parameter in parameter list |    Select this checkbox to have a trailing comma inserted after the last parameter in parameter lists.      Select the When multiline option to comply with [PER Coding Style](https://www.php-fig.org/per/coding-style/#26-trailing-commas) and skip adding a trailing comma if the list is contained on a single line.      Allowed by the syntax in PHP 8.0 and later.    |
| Add a comma after last variable in closure use list |    Select this checkbox to have a trailing comma inserted after the last variable in closure `use` lists.      Select the When multiline option to comply with [PER Coding Style](https://www.php-fig.org/per/coding-style/#26-trailing-commas) and skip adding a trailing comma if the list is contained on a single line.      Allowed by the syntax in PHP 8.0 and later.    |
| Add a comma after last argument in function call |    Select this checkbox to have a trailing comma inserted after the last argument in function calls.      Select the When multiline option to comply with [PER Coding Style](https://www.php-fig.org/per/coding-style/#26-trailing-commas) and skip adding a trailing comma if the list is contained on a single line.     |
| Add a comma after last match arm | Select this checkbox to have a trailing comma inserted after the last arm in `match` expressions. |
|  Array/List Declaration Style  |      * Force short declaration style: select this checkbox to have IntelliJ IDEA replace the `array()` constructs with `[]` in array declarations during reformatting. When the checkbox is cleared, the traditional literal style in array declarations is preserved after reformatting.    * Add a comma after last element in multiline array: select this checkbox to have IntelliJ IDEA automatically insert a comma after the last item in declarations of multiline arrays to meet the required coding standard, for example, the [Symfony coding standards](https://symfony.com/doc/current/contributing/code/standards.html) .      For more information, refer to [Arrays. Syntax](https://php.net/manual/en/language.types.array.php#language.types.array.syntax.array-func).     |

## Code Generation

In this tab, configure the code style to be applied when performing certain [code generation](generating-code.html) and [refactoring](refactoring-source-code.html) procedures.

| Item | Description |
| --- | --- |
|  Variable Naming Style  |     Select the desired option to have the generated variables displayed uniformly in Mixed case, camelCase, or snake_case.     |
|  Properties Default Visibility  |     Select the desired option to automatically prefix the generated class properties with `private`, `protected`, or `public` [visibility modifiers](https://www.php.net/manual/en/language.oop5.visibility.php).       The selected option will correspondingly affect the behavior of the [Extract field](extract-field.html) refactoring, the [Change signature](change-signature.html) refactoring invoked on a class constructor, and the Initialize fields intention action.     |
|  Getters/Setters style  |     In this area, use the provided options to customize the [generated getters and setters](generating-code.html#generate-getters-setters):        * Getters/Setters order: Choose, which constructs have to come first – getters or setters.    * Naming style: Choose the naming scheme, that is `camelCase` or `snake_case`, for the generated getters or setters.    |
|  Comment Code  |    In this area, configure the code style options to be applied to comments.        * Line comment at first column: select this checkbox to have line comments start at the first column, without any indentation. Note that no extra blank spaces are added after the line comment characters. The checkbox is by default selected. When the checkbox is cleared, the line comments start from the minimum indentation within the selected code block to be commented.    * Add a space at line comment start: select this checkbox to have a space is inserted between a line comment character and the first character of a commented line.    |

## Arrangement

In this tab, define a set of rules to [rearrange your PHP code](reformat-and-rearrange-code.html) according to your preferences.

| Item | Description |
| --- | --- |
| Grouping Rules |    Use this area to set the grouping rules.        * Keep getters and setters together Select this checkbox to keep getter and setter methods together. By default, this checkbox is selected.    * Keep overridden methods together Select this checkbox to group the overridden methods together by class and interface. In order list, select keep order or order by name options.    * Keep dependent methods together Select this checkbox to group the dependent methods together. In the order list, select depth-first order or breadth-first order options. The former will arrange the methods according to the nesting hierarchy; the latter will group together the sibling methods from the same nesting level. Depth-first: ```PHP class foo { public function parent() { $this->child1(); $this->child2(); } private function child1() { $this->nested1(); } private function nested1() { $this->nested2(); } private function nested2() { } private function child2() { } } ``` Breadth-first: ```PHP class foo { public function parent() { $this->child1(); $this->child2(); } private function child1() { $this->nested1(); } private function child2() { } private function nested1() { $this->nested2(); } private function nested2() { } } ```    |
| Matching rules |    Use this area to define elements order as a list of rules, where every rule has a set of matches such as modifier or type.        * ![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg): use this button to add a rule. The empty rule area opens.    * ![the Add Section Rule button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.codeStyle.AddNewSectionRule.svg): use this button to add a section rule. The section rule lets you move methods or variables into sections that you have defined. For example, you can create the following section rule: ![A matching rule](https://resources.jetbrains.com.cn/help/img/idea/2026.2/matching_rule.png) After the arrangement, methods in the class will be rearranged as specified in the created section rule and will be surrounded by comments: ```PHP //methods start public function test() {} private function a() { return 1; } static function r() {} //methods end ```    * ![the Remove button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg): use this button to remove the rule from the list.    * ![the Edit button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.edit.svg): use this button to edit an existing rule. To see this button, navigate to the rule that you want to edit and click the button. In popup that opens, modify the rule fields.    * ![the Move up button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.moveUp.svg) ![the Move down button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.moveDown.svg): use these buttons to move the selected rule up or down.    |
| Empty rule |    Use this area to create a new matching rule or edit an existing one. You can select from the following filters:       * Type: use this filter to choose classes or methods for your rule. Note that clicking a type keyword twice negates the condition.    * Modifier: use this filter to select the types of modifiers for the rule. Note that clicking a modifier keyword twice negates the condition.    * Name: use this field to specify entry names in the rule. This filter matches only entry names, such as field names, method names, class names, and so on. The filter supports regular expressions and uses a [standard syntax](http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html). The match is performed against the entire name.    * Order: use this list to select the sorting order for the rule. This option is useful when more than one element uses the same matching rule. In this case, selecting Keep order will keep the same order as was set before the rearrangement and selecting Order by Name will sort the elements with the same matching rule by their names.    * Aliases: this option displays aliases that were defined in the Rules Alias Definition dialog. You can remove the ones you do not need.    |
| ![the Sort Alphabetically button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.objectBrowser.sorted.svg) | This icon appears when you select Order by Name from the Order list. The icon indicates that the items in this rule are sorted alphabetically. |

## See also

### Procedures

[PHP](php-specific-guidelines.html) [Code style schemes](configuring-code-style.html)

### Reference

[Code Style](settings-code-style.html)

