1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <?xml version="1.0"?> <ruleset name="EasyBib"> <description>EasyBib Coding Standard.</description> <exclude-pattern>*tests/*</exclude-pattern> <exclude-pattern>*data/*</exclude-pattern> <exclude-pattern>*var/*</exclude-pattern> <exclude-pattern>*bin/*</exclude-pattern> <exclude-pattern>*vendor/*</exclude-pattern> <exclude-pattern>*www/*</exclude-pattern> <exclude-pattern>*views/scripts/*</exclude-pattern> <exclude-pattern>*etc/*</exclude-pattern> <exclude-pattern>*examples/*</exclude-pattern> <exclude-pattern>*docs/*</exclude-pattern> <rule ref="PEAR"/> <rule ref="PSR1"/> <rule ref="PSR2"/> <rule ref="Generic.Commenting.Todo.CommentFound"> <message>Please review this TODO comment: %s</message> <severity>3</severity> </rule> <rule ref="Generic.NamingConventions.UpperCaseConstantName"/> <rule ref="Generic.NamingConventions.CamelCapsFunctionName"> <properties> <property name="strict" value="false"/> </properties> </rule> <rule ref="PEAR.NamingConventions.ValidFunctionName"> <exclude name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore"/> <exclude name="PEAR.NamingConventions.ValidFunctionName.FunctionUnderscore"/> </rule> <rule ref="PEAR.NamingConventions.ValidVariableName"> <exclude name="PEAR.NamingConventions.ValidVariableName.PrivateNoUnderscore"/> </rule> <rule ref="PSR2.Files.EndFileNewline"> <exclude name="PSR2.Files.EndFileNewline.NotFound"/> </rule> <rule ref="EasyBib.Methods.ConstructShouldNotReturn"/> </ruleset> |
pear install PHP_CodeSniffer
This is how:
phpcs \
--standard=/path/to/repo/EasyBib/ruleset.xml \
target-dir
.travis.yml
on various projects1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | { "type": "library", "license": "BSD", "repositories": [ { "type": "pear", "url": "http://pear.php.net" } ], "autoload": { "psr-0": { "EasyBib\\PHP\\CodeSniffer": "library", "PHP_CodeSniffer": "vendor/pear-pear.php.net/PHP_CodeSniffer" } }, "require-dev": { "pear-pear/php_codesniffer": "*" } } |
1 2 3 4 5 6 | <?php require './vendor/autoload.php'; $cs = new \EasyBib\PHP\CodeSniffer\CodingStandard; $cs->getIncludedSniffs(); |