A coding standard to check against the Symfony coding standards, originally shamelessly copied from the -disappeared- opensky/Symfony2-coding-standard repository.
This standard can be installed with the Composer dependency manager.
-
Install the coding standard as a dependency of your project
composer require --dev anujithsingh/symfony2-coding-standard:1.0.0
-
Check the installed coding standards for "Symfony"
phpcs -i
-
Done!
bin/phpcs --standard=Symfony2 /path/to/code
-
Install PHP_CodeSniffer
-
Checkout this repository
git clone git://github.com/anujith-singh/Symfony2-coding-standard.git
-
Move rules to squizlabs/PHP_CodeSniffer's Standards directory
cp -R path/to/anujithsingh/symfony2-coding-standard/ vendor/squizlabs/php_codesniffer/src/Standards/Symfony2
-
Check the installed coding standards for "Symfony"
phpcs -i
-
Done!
phpcs --standard=Symfony2 /path/to/code
If you do contribute code to these sniffs, please make sure it conforms to the PEAR coding standard and that the Symfony2-coding-standard unit tests still pass.
To check the coding standard, run from the Symfony2-coding-standard source root:
$ phpcs --ignore=*/tests/* --standard=PEAR . -n
The unit-tests are run from within the PHP_CodeSniffer directory:
$ phpunit --filter Symfony2_* tests/AllTests.php