Whitespace around the keywords of a class, trait, enum or interfaces definition should be one space.
Whether definitions should be multiline.
Allowed types: bool
Default value: false
Whether definitions should be single line when including a single item.
Allowed types: bool
Default value: false
Whether definitions should be single line.
Allowed types: bool
Default value: false
Whether there should be a single space after the parenthesis of anonymous class (PSR12) or not.
Allowed types: bool
Default value: false
Whether constructor argument list in anonymous classes should be single line.
Allowed types: bool
Default value: true
Default configuration.
--- Original
+++ New
<?php
-class Foo extends Bar implements Baz, BarBaz
+class Foo extends Bar implements Baz, BarBaz
{
}
-final class Foo extends Bar implements Baz, BarBaz
+final class Foo extends Bar implements Baz, BarBaz
{
}
-trait Foo
+trait Foo
{
}
-$foo = new class extends Bar implements Baz, BarBaz {};
+$foo = new class extends Bar implements Baz, BarBaz {};
With configuration: ['single_line' => true]
.
--- Original
+++ New
<?php
-class Foo
-extends Bar
-implements Baz, BarBaz
+class Foo extends Bar implements Baz, BarBaz
{}
With configuration: ['single_item_single_line' => true]
.
--- Original
+++ New
<?php
-class Foo
-extends Bar
-implements Baz
+class Foo extends Bar implements Baz
{}
With configuration: ['multi_line_extends_each_single_line' => true]
.
--- Original
+++ New
<?php
interface Bar extends
- Bar, BarBaz, FooBarBaz
+ Bar,
+ BarBaz,
+ FooBarBaz
{}
With configuration: ['space_before_parenthesis' => true]
.
--- Original
+++ New
<?php
-$foo = new class(){};
+$foo = new class () {};
With configuration: ['inline_constructor_arguments' => true]
.
--- Original
+++ New
<?php
-$foo = new class(
- $bar,
- $baz
-) {};
+$foo = new class($bar, $baz) {};
The rule is part of the following rule sets:
- @PER
Using the @PER rule set will enable the
class_definition
rule with the config below:['inline_constructor_arguments' => false, 'space_before_parenthesis' => true]
- @PSR12
Using the @PSR12 rule set will enable the
class_definition
rule with the config below:['inline_constructor_arguments' => false, 'space_before_parenthesis' => true]
- @PSR2
- Using the @PSR2 rule set will enable the
class_definition
rule with the default config. - @PhpCsFixer
Using the @PhpCsFixer rule set will enable the
class_definition
rule with the config below:['single_line' => true]
- @Symfony
Using the @Symfony rule set will enable the
class_definition
rule with the config below:['single_line' => true]