You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Slevomat Coding Standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) complements [Consistence Coding Standard](https://github.com/consistence/coding-standard) by providing sniffs with additional checks.
10
+
Slevomat Coding Standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) provides sniffs that fall into three categories:
11
+
12
+
* Functional - improving the safety and behaviour of code
13
+
* Cleaning - detecting dead code
14
+
* Formatting - rules for consistent code looks
11
15
12
16
## Table of contents
13
17
@@ -16,11 +20,12 @@ Slevomat Coding Standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_
16
20
-[Cleaning - detecting dead code](#cleaning---detecting-dead-code)
17
21
-[Formatting - rules for consistent code looks](#formatting---rules-for-consistent-code-looks)
18
22
2.[Installation](#installation)
19
-
3.[Using the standard as a whole](#using-the-standard-as-a-whole)
@@ -383,89 +388,82 @@ The recommended way to install Slevomat Coding Standard is [through Composer](ht
383
388
```JSON
384
389
{
385
390
"require-dev": {
386
-
"slevomat/coding-standard": "~3.0"
391
+
"slevomat/coding-standard": "~4.0"
387
392
}
388
393
}
389
394
```
390
395
391
396
It's also recommended to install [jakub-onderka/php-parallel-lint](https://github.com/JakubOnderka/PHP-Parallel-Lint) which checks source code for syntax errors. Sniffs count on the processed code to be syntatically valid (no parse errors), otherwise they can behave unexpectedly. It is advised to run `PHP-Parallel-Lint` in your build tool before running `PHP_CodeSniffer` and exiting the build process early if `PHP-Parallel-Lint` fails.
392
397
393
-
## Using the standard as a whole
398
+
## How to run the sniffs
394
399
395
-
If you want to use the whole coding standard, besides requiring `slevomat/coding-standard` in composer.json, require also Consistence Coding Standard:
400
+
You can choose one of two ways to run only selected sniffs from the standard on your codebase:
396
401
397
-
```JSON
398
-
{
399
-
"require-dev": {
400
-
"consistence/coding-standard": "~2.0"
401
-
}
402
-
}
403
-
```
402
+
### Choose which sniffs to run
404
403
405
-
Then mention both standards in `ruleset.xml`:
404
+
Mention Slevomat Conding Standard in your project's`ruleset.xml`:
<configname="installed_paths"value="../../slevomat/coding-standard"/><!-- relative path from PHPCS source location -->
413
410
</ruleset>
414
411
```
415
412
416
-
To check your code base for violations, run `PHP-Parallel-Lint` and `PHP_CodeSniffer` from the command line:
413
+
When running `phpcs`[on the command line](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage), use the `--sniffs` option to list all the sniffs you want to use separated by a comma:
When running `phpcs`[on the command line](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage), use the `--sniffs` option to list all the sniffs you want to use separated by a comma:
⚠️ This is no longer a recommended way to use Slevomat Coding Standard, because your build can break when moving between minor versions of the standard (which can happen if you use `^` or `~` version constraint in `composer.json`). We regularly add new sniffs even in minor versions meaning your code won't most likely comply with new minor versions of the package.
449
441
450
-
Mention Slevomat Conding Standard in your project's `ruleset.xml` and list all the excluded sniffs:
442
+
If you want to use the whole coding standard, besides requiring `slevomat/coding-standard` in composer.json, require also Consistence Coding Standard:
0 commit comments