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
@@ -123,44 +123,52 @@ The simplest way of using PHP_CodeSniffer is to provide the location of a file o
123
123
124
124
In the example below, the first command tells PHP_CodeSniffer to check the `myfile.inc` file for coding standard errors while the second command tells PHP_CodeSniffer to check all PHP files in the `my_dir` directory.
125
125
126
-
$ phpcs /path/to/code/myfile.inc
127
-
$ phpcs /path/to/code/my_dir
126
+
```bash
127
+
$ phpcs /path/to/code/myfile.inc
128
+
$ phpcs /path/to/code/my_dir
129
+
```
128
130
129
131
You can also specify multiple files and folders to check. The command below tells PHP_CodeSniffer to check the `myfile.inc` file and all files in the `my_dir` directory.
After PHP_CodeSniffer has finished processing your files, you will get an error report. The report lists both errors and warnings for all files that violated the coding standard. The output looks like this:
<palign="right"><ahref="#table-of-contents">back to top</a></p>
166
174
@@ -169,32 +177,36 @@ If you don't want warnings included in the output, specify the `-n` command line
169
177
170
178
By default, PHP_CodeSniffer will print a complete list of all errors and warnings it finds. This list can become quite long, especially when checking a large number of files at once. To print a summary report that only shows the number of errors and warnings for each file, use the `--report=summary` command line argument. The output will look like this:
> You can configure PHP_CodeSniffer to show progress information by default using [the configuration option](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#showing-progress-by-default)</link>.
229
244
230
245
With verbose output enabled, PHP_CodeSniffer will print the file that it is checking, show you how many tokens and lines the file contains, and let you know how long it took to process. The output will look like this:
231
246
232
-
$ phpcs /path/to/code/CodeSniffer -v
233
-
Registering sniffs in PEAR standard... DONE (24 sniffs registered)
234
-
Creating file list... DONE (572 files in queue)
235
-
Processing AbstractDocElement.php [1093 tokens in 303 lines]... DONE in < 1 second (0 errors, 1 warnings)
236
-
Processing AbstractParser.php [2360 tokens in 558 lines]... DONE in 2 seconds (0 errors, 1 warnings)
237
-
Processing ClassCommentParser.php [923 tokens in 296 lines]... DONE in < 1 second (2 errors, 0 warnings)
238
-
Processing CommentElement.php [988 tokens in 218 lines]... DONE in < 1 second (1 error, 5 warnings)
239
-
Processing FunctionCommentParser.php [525 tokens in 184 lines]... DONE in 1 second (0 errors, 6 warnings)
240
-
Processing File.php [10968 tokens in 1805 lines]... DONE in 5 seconds (0 errors, 5 warnings)
241
-
Processing Sniff.php [133 tokens in 94 lines]... DONE in < 1 second (0 errors, 0 warnings)
242
-
Processing SniffException.php [47 tokens in 36 lines]... DONE in < 1 second (1 errors, 3 warnings)
247
+
```
248
+
$ phpcs /path/to/code/CodeSniffer -v
249
+
250
+
Registering sniffs in PEAR standard... DONE (24 sniffs registered)
251
+
Creating file list... DONE (572 files in queue)
252
+
Processing AbstractDocElement.php [1093 tokens in 303 lines]... DONE in < 1 second (0 errors, 1 warnings)
253
+
Processing AbstractParser.php [2360 tokens in 558 lines]... DONE in 2 seconds (0 errors, 1 warnings)
254
+
Processing ClassCommentParser.php [923 tokens in 296 lines]... DONE in < 1 second (2 errors, 0 warnings)
255
+
Processing CommentElement.php [988 tokens in 218 lines]... DONE in < 1 second (1 error, 5 warnings)
256
+
Processing FunctionCommentParser.php [525 tokens in 184 lines]... DONE in 1 second (0 errors, 6 warnings)
257
+
Processing File.php [10968 tokens in 1805 lines]... DONE in 5 seconds (0 errors, 5 warnings)
258
+
Processing Sniff.php [133 tokens in 94 lines]... DONE in < 1 second (0 errors, 0 warnings)
259
+
Processing SniffException.php [47 tokens in 36 lines]... DONE in < 1 second (1 errors, 3 warnings)
260
+
```
243
261
244
262
<palign="right"><ahref="#table-of-contents">back to top</a></p>
245
263
@@ -250,15 +268,21 @@ PHP_CodeSniffer can have multiple coding standards installed to allow a single i
250
268
251
269
The example below checks the `myfile.inc` file for violations of the _PEAR_ coding standard (installed by default).
252
270
253
-
$ phpcs --standard=PEAR /path/to/code/myfile.inc
271
+
```bash
272
+
$ phpcs --standard=PEAR /path/to/code/myfile.inc
273
+
```
254
274
255
275
You can also tell PHP_CodeSniffer to use an external standard by specifying the full path to the standard's root directory on the command line. An external standard is one that is stored outside of PHP_CodeSniffer's `Standards` directory.
Multiple coding standards can be checked at the same time by passing a list of comma separated standards on the command line. A mix of external and installed coding standards can be passed if required.
<palign="right"><ahref="#table-of-contents">back to top</a></p>
264
288
@@ -267,8 +291,10 @@ Multiple coding standards can be checked at the same time by passing a list of c
267
291
268
292
PHP_CodeSniffer can print you a list of the coding standards that are installed so that you can correctly specify a coding standard to use for testing. You can print this list by specifying the `-i` command line argument.
269
293
270
-
$ phpcs -i
271
-
The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz and Zend
294
+
```
295
+
$ phpcs -i
296
+
The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz and Zend
297
+
```
272
298
273
299
<palign="right"><ahref="#table-of-contents">back to top</a></p>
0 commit comments