Reputation: 39
I am currently working on a standard formatting configuration for my PHP project. I want to use the PSR-12 rules, but I prefer to disable the rule that forces the opening curly brace to be on the same line as the statement.
For example:
if (true) { // Wrong
}
if (true)
{ // Correct
}
I would like to apply this to all types of statements, including classes, functions, if, else, and others. How can I achieve this?
This is my phpcs.xml now:
<?xml version="1.0"?>
<ruleset name="Standard">
<rule ref="PSR12" />
<rule ref="Generic.Formatting.MultipleStatementAlignment" />
<rule ref="Generic.Formatting.SpaceAfterCast" />
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
<exclude-pattern>vendor/*</exclude-pattern>
</ruleset>
Upvotes: 2
Views: 22
Reputation:
Use Squiz.ControlStructures.ControlStructureSpacing
:
phpcs.xml:
<?xml version="1.0"?>
<ruleset name="Standard">
<rule ref="PSR12" />
<!-- Disable the rule that forces opening curly braces to be on the same line -->
<rule ref="Squiz.ControlStructures.ControlStructureSpacing">
<exclude name="Squiz.ControlStructures.ControlStructureSpacing"/>
</rule>
<rule ref="Generic.Formatting.MultipleStatementAlignment" />
<rule ref="Generic.Formatting.SpaceAfterCast" />
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
<exclude-pattern>vendor/*</exclude-pattern>
</ruleset>
Upvotes: 0