Skip to content

Commit b702ec9

Browse files
committed
Fix up docs.
1 parent 6e3e767 commit b702ec9

File tree

5 files changed

+26
-112
lines changed

5 files changed

+26
-112
lines changed

PSR2R/Tools/Sniffer.php

Lines changed: 0 additions & 81 deletions
This file was deleted.

README.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,28 @@ Most likely you are using composer. As such, put it into the require-dev depende
3636
composer 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

9593
If you want a list of all sniffs in this standard, use `-e`:
9694
```
97-
vendor/bin/sniff -e
95+
vendor/bin/phpcs -e
9896
```
9997
It 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

106104
Usually, 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
112110
For 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

phpcs.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
<file>PSR2R/</file>
88
<file>docs/</file>
99
<file>bin/</file>
10+
<file>tests/Sniffs/</file>
1011

1112
<rule ref="PSR2R"/>
1213

13-
<exclude-pattern>/tests/files/,*.inc,*.fixed</exclude-pattern>
14+
<exclude-pattern>,*.inc,*.fixed</exclude-pattern>
1415

1516
</ruleset>

tests/Sniffs/Commenting/FullyQualifiedClassNameInDocBlockSniffTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ class FullyQualifiedClassNameInDocBlockSniffTest extends TestCase {
99

1010
/**
1111
* @return void
12-
* @throws \PHPUnit_Framework_AssertionFailedError
13-
* @throws \PHPUnit_Framework_Exception
1412
*/
1513
public function testInstance() {
1614
$this->assertTrue(class_exists(FullyQualifiedClassNameInDocBlockSniff::class));

tests/Sniffs/Commenting/FullyQualifiedClassNameInDocBlockUnitTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77
class FullyQualifiedClassNameInDocBlockUnitTest extends AbstractSniffUnitTest {
88

99
/**
10-
* {@inheritDoc}
10+
* @inheritDoc
1111
*/
12-
public function getErrorList()
13-
{
12+
public function getErrorList() {
1413
return [
1514
//9 => 1,
1615
];
1716
}
1817
/**
19-
* {@inheritDoc}
18+
* @inheritDoc
2019
*/
21-
public function getWarningList()
22-
{
20+
public function getWarningList() {
2321
return [
2422
];
2523
}

0 commit comments

Comments
 (0)