@@ -36,30 +36,28 @@ Most likely you are using composer. As such, put it into the require-dev depende
3636composer require --dev fig-r/psr2r-sniffer
3737```
3838
39- You can then use it like this:
40- ```
41- // Sniffs only
42- vendor/bin/sniff /path/to/your/files
39+ Set up a ` phpcs.xml ` in the root of your library.
40+ Define here the standard to use as well as the project paths, usually
41+ ``` xml
42+ < rule ref = " vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml " />
4343
44- // Sniffs and fixes
45- vendor/bin/sniff /path/to/your/files -f
44+ < file >src/</ file >
45+ < file >tests/</ file >
4646```
47- The path is optional if you want to run it on your complete project root dir. It will in this case automatically skip the ` vendor/ ` dir.
4847
49- #### Examples
50- If you want to run the sniffer over your root ` src/ ` folder, run:
51- ```
52- vendor/bin/sniff src/
48+ You can then use it like this:
5349```
50+ // Sniffs only
51+ vendor/bin/phpcs {path/file}
5452
55- Use ` -h ` to list all available options.
56- But with this bin tool the path needs to always come first (it does not work otherwise):
57- ```
58- vendor/bin/sniff /path/to/files [optional params]
53+ // Sniffs and fixes
54+ vendor/bin/phpcbf {path/file}
5955```
56+ The path is optional if you want to run it on a specific subset of your defined paths.
57+ Otherwise, it defaults to the paths defined in your XML file.
6058
6159### Customizing
62- You can always customize on project level using your own ` phpcs.xml ` file there , e.g.:
60+ You can always customize your ` phpcs.xml ` further , e.g.:
6361
6462``` xml
6563<?xml version =" 1.0" ?>
@@ -83,7 +81,7 @@ You can always customize on project level using your own `phpcs.xml` file there,
8381 <severity >0</severity >
8482 </rule >
8583
86- <!-- Define your own sniffs here -->
84+ <!-- Define your own additional sniffs here -->
8785
8886</ruleset >
8987```
@@ -94,24 +92,24 @@ Verbose output with `-v` is always useful. With `-vv` or even `-vvv` you get eve
9492
9593If you want a list of all sniffs in this standard, use ` -e ` :
9694```
97- vendor/bin/sniff -e
95+ vendor/bin/phpcs -e
9896```
9997It will list them all grouped by their standard name and sniff type.
10098
101- To just run a single sniff, use ` --sniffs=... ` and a comma separated list of sniffs, . e.g.:
99+ To just run a single sniff, use ` --sniffs=... ` and a comma separated list of sniffs, e.g.:
102100```
103- vendor/bin/sniff --sniffs=PSR2R.Files.EndFileNewline
101+ vendor/bin/phpcs --sniffs=PSR2R.Files.EndFileNewline
104102```
105103
106104Usually, if you run it over your complete repository, you would want to exclude dirs like ` tests/test_files/ ` :
107105```
108- vendor/bin/sniff --ignore=tests/test_files/
106+ vendor/bin/phpcs --ignore=/ tests/test_files/
109107```
110108
111109#### Windows usage
112110For Win OS you should be using ` \ ` as separator:
113111```
114- vendor\bin\sniff -v
112+ vendor\bin\phpcs
115113```
116114
117115#### Include it in your IDE via hotkey
0 commit comments