I’ve asked a question here because all my Php code is indented by 2, not 4.
Php CodeSniffer, which is a really great tool, has an indentation of “4” and it seems you can’t change that value.
Php CodeSniffer has a lot of options. So this it should be easy to add “indentation width”. But it seems the creators have voluntary avoided the possibility, because it’s not possible (which is weird IMHO).
So if you can’t change this, I was wondering: is “indentation width = 4” a de-facto standard?
Is this the same for Java / JavaDoc generation ?
Do I have to change all my 10.000+ lines of code to a 4 – indendation width?
Any public member var in sniffs can be overwritten by using a ruleset.xml file. A ruleset.xml file is an XML representation of your own custom coding standard. It can import sniffs from any of the included standards and can also include your own custom sniffs if you choose to write them.
In your case, you want the exact PEAR standard, but with the indent value changed. So create a file
mystandard.xmland make this the contents:Now, instead of running PHP_CodeSniffer using the command
phpcs --standard=PEAR ...you usephpcs --standard=/path/to/mystandard.xml ...Note that you can call the standard anything you want and change the XML metadata (name and description) to something more appropriate.
There is a lot more you can do with a custom ruleset.xml file. You can find more information about custom rulesets here: http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php