greenrabbit lint config
PHP-Lint is simplified linter solution for php, based on PHP_CodeSniffer.
Currently it's support only as HG hook, GIT hook will come soon.
Installation is realized by Composer.
In the console write:
composer require --dev grnrbt/php-lint "*"
or add following line in
require-dev section of
Checks only staged files in repository so it can be added in present repositories without problems with old files.
Add following code into
.hg/hgrc file or HG-client settings:
[hooks] pretxncommit.hglint = vendor/bin/lint
or on Windows:
[hooks] pretxncommit.hglint = vendor\bin\lint.bat
To skip checking run commit from console with ENV param
NO_VERIFY=1 hg ci -u <user> -m <message>
You can run linter with ruleset manually from console
It will check staged files or run CodeSniffer itself
$ ./vendor/bin/phpcs --extensions=php --standard=/vendor/grnrbt/php-lint/ruleset.xml <dir>
For checking choosen directory
If you're using PhpStorm you can configure it to use CodeSniffer using Settings → Languages & Frameworks → PHP → Code Sniffer.
You can override standard rules by placing file
ruleset.xml in root directory of your project. In that file you can
include original file and add your own rules or disable rules, that was added in common ruleset.
<?xml version="1.0"?> <ruleset name="Custom Standard"> <description>A custom coding standard</description> <exclude-pattern>*/tests/*</exclude-pattern> <rule ref="/vendor/grnrbt/php-lint/ruleset.xml"/> <!-- custom rules, overrides --> </ruleset>