mikestreety
mikestreety

Reputation: 841

PHP Code Sniffer - rule updates and tweaking for spaces and underscores

Before I start, I really don't want this to turn into a "change your coding style" post, but rather how I can use PHP Code Sniffer to "lint" our current coding standards. Thanks :)

There are two rules which, due to legacy and personal coding styles, we would wish to invert. Rather than just exclude, we want to ensure that the opposite is true.

We are currently using a config file, where the rules will go.

No space after control

We like to ensure that there is no space between the control signature and the bracket.

E.g.

if(condition)

Instead of

if (condition)

The current rule which flags this is Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword.

Is there any way I can enforce the other way?

Snake case class names

We write our class names in snake_case not camelCase. This rule currently flags it up: Squiz.Classes.ValidClassName.NotCamelCaps

Again, any way we can alter this?

Struggling with the documentation.

Many thanks for your help

Upvotes: 1

Views: 1096

Answers (1)

shudder
shudder

Reputation: 2101

You might need to create custom sniff for that - check Annotated-ruleset.xml for external sniffs setting, and take a look at Sniff interface and some defined sniffs for clues.

Upvotes: 0

Related Questions