-
Notifications
You must be signed in to change notification settings - Fork 5
PHP CodeSniffer
Harmen Janssen edited this page Jul 5, 2016
·
4 revisions
We try to have a consistent codebase, and SquizLabs' CodeSniffer helps.
- Make sure you have the CodeSniffer installed, by running
composer require squizlabs/php_codesniffer --dev
- Make sure you have this pre-commit hook installed, and very important, that it's executable:
chmod +x .git/hooks/pre-commit
- Make sure Garp3 is at least version
3.9.11
That's it!
It's a good idea to create a .git_template
directory to include the hook. That way git init
will setup all your repos to automatically include the hook. See also this Stack Overflow question.
You can add the following to .travis.yml
:
before_script:
- chmod -R +x vendor/bin/phpcs
script:
- if [ "$(git diff --name-only HEAD^..HEAD -- '*.php')" != "" ]; then ./vendor/bin/phpcs --standard=vendor/grrr-amsterdam/garp3/phpcs.xml --colors --encoding=utf-8 -n -p $(git diff --name-only HEAD^..HEAD -- '*.php'); fi
to test the files in your last commit.