node package manager

grunt-php-cs-fixer

grunt-php-cs-fixer

Grunt plugin for running PHP Coding Standards Fixer.

Installation

  1. Install grunt-php-cs-fixer
npm install grunt-php-cs-fixer --save-dev
  1. Install PHP Coding Standards Fixer

  2. Include the task in your Gruntfile with a line like this

grunt.loadNpmTasks('grunt-php-cs-fixer');

Usage Example

To be included in your Grunt initConfig.

phpcsfixer: {
    app: {
        dir: 'app' // or ['src/models', 'src/lib'] 
    },
    options: {
        bin: 'vendor/bin/php-cs-fixer',
        usingCache: "no",
        quiet: true
    }
}

This task is a multi task so any targets, files and options should be specified accordingly.

Target Properties

dir

Type: String || Array

The file(s) or directory(s) to fix.

Options

bin

Type: String Default: 'php-cs-fixer'

The path to php-cs-fixer.
(For composer, use vendor/bin/php-cs-fixer).

configfile

Type: String Default: null

Path to php-cs-fixer config file.

verbose

Type: Boolean Default: false

Output full info including warnings and a list of changes.

quiet

Type: Boolean Default: false

Output minimal info.

diff

Type: Boolean Default: false

Show a diff for the proposed changes.

dryRun

Type: Boolean Default: false

Don't effect the proposed changes (useful when combined with --diff).

allowRisky

Type: Boolean Default: false

Allows you to set whether risky rules may run.

usingCache

Type: Boolean Default: no

Controls whether a local cache is used, accepted values are "yes" or "no".

rules

Type: String Default: (all PSR rules)

Comma-separated string, or array of rules to use.
@see https://github.com/FriendsOfPHP/PHP-CS-Fixer.