|
18 | 18 | * [The Level Map](#the-level-map)
|
19 | 19 | * [Printing Verbose Token Processing Output](#printing-verbose-token-processing-output)
|
20 | 20 | * [Quieting Output](#quieting-output)
|
| 21 | +* [Understanding the Exit Codes](#understanding-the-exit-codes) |
21 | 22 |
|
22 | 23 | ***
|
23 | 24 |
|
@@ -524,3 +525,35 @@ For example, the ScopeIndentSniff executes on the if statement's token only, but
|
524 | 525 | If a coding standard or configuration file includes settings to print progress or verbose output while running PHP_CodeSniffer, it can make it difficult to use the standard with automated checking tools and build scripts as these typically only expect an error report. If you have this problem, or just want less output, you can quieten the output of PHP_CodeSniffer by using the `-q` command line argument. When using this quiet mode, PHP_CodeSniffer will only print report output, and only if errors or warnings are found. No progress or verbose output will be printed.
|
525 | 526 |
|
526 | 527 | <p align="right"><a href="#table-of-contents">back to top</a></p>
|
| 528 | + |
| 529 | + |
| 530 | +## Understanding the Exit Codes |
| 531 | + |
| 532 | +As of PHP_CodeSniffer 4.0.0, exit codes are cumulative and composed as follows: |
| 533 | + |
| 534 | +| Exit code | Meaning | |
| 535 | +| --------- | ------------------------------------------------------------------------------------------------------- | |
| 536 | +| `0` | clean code base / successful non-scan request (_help/documentation/etc_) | |
| 537 | +| `1` | issues found/remaining, auto-fixable | |
| 538 | +| `2` | issues found/remaining, non-auto-fixable | |
| 539 | +| `4` | failure to fix some files/fixer conflict (phpcbf only) | |
| 540 | +| `16` | processing error - blocking the actual run of PHP_CodeSniffer, like a parse error in an XML ruleset | |
| 541 | +| `64` | requirements for running not met (i.e. minimum PHP version doesn't comply, missing required extensions) | |
| 542 | + |
| 543 | +Example: when running `phpcs`, if both auto-fixable as well as non-auto-fixable issues are found, the exit code will be `3` (`1` + `2`). |
| 544 | + |
| 545 | +The exit codes can be influenced by the following configuration flags: [`ignore_errors_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-errors-when-generating-the-exit-code), [`ignore_warnings_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-warnings-when-generating-the-exit-code) and [`ignore_non_auto_fixable_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-non-auto-fixable-issues-when-generating-the-exit-code). |
| 546 | + |
| 547 | + |
| 548 | +In PHP_CodeSniffer 3.x, the exit codes were: |
| 549 | + |
| 550 | +| `phpcs` | | `phpcbf` | | |
| 551 | +| ------- | -------------------- | -------- | -------------------------------------------------------- | |
| 552 | +| `0` | no errors found | `0` | no fixable errors were found, so nothing was fixed | |
| 553 | +| `1` | errors found | `1` | all fixable errors were fixed correctly | |
| 554 | +| `2` | fixable errors found | `2` | PHPCBF failed to fix some of the fixable errors it found | |
| 555 | +| `3` | processing error | `3` | processing error | |
| 556 | + |
| 557 | +And the following configuration flags were available: [`ignore_errors_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-errors-when-generating-the-exit-code), [`ignore_warnings_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-warnings-when-generating-the-exit-code). |
| 558 | + |
| 559 | +<p align="right"><a href="#table-of-contents">back to top</a></p> |
0 commit comments