PHP_CodeSniffer
PHP_CodeSniffer copied to clipboard
Add constants for exit return codes
Inspired by https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Console/Command/Command.php#L37-L40, to make the code more readable and to avoid miss-using exit codes.
This is a good idea in general, but the exit codes don't map like that. PHPCS and PHPCBF use the same exit codes to mean different things, which has resulted in a suggestion like:
if ($this->reporter->totalFixable === 0) {
// PHPCBF fixed all fixable errors.
return self::FAILURE;
}
That's obviously not a failed run for PHPCS given it fixed all errors.
So this would need a bit of work before it could be merged. Likely different constants for PHPCS and PHPCBF, with appropriate names and documentation of the constant itself.
Linking the 4.0 issue to change the exit codes as this would be helpful there: https://github.com/squizlabs/PHP_CodeSniffer/issues/2898
I see that return codes are not consistent, so maybe that could be done for v4 only yes.