Skip to content

Commit 25ca0a7

Browse files
committed
Usage: update the help information
As per the revamped help screen. See PR PHPCSStandards/PHP_CodeSniffer#447
1 parent ae14dab commit 25ca0a7

File tree

1 file changed

+95
-65
lines changed

1 file changed

+95
-65
lines changed

wiki/Usage.md

Lines changed: 95 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -14,71 +14,101 @@
1414
Running PHP_CodeSniffer with the `-h` or `--help` command line arguments will print a list of commands that PHP_CodeSniffer will respond to. The output of `phpcs -h` is shown below.
1515

1616
```
17-
Usage: phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors]
18-
[--cache[=<cacheFile>]] [--no-cache] [--tab-width=<tabWidth>]
19-
[--report=<report>] [--report-file=<reportFile>] [--report-<report>=<reportFile>]
20-
[--report-width=<reportWidth>] [--basepath=<basepath>] [--bootstrap=<bootstrap>]
21-
[--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]
22-
[--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]
23-
[--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>]
24-
[--encoding=<encoding>] [--parallel=<processes>] [--generator=<generator>]
25-
[--extensions=<extensions>] [--ignore=<patterns>] [--ignore-annotations]
26-
[--stdin-path=<stdinPath>] [--file-list=<fileList>] [--filter=<filter>] <file> - ...
27-
28-
- Check STDIN instead of local files and directories
29-
-n Do not print warnings (shortcut for --warning-severity=0)
30-
-w Print both warnings and errors (this is the default)
31-
-l Local directory only, no recursion
32-
-s Show error codes in all reports
33-
-a Run interactively
34-
-e Explain a standard by showing the sniffs it includes
35-
-p Show progress of the run
36-
-q Quiet mode; disables progress and verbose output
37-
-m Stop error messages from being recorded
38-
(saves a lot of memory, but stops many reports from being used)
39-
-v Print processed files
40-
-vv Print ruleset and token output
41-
-vvv Print sniff processing information
42-
-i Show a list of installed coding standards
43-
-d Set the [key] php.ini value to [value] or [true] if value is omitted
44-
45-
--help Print this help message
46-
--version Print version information
47-
--colors Use colors in output
48-
--no-colors Do not use colors in output (this is the default)
49-
--cache Cache results between runs
50-
--no-cache Do not cache results between runs (this is the default)
51-
--ignore-annotations Ignore all phpcs: annotations in code comments
52-
53-
<cacheFile> Use a specific file for caching (uses a temporary file by default)
54-
<basepath> A path to strip from the front of file paths inside reports
55-
<bootstrap> A comma separated list of files to run before processing begins
56-
<encoding> The encoding of the files being checked (default is utf-8)
57-
<extensions> A comma separated list of file extensions to check
58-
The type of the file can be specified using: ext/type
59-
e.g., module/php,es/js
60-
<file> One or more files and/or directories to check
61-
<fileList> A file containing a list of files and/or directories to check (one per line)
62-
<filter> Use either the "GitModified" or "GitStaged" filter,
63-
or specify the path to a custom filter class
64-
<generator> Use either the "HTML", "Markdown" or "Text" generator
65-
(forces documentation generation instead of checking)
66-
<patterns> A comma separated list of patterns to ignore files and directories
67-
<processes> How many files should be checked simultaneously (default is 1)
68-
<report> Print either the "full", "xml", "checkstyle", "csv"
69-
"json", "junit", "emacs", "source", "summary", "diff"
70-
"svnblame", "gitblame", "hgblame", "notifysend" or "performance"
71-
report, or specify the path to a custom report class
72-
(the "full" report is printed by default)
73-
<reportFile> Write the report to the specified file path
74-
<reportWidth> How many columns wide screen reports should be printed
75-
or set to "auto" to use current screen width, where supported
76-
<severity> The minimum severity required to display an error or warning
77-
<sniffs> A comma separated list of sniff codes to include or exclude from checking
78-
(all sniffs must be part of the specified standard)
79-
<standard> The name or path of the coding standard to use
80-
<stdinPath> If processing STDIN, the file path that STDIN will be processed as
81-
<tabWidth> The number of spaces each tab represents
17+
Usage:
18+
phpcs [options] <file|directory>
19+
20+
Scan targets:
21+
<file|directory> One or more files and/or directories to check, space separated.
22+
- Check STDIN instead of local files and directories.
23+
--stdin-path=<stdinPath> If processing STDIN, the file path that STDIN will be processed as.
24+
--file-list=<fileList> Check the files and/or directories which are defined in the file to which the
25+
path is provided (one per line).
26+
--filter=<filter> Check based on a predefined file filter. Use either the "GitModified" or
27+
"GitStaged" filter, or specify the path to a custom filter class.
28+
--ignore=<patterns> Ignore files based on a comma-separated list of patterns matching files
29+
and/or directories.
30+
--extensions=<extensions> Check files with the specified file extensions (comma-separated list).
31+
Defaults to php,inc/php,js,css.
32+
The type of the file can be specified using: ext/type; e.g. module/php,es/js.
33+
-l Check local directory only, no recursion.
34+
35+
Rule Selection Options:
36+
--standard=<standard> The name of, or the path to, the coding standard to use. Can be a
37+
comma-separated list specifying multiple standards. If no standard is
38+
specified, PHP_CodeSniffer will look for a [.]phpcs.xml[.dist] custom ruleset
39+
file in the current directory and those above it.
40+
--sniffs=<sniffs> A comma-separated list of sniff codes to limit the scan to. All sniffs must
41+
be part of the standard in use.
42+
--exclude=<sniffs> A comma-separated list of sniff codes to exclude from the scan. All sniffs
43+
must be part of the standard in use.
44+
45+
-i Show a list of installed coding standards.
46+
-e Explain a standard by showing the names of all the sniffs it includes.
47+
--generator=<generator> Show documentation for a standard. Use either the "HTML", "Markdown" or
48+
"Text" generator.
49+
50+
Run Options:
51+
-a Run in interactive mode, pausing after each file.
52+
--bootstrap=<bootstrap> Run the specified file(s) before processing begins. A list of files can be
53+
provided, separated by commas.
54+
--cache[=<cacheFile>] Cache results between runs. Optionally, <cacheFile> can be provided to use a
55+
specific file for caching. Otherwise, a temporary file is used.
56+
--no-cache Do not cache results between runs (default).
57+
--parallel=<processes> The number of files to be checked simultaneously. Defaults to 1 (no parallel
58+
processing).
59+
If enabled, this option only takes effect if the PHP PCNTL (Process Control)
60+
extension is available.
61+
62+
-d <key[=value]> Set the [key] php.ini value to [value] or set to [true] if value is omitted.
63+
Note: only php.ini settings which can be changed at runtime are supported.
64+
65+
Reporting Options:
66+
--report=<report> Print either the "full", "xml", "checkstyle", "csv", "json", "junit",
67+
"emacs", "source", "summary", "diff", "svnblame", "gitblame", "hgblame",
68+
"notifysend" or "performance" report or specify the path to a custom report
69+
class. By default, the "full" report is displayed.
70+
--report-file=<reportFile> Write the report to the specified file path.
71+
--report-<report>=<reportFile> Write the report specified in <report> to the specified file path.
72+
--report-width=<reportWidth> How many columns wide screen reports should be. Set to "auto" to use current
73+
screen width, where supported.
74+
--basepath=<basepath> Strip a path from the front of file paths inside reports.
75+
76+
-w Include both warnings and errors (default).
77+
-n Do not include warnings. Shortcut for "--warning-severity=0".
78+
--severity=<severity> The minimum severity required to display an error or warning. Defaults to 5.
79+
--error-severity=<severity> The minimum severity required to display an error. Defaults to 5.
80+
--warning-severity=<severity> The minimum severity required to display a warning. Defaults to 5.
81+
82+
-s Show sniff error codes in all reports.
83+
--ignore-annotations Ignore all "phpcs:..." annotations in code comments.
84+
--colors Use colors in screen output.
85+
--no-colors Do not use colors in screen output (default).
86+
-p Show progress of the run.
87+
-q Quiet mode; disables progress and verbose output.
88+
-m Stop error messages from being recorded. This saves a lot of memory but stops
89+
many reports from being used.
90+
91+
Configuration Options:
92+
--encoding=<encoding> The encoding of the files being checked. Defaults to "utf-8".
93+
--tab-width=<tabWidth> The number of spaces each tab represents.
94+
95+
Default values for a selection of options can be stored in a user-specific CodeSniffer.conf configuration
96+
file.
97+
This applies to the following options: "default_standard", "report_format", "tab_width", "encoding",
98+
"severity", "error_severity", "warning_severity", "show_warnings", "report_width", "show_progress", "quiet",
99+
"colors", "cache", "parallel".
100+
--config-show Show the configuration options which are currently stored in the applicable
101+
CodeSniffer.conf file.
102+
--config-set <key> <value> Save a configuration option to the CodeSniffer.conf file.
103+
--config-delete <key> Delete a configuration option from the CodeSniffer.conf file.
104+
--runtime-set <key> <value> Set a configuration option to be applied to the current scan run only.
105+
106+
Miscellaneous Options:
107+
-h, -?, --help Print this help message.
108+
--version Print version information.
109+
-v Verbose output: Print processed files.
110+
-vv Verbose output: Print ruleset and token output.
111+
-vvv Verbose output: Print sniff processing information.
82112
```
83113

84114
> [!NOTE]

0 commit comments

Comments
 (0)