Skip to content
 
 

Repository files navigation

Doctrine PHP_CodeSniffer Coding Standard

Build Status Coverage Status

The PHP_CodeSniffer Coding Standard to check against the Doctrine Coding Standard.

Installation

You have three possibilities to use the Doctrine Coding Standard with PHP_CodeSniffer in a particular project.

1. Standalone installation

You can install the Doctrine Coding Standard as a plugin into your global system PHP_CodeSniffer installation:

$ cd /path/to/phpcs/CodeSniffer/Standards
$ git clone https://github.com/doctrine/coding-standard.git Doctrine

Then you can use it like (assuming that you have the phpcs binary in your search path):

$ phpcs --standard=Doctrine /path/to/some/file/to/sniff.php

Or even set it as default standard (assuming that you have the phpcs binary in your search path):

$ phpcs --config-set default_standard Doctrine

And just sniff a particular file with (assuming that you have the phpcs binary in your search path):

$ phpcs /path/to/some/file/to/sniff.php

2. Custom installation

You can install the Doctrine Coding Standard anywhere you want:

$ cd /path/to/whatever/directory/you/want
$ git clone https://github.com/doctrine/coding-standard.git Doctrine

Then you can use it like (assuming that you have the phpcs binary in your search path):

$ phpcs --standard=/path/to/whatever/directory/you/want/Doctrine /path/to/some/file/to/sniff.php

3. As a composer dependency of your project

You can install the Doctrine Coding Standard as a composer dependency to your particular project. Just add the following block to your project's composer.json file:

{
    "require": {
        "doctrine/coding-standard": "dev-master"
    }
}

Then you can use it like:

$ ./vendor/bin/phpcs --standard=vendor/doctrine/coding-standard/Doctrine /path/to/some/file/to/sniff.php

Testing

If you are contributing to the Doctrine Coding Standard and want to test your contribution, you have to make sure all dependencies are correctly installed:

$ php composer.phar install --prefer-source --dev

The option --prefer-source is particularly necessary to ensure the test suite from PHP_CodeSniffer is installed. Otherwise the test suite for the Doctrine Coding Standard won't work!

Run the test suite with:

$ ./vendor/bin/phpunit

About

The coding standard of the Doctrine project.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors