
class_definition
¶Whitespace around the keywords of a class, trait or interfaces definition should be one space.
multi_line_extends_each_single_line
¶Whether definitions should be multiline.
Note
The previous name of this option was multiLineExtendsEachSingleLine
but it is now deprecated and will be removed on next major version.
Allowed types: bool
Default value: false
single_item_single_line
¶Whether definitions should be single line when including a single item.
Note
The previous name of this option was singleItemSingleLine
but it is now deprecated and will be removed on next major version.
Allowed types: bool
Default value: false
single_line
¶Whether definitions should be single line.
Note
The previous name of this option was singleLine
but it is now deprecated and will be removed on next major version.
Allowed types: bool
Default value: false
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
{
}
Default configuration.
--- Original
+++ New
<?php
-$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
{}
The rule is part of the following rule sets:
Using the @PSR12 rule set will enable the class_definition
rule with the default config.
Using the @PSR2 rule set will enable the class_definition
rule with the default config.
Using the @PhpCsFixer rule set will enable the class_definition
rule with the config below:
['single_line' => true]
Using the @Symfony rule set will enable the class_definition
rule with the config below:
['single_line' => true]