PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Add constants for exit return codes

Open BafS opened this issue 3 years ago • 2 comments
trafficstars

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.

BafS avatar Oct 18 '22 13:10 BafS

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

gsherwood avatar Oct 20 '22 05:10 gsherwood

I see that return codes are not consistent, so maybe that could be done for v4 only yes.

BafS avatar Oct 27 '22 03:10 BafS