From 2c1b135473bfcd8da8b4a231d0aae50da92120fa Mon Sep 17 00:00:00 2001 From: Stu <31927084+yCodeTech@users.noreply.github.com> Date: Wed, 27 Aug 2025 03:54:03 +0100 Subject: [PATCH 1/3] 4.0 | Wiki: add the cumulative exit codes - Added the cumulative exit codes as documented in the interim proposal (https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/184#issuecomment-2644329771). This ensures a complete exit code documentation where users and devs can easily read exactly what the cumulative exit codes are. - Also added another description to the `0` exit code to describe when issues are fixed with no issues remaining, because "clean code base" could just be interpreted as no issues at all. --- wiki/Advanced-Usage.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/wiki/Advanced-Usage.md b/wiki/Advanced-Usage.md index 25bc73e..07d108c 100644 --- a/wiki/Advanced-Usage.md +++ b/wiki/Advanced-Usage.md @@ -515,17 +515,25 @@ If a coding standard or configuration file includes settings to print progress o As of PHP_CodeSniffer 4.0.0, exit codes are cumulative and composed as follows: -| Exit code | Meaning | -| --------- | ------------------------------------------------------------------------------------------------------- | -| `0` | clean code base / successful non-scan request (_help/documentation/etc_) | -| `1` | issues found/remaining, auto-fixable | -| `2` | issues found/remaining, non-auto-fixable | -| `4` | failure to fix some files/fixer conflict (phpcbf only) | -| `16` | processing error - blocking the actual run of PHP_CodeSniffer, like a parse error in an XML ruleset | -| `64` | requirements for running not met (i.e. minimum PHP version doesn't comply, missing required extensions) | +| Exit code | Meaning | +| --------- | -------------------------------------------------------------------------------------------------------------- | +| `0` | clean code base / auto-fixed with no issues remaining / successful non-scan request (_help/documentation/etc_) | +| `1` | issues found/remaining, auto-fixable | +| `2` | issues found/remaining, non-auto-fixable | +| `4` | failure to fix some files/fixer conflict (phpcbf only) | +| `16` | processing error - blocking the actual run of PHP_CodeSniffer, like a parse error in an XML ruleset | +| `64` | requirements for running not met (i.e. minimum PHP version doesn't comply, missing required extensions) | 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`). +Cumulative exit codes: + +| Exit code | Meaning | +| --------- | ------------------------------------------------------------------------------------------------------- | +| `3` | issues found, mix of auto-fixable and non-auto-fixable (`1` + `2`) (phpcs only) | +| `5` | issues found, auto-fixable, but some failed to fix (`1` + `4`) (phpcbf only) | +| `7` | issues found, mix of auto-fixable and non-auto-fixable, but some failed to fix (`1` + `2` + `4`) (phpcbf only) | + 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). From 0a2036fa5bcbea6add471ebdb8162f0753985981 Mon Sep 17 00:00:00 2001 From: yCodeTech Date: Wed, 27 Aug 2025 05:19:46 +0100 Subject: [PATCH 2/3] fix: cumulative exit codes table formatting --- wiki/Advanced-Usage.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wiki/Advanced-Usage.md b/wiki/Advanced-Usage.md index 07d108c..647ac1c 100644 --- a/wiki/Advanced-Usage.md +++ b/wiki/Advanced-Usage.md @@ -528,11 +528,12 @@ Example: when running `phpcs`, if both auto-fixable as well as non-auto-fixable Cumulative exit codes: -| Exit code | Meaning | -| --------- | ------------------------------------------------------------------------------------------------------- | -| `3` | issues found, mix of auto-fixable and non-auto-fixable (`1` + `2`) (phpcs only) | -| `5` | issues found, auto-fixable, but some failed to fix (`1` + `4`) (phpcbf only) | -| `7` | issues found, mix of auto-fixable and non-auto-fixable, but some failed to fix (`1` + `2` + `4`) (phpcbf only) | +| Exit code | Meaning | +|-----------|----------------------------------------------------------------------------------------------------------------| +| `3` | issues found, mix of auto-fixable and non-auto-fixable (`1` + `2`) (phpcs only) | +| `5` | issues found, auto-fixable, but some failed to fix (`1` + `4`) (phpcbf only) | +| `7` | issues found, mix of auto-fixable and non-auto-fixable, but some failed to fix (`1` + `2` + `4`) (phpcbf only) | + 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). From 5634b9bc986cff915c3d5c6c5dd5205d41f1f997 Mon Sep 17 00:00:00 2001 From: yCodeTech Date: Thu, 28 Aug 2025 02:51:36 +0100 Subject: [PATCH 3/3] 4.0 | Wiki: change cumulative exit codes table and example paragraph - Added new column to the cumulative exit codes table to define the codes that were combined, instead of defining them in brackets in the descriptions. - Removed the now redundant cumulative exit code example. - Changed the cumulative table header to describe the cumulative behaviour. --- wiki/Advanced-Usage.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/wiki/Advanced-Usage.md b/wiki/Advanced-Usage.md index 647ac1c..e6c614c 100644 --- a/wiki/Advanced-Usage.md +++ b/wiki/Advanced-Usage.md @@ -524,16 +524,13 @@ As of PHP_CodeSniffer 4.0.0, exit codes are cumulative and composed as follows: | `16` | processing error - blocking the actual run of PHP_CodeSniffer, like a parse error in an XML ruleset | | `64` | requirements for running not met (i.e. minimum PHP version doesn't comply, missing required extensions) | -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`). - -Cumulative exit codes: - -| Exit code | Meaning | -|-----------|----------------------------------------------------------------------------------------------------------------| -| `3` | issues found, mix of auto-fixable and non-auto-fixable (`1` + `2`) (phpcs only) | -| `5` | issues found, auto-fixable, but some failed to fix (`1` + `4`) (phpcbf only) | -| `7` | issues found, mix of auto-fixable and non-auto-fixable, but some failed to fix (`1` + `2` + `4`) (phpcbf only) | +The exit codes in some situations can be combined, resulting in a new exit code. These cumulative exit codes are as follows: +| Exit code | Exit codes used | Meaning | +| --------- | --------------- | -------------------------------------------------------------------------------------------- | +| `3` | `1` + `2` | issues found, mix of auto-fixable and non-auto-fixable (phpcs only) | +| `5` | `1` + `4` | issues found, auto-fixable, but some failed to fix (phpcbf only) | +| `7` | `1` + `2` + `4` | issues found, mix of auto-fixable and non-auto-fixable, but some failed to fix (phpcbf only) | 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).