Skip to content

Instantly share code, notes, and snippets.

Created December 5, 2014 20:06
What would you like to do?
PSR2 with tabs instead of spaces
<?xml version="1.0"?>
<ruleset name="MyStandard">
<description>PSR2 with tabs instead of spaces.</description>
<arg name="tab-width" value="4"/>
<rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
Copy link

Now all that is missing for a sane and consistent code style would be the curly brackets on the same line ( ). Any idea how to do that?

Yes. I did this in my fork. There is the explanation:

For functions you should

  • exclude Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine
  • include Generic.Functions.OpeningFunctionBraceKernighanRitchie

For classes you should

  • exclude PSR2.Classes.ClassDeclaration.OpenBraceNewLine
  • include Generic.Classes.OpeningBraceSameLine

Copy link

I’m having trouble with these rules and the following lines:


getting an error

 358 | ERROR | [x] Line indented incorrectly; expected 3 tabs, found
         |       |     4
         |       |     (Generic.WhiteSpace.ScopeIndent.IncorrectExact)

Looks like the lack of brackets in the conditional doesn’t increment the expected indentation level. Is that a bug?

Copy link

Richard Hendricks would be proud :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment