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
PHP_CodeSniffer supports colourised output when requested. This can be enabled with --colors and disabled with --no-colors. By default, no colour is used in output.
Other tools can selectively show colours depending on the output destination.
For example, grep in Linux has a single --color (and equivalent --colour) flag which takes an optional argument. The argument has three possible values: always, never, and auto. (When the argument is not supplied, auto is assumed.)
Describe the solution you'd like
PHP_CodeSniffer should have an auto-detection mode for colour support.
[next minor] Create functionality within PHP_CodeSniffer to allow for auto-detecting if colour support could be enabled in the current output.
Note that this functionality can be based on what has been done in other projects, like Symfony.
[next minor] Adjust the existing --colors command-line flag to support an optional argument.
These suggestions are in line with other PHP command-line tools.
--colors behaves the same as --colors=always
--colors=always turns on colour support
--colors=auto allows PHP_CodeSniffer to selectively enable / disable colourised output at its discretion.
--colors=never turns off colours support
--no-colors behaves the same as --colors=never
[next minor] Soft-deprecate --no-colors flag.
[last minor] Hard-deprecate --no-colors flag.
[next minor +1, or next major] Change default value from never to auto.
[next major] Remove --no-colors command-line flag
Future enhancements
Review code-base for existing use of colourised output: check that these use proper colour codes, and respect the setting.
Check for places where colours could be used, but are not currently.
Consider helper methods / utility for adding colour to text.
Consider if we should be adding colour always, and have an output processor remove colours as needed, or if we want to put if statements in the code where messages are generated. The helper methods / utility may be useful here.
PHP_CodeSniffer supports colourised output when requested. This can be enabled with
--colorsand disabled with--no-colors. By default, no colour is used in output.Other tools can selectively show colours depending on the output destination.
For example,
grepin Linux has a single--color(and equivalent--colour) flag which takes an optional argument. The argument has three possible values:always,never, andauto. (When the argument is not supplied,autois assumed.)Describe the solution you'd like
PHP_CodeSniffer should have an auto-detection mode for colour support.
--colorscommand-line flag to support an optional argument.These suggestions are in line with other PHP command-line tools.
--colorsbehaves the same as--colors=always--colors=alwaysturns on colour support--colors=autoallows PHP_CodeSniffer to selectively enable / disable colourised output at its discretion.--colors=neverturns off colours support--no-colorsbehaves the same as--colors=never--no-colorsflag.--no-colorsflag.nevertoauto.--no-colorscommand-line flagFuture enhancements
ifstatements in the code where messages are generated. The helper methods / utility may be useful here.Related issues / pull requests