Gulp plugin for running PHP Code Sniffer.
-
Install the plugin with the following command:
npm install gulp-phpcs --save-dev
var gulp = require('gulp');
var phpcs = require('gulp-phpcs');
gulp.task('default', function () {
return gulp.src(['src/**/*.php', '!src/vendor/**/*.*'])
// Validate files using PHP Code Sniffer
.pipe(phpcs({
bin: 'src/vendor/bin/phpcs',
standard: 'PSR2',
warningSeverity: 0
}))
// Log all problems that was found
.pipe(phpcs.reporter('log'));
});
Type: String
Default: 'phpcs'
PHP Code Sniffer executable.
Type: Integer
The minimum severity required to display an error or warning.
This option is equivalent to Code Sniffer --severity=<severity>
option.
Type: Integer
The minimum severity required to display an error or warning.
This option is equivalent to Code Sniffer --warning-severity=<severity>
option.
Type: Integer
The minimum severity required to display an error or warning.
This option is equivalent to Code Sniffer --error-severity=<severity>
option.
Type: String
The name or path of the coding standard to use.
This option is equivalent to Code Sniffer --standard="<standard>"
option.
Type: String
The encoding of the files being checked.
This option is equivalent to Code Sniffer --encoding="<encoding>"
option.
Loads one of the reporters that shipped with the plugin (see below).
Type: String
The name of the reporter that should be loaded.
The plugin only pass files through PHP Code Sniffer. To process the results of the check one should use a reporter. Reporters are plugins too, so one can pipe a files stream to them. Several repotrers can be used on a stream, just like any other plugins.
These reporters are shipped with the plugin:
-
Fail reporter - fails if a problem was found. Use
phpcs.reporter('fail')
to load it. -
Log reporter - outputs all problems to the console. Use
phpcs.reporter('log')
to load it.
MIT © Dmitriy Simushev