description and source-codegulp-phpcs = function (options) {
var command = buildCommand(options || {});
return through.obj(function(file, enc, callback) {
var stream = this;
if (file.isNull()) {
stream.push(file);
callback();
return;
}
if (file.isStream()) {
stream.emit('error', new gutil.PluginError('gulp-phpcs', 'Streams are not supported'));
callback();
return;
}
runCodeSniffer(command.bin, command.args, file, function(runError, exitCode, output) {
if (runError) {
// Something is totally wrong. It seems that execution of Code Sniffer
// failed (not because of non-zero exit code of PHPCS).
stream.emit('error', new gutil.PluginError('gulp-phpcs', runError));
callback();
return;
}
if (exitCode > 1) {
// On codding style problems Code Sniffer should exists with "1" code.
// All other non-zero exit codes should be treated as Code Sniffer errors.
var phpcsError = new gutil.PluginError('gulp-phpcs', 'Execution of Code Sniffer Failed');
phpcsError.stdout = output;
stream.emit('error', phpcsError);
callback();
return;
}
var report = {
error: false,
output: ''
};
if (exitCode === 1) {
// A codding style problem is found. Attache report to the file to allow
// reporters do their job.
report.error = true;
report.output = output;
}
file.phpcsReport = report;
stream.push(file);
callback();
});
});
}