Giter VIP home page Giter VIP logo

gulp-phpcs's Introduction

gulp-phpcs NPM version

Gulp plugin for running PHP Code Sniffer.

Install

  1. Install the plugin with the following command:

    npm install gulp-phpcs --save-dev
  2. Install PHP Code Sniffer

Usage

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'));
});

API

phpcs(options)

options.bin

Type: String

Default: 'phpcs'

PHP Code Sniffer executable.

options.severity

Type: Integer

The minimum severity required to display an error or warning.

This option is equivalent to Code Sniffer --severity=<severity> option.

options.warningSeverity

Type: Integer

The minimum severity required to display an error or warning.

This option is equivalent to Code Sniffer --warning-severity=<severity> option.

options.errorSeverity

Type: Integer

The minimum severity required to display an error or warning.

This option is equivalent to Code Sniffer --error-severity=<severity> option.

options.standard

Type: String

The name or path of the coding standard to use.

This option is equivalent to Code Sniffer --standard="<standard>" option.

phpcs.reporter(name)

Loads one of the reporters that shipped with the plugin (see below).

name

Type: String

The name of the reporter that should be loaded.

Reporters

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:

  1. Fail reporter - fails if a problem was found. Use phpcs.reporter('fail') to load it.

  2. Log reporter - outputs all problems to the console. Use phpcs.reporter('log') to load it.

License

MIT © Dmitriy Simushev

gulp-phpcs's People

Contributors

justblackbird avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.