@@ -49,46 +49,80 @@ Diff reports are more easily used when output to a file. They can then be applie
49
49
## Using the PHP Code Beautifier and Fixer
50
50
To automatically fix as many sniff violations as possible, use the ` phpcbf ` command in place of the ` phpcs ` command. While most of the PHPCS command line arguments can be used by PHPCBF, some are specific to reporting and will be ignored. Running PHPCBF with the ` -h ` or ` --help ` command line arguments will print a list of commands that PHPCBF will respond to. The output of ` phpcbf -h ` is shown below.
51
51
```
52
- Usage: phpcbf [-nwli] [-d key[=value]] [--ignore-annotations] [--stdin-path=<stdinPath>]
53
- [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--suffix=<suffix>]
54
- [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]
55
- [--tab-width=<tabWidth>] [--encoding=<encoding>] [--parallel=<processes>]
56
- [--basepath=<basepath>] [--extensions=<extensions>] [--ignore=<patterns>] <file> - ...
57
-
58
- - Fix STDIN instead of local files and directories
59
- -n Do not fix warnings (shortcut for --warning-severity=0)
60
- -w Fix both warnings and errors (on by default)
61
- -l Local directory only, no recursion
62
- -p Show progress of the run
63
- -q Quiet mode; disables progress and verbose output
64
- -v Print processed files
65
- -vv Print ruleset and token output
66
- -vvv Print sniff processing information
67
- -i Show a list of installed coding standards
68
- -d Set the [key] php.ini value to [value] or [true] if value is omitted
69
-
70
- --help Print this help message
71
- --version Print version information
72
- --ignore-annotations Ignore all phpcs: annotations in code comments
73
-
74
- <basepath> A path to strip from the front of file paths inside reports
75
- <file> One or more files and/or directories to fix
76
- <encoding> The encoding of the files being fixed (default is utf-8)
77
- <extensions> A comma separated list of file extensions to fix
78
- (extension filtering only valid when checking a directory)
79
- The type of the file can be specified using: ext/type
80
- e.g., module/php,es/js
81
- <patterns> A comma separated list of patterns to ignore files and directories
82
- <processes> How many files should be fixed simultaneously (default is 1)
83
- <severity> The minimum severity required to fix an error or warning
84
- <sniffs> A comma separated list of sniff codes to include or exclude from fixing
85
- (all sniffs must be part of the specified standard)
86
- <standard> The name or path of the coding standard to use
87
- <stdinPath> If processing STDIN, the file path that STDIN will be processed as
88
- <suffix> Write modified files to a filename using this suffix
89
- ("diff" and "patch" are not used in this mode)
90
- <tabWidth> The number of spaces each tab represents
52
+ Usage:
53
+ phpcbf [options] <file|directory>
54
+
55
+ Scan targets:
56
+ <file|directory> One or more files and/or directories to check, space separated.
57
+ - Check STDIN instead of local files and directories.
58
+ --stdin-path=<stdinPath> If processing STDIN, the file path that STDIN will be processed as.
59
+ --file-list=<fileList> Check the files and/or directories which are defined in the file to which the
60
+ path is provided (one per line).
61
+ --filter=<filter> Check based on a predefined file filter. Use either the "GitModified" or
62
+ "GitStaged" filter, or specify the path to a custom filter class.
63
+ --ignore=<patterns> Ignore files based on a comma-separated list of patterns matching files and/or
64
+ directories.
65
+ --extensions=<extensions> Check files with the specified file extensions (comma-separated list).
66
+ Defaults to php,inc/php,js,css.
67
+ The type of the file can be specified using: ext/type; e.g. module/php,es/js.
68
+ -l Check local directory only, no recursion.
69
+
70
+ Rule Selection Options:
71
+ --standard=<standard> The name of, or the path to, the coding standard to use. Can be a
72
+ comma-separated list specifying multiple standards. If no standard is
73
+ specified, PHP_CodeSniffer will look for a [.]phpcs.xml[.dist] custom ruleset
74
+ file in the current directory and those above it.
75
+ --sniffs=<sniffs> A comma-separated list of sniff codes to limit the scan to. All sniffs must be
76
+ part of the standard in use.
77
+ --exclude=<sniffs> A comma-separated list of sniff codes to exclude from the scan. All sniffs
78
+ must be part of the standard in use.
79
+
80
+ -i Show a list of installed coding standards.
81
+
82
+ Run Options:
83
+ --bootstrap=<bootstrap> Run the specified file(s) before processing begins. A list of files can be
84
+ provided, separated by commas.
85
+ --parallel=<processes> The number of files to be checked simultaneously. Defaults to 1 (no parallel
86
+ processing).
87
+ If enabled, this option only takes effect if the PHP PCNTL (Process Control)
88
+ extension is available.
89
+ --suffix=<suffix> Write modified files to a filename using this suffix ("diff" and "patch" are
90
+ not used in this mode).
91
+
92
+ -d <key[=value]> Set the [key] php.ini value to [value] or set to [true] if value is omitted.
93
+ Note: only php.ini settings which can be changed at runtime are supported.
94
+
95
+ Reporting Options:
96
+ --report-width=<reportWidth> How many columns wide screen reports should be. Set to "auto" to use current
97
+ screen width, where supported.
98
+ --basepath=<basepath> Strip a path from the front of file paths inside reports.
99
+
100
+ -w Include both warnings and errors (default).
101
+ -n Do not include warnings. Shortcut for "--warning-severity=0".
102
+ --severity=<severity> The minimum severity required to display an error or warning. Defaults to 5.
103
+ --error-severity=<severity> The minimum severity required to display an error. Defaults to 5.
104
+ --warning-severity=<severity> The minimum severity required to display a warning. Defaults to 5.
105
+
106
+ --ignore-annotations Ignore all "phpcs:..." annotations in code comments.
107
+ --colors Use colors in screen output.
108
+ --no-colors Do not use colors in screen output (default).
109
+ -p Show progress of the run.
110
+ -q Quiet mode; disables progress and verbose output.
111
+
112
+ Configuration Options:
113
+ --encoding=<encoding> The encoding of the files being checked. Defaults to "utf-8".
114
+ --tab-width=<tabWidth> The number of spaces each tab represents.
115
+
116
+ --runtime-set <key> <value> Set a configuration option to be applied to the current scan run only.
117
+
118
+ Miscellaneous Options:
119
+ -h, -?, --help Print this help message.
120
+ --version Print version information.
121
+ -v Verbose output: Print processed files.
122
+ -vv Verbose output: Print ruleset and token output.
123
+ -vvv Verbose output: Print sniff processing information.
91
124
```
125
+
92
126
When using the PHPCBF command, you do not need to specify a report type. PHPCBF will automatically make changes to your source files:
93
127
94
128
$ phpcbf /path/to/code
0 commit comments