Curly braces must be placed as configured.
the position of the opening brace of control structures body.
Allowed values: 'next_line_unless_newline_at_signature_end'
, 'same_line'
Default value: 'same_line'
the position of the opening brace of functions body.
Allowed values: 'next_line_unless_newline_at_signature_end'
, 'same_line'
Default value: 'next_line_unless_newline_at_signature_end'
the position of the opening brace of anonymous functions body.
Allowed values: 'next_line_unless_newline_at_signature_end'
, 'same_line'
Default value: 'same_line'
the position of the opening brace of classes body.
Allowed values: 'next_line_unless_newline_at_signature_end'
, 'same_line'
Default value: 'next_line_unless_newline_at_signature_end'
the position of the opening brace of anonymous classes body.
Allowed values: 'next_line_unless_newline_at_signature_end'
, 'same_line'
Default value: 'same_line'
allow anonymous classes to have opening and closing braces on the same line.
Allowed types: bool
Default value: true
allow anonymous functions to have opening and closing braces on the same line.
Allowed types: bool
Default value: true
Default configuration.
--- Original
+++ New
<?php
-class Foo {
+class Foo
+{
}
-function foo() {
+function foo()
+{
}
-$foo = function()
-{
+$foo = function() {
};
-if (foo())
-{
+if (foo()) {
bar();
}
Default configuration.
--- Original
+++ New
<?php
-$foo = new class
-{
+$foo = new class {
};
With configuration: ['control_structures_opening_brace' => 'next_line_unless_newline_at_signature_end']
.
--- Original
+++ New
<?php
-if (foo()) {
+if (foo())
+{
bar();
}
With configuration: ['functions_opening_brace' => 'same_line']
.
--- Original
+++ New
<?php
-function foo()
-{
+function foo() {
}
With configuration: ['anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end']
.
--- Original
+++ New
<?php
-$foo = function () {
+$foo = function ()
+{
};
With configuration: ['classes_opening_brace' => 'same_line']
.
--- Original
+++ New
<?php
-class Foo
-{
+class Foo {
}
With configuration: ['anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end']
.
--- Original
+++ New
<?php
-$foo = new class {
+$foo = new class
+{
};
With configuration: ['allow_single_line_empty_anonymous_classes' => true]
.
--- Original
+++ New
<?php
$foo = new class { };
-$bar = new class { private $baz; };
+$bar = new class {
+private $baz;
+};
With configuration: ['allow_single_line_anonymous_functions' => true]
.
--- Original
+++ New
<?php
$foo = function () { return true; };
-$bar = function () { $result = true;
- return $result; };
+$bar = function () {
+$result = true;
+ return $result;
+};