-
Notifications
You must be signed in to change notification settings - Fork 0
Nether Notation Coding Standard for PHP_CodeSniffer
This repository contains a phpcs
standard for testing and automated reformatting of source to fit the standard. While most are most are, there are still some rules covered by this standard that have not yet been implemented for phpcs
.
$ composer require netherphp/standards
Composer will have set up a little bin script. It accepts any argument that can normally be passed to phpcs
. It will display a report of all the violations in all the files that it found. No changes will be made to the code at this stage.
$ nethercs <dir-or-file>
This is the same as invoking phpcs
like this:
$ phpcs <dir-or-file> --standard=vendor/netherphp/standards/NetherCS
Note: if
./vendor/bin
is not in your PATH you will need to use the full path to the bin scripts,vendor/bin/nethercs
orvendor/bin/phpcs
.
Composer will set up another bin script, nethercbf
, to wrap phpcbf
for you. By default nethercbf
will NOT overwrite code, but create new files ending in .nethercs
for you to inspect.
$ nethercbf <dir-or-file>
This is the same as invoking phpcbf
like this:
$ phpcbf <dir-or-file> --standard=vendor/netherphp/standards/NetherCS --suffix=.nethercs
If you are satisfied with the results you can apply the fixes to the original code files with the following:
$ nethercbf <dir-or-file> --overwrite
Which is the same as invoking phpcbf
like this:
$ phpcbf <dir-or-file> --standard=vendor/netherphp/standards/NetherCS
If you install dealerdirect/phpcodesniffer-composer-installer
after installing netherphp/standards
then NetherCS will be detected as an installed standard by phpcs
. This seems like an important step to get the phpcs
autoloader to work as expected if you are trying to use a custom linter in your IDE to work rather than the command line interface provided by this package.
$ phpcs -i
The installed coding standards are PSR12, PSR2, Zend, PEAR, MySource, Squiz, PSR1 and NetherCS