-
Notifications
You must be signed in to change notification settings - Fork 6
How to install and setup PHP_CodeSniffer
Tom de Wit edited this page Dec 11, 2020
·
2 revisions
https://github.com/squizlabs/PHP_CodeSniffer
composer require squizlabs/php_codesniffer --dev
./vendor/bin/phpcs app --basepath=. --report=json > phpcs.json
We run PHP_CodeSniffer from the project root and set the base path to .
. We output the result to a JSON-file called phpcs.json
. Setting the --basepath
option helps with improved filenames and their readability.
PHP_CodeSniffer:
stage: Code quality
allow_failure: true
script:
- ./vendor/bin/phpcs app --basepath=. --report=json > phpcs.json
artifacts:
paths:
- phpcs.json
when: always
Earlier in the configuration file you've defined the "Code quality" stage. Since quality assurance tools can fail we allow this job to fail to signal there are PHP_CodeSniffer errors. We then run the aforementioned script and save the output. Since GitLab, by default, doesn't store it's artifacts on failure, we overrule it's setting by always uploading phpcs.json
.