PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/extra/php-codesniffer-php-token/Config.php +1353 -1373 3.0.1 → 6.3.0 View file →
@@ -14,1585 +14,1565 @@
14 14
15 15 use PHP_CodeSniffer\Exceptions\DeepExitException;
16 16 use PHP_CodeSniffer\Exceptions\RuntimeException;
17 17
18 -class Config
19 -{
18 +class Config {
20 19
21 - /**
22 - * The current version.
23 - *
24 - * @var string
25 - */
26 - const VERSION = '3.5.4';
20 + /**
21 + * The current version.
22 + *
23 + * @var string
24 + */
25 + const VERSION = '3.5.4';
27 26
28 - /**
29 - * Package stability; either stable, beta or alpha.
30 - *
31 - * @var string
32 - */
33 - const STABILITY = 'stable';
27 + /**
28 + * Package stability; either stable, beta or alpha.
29 + *
30 + * @var string
31 + */
32 + const STABILITY = 'stable';
34 33
35 - /**
36 - * An array of settings that PHPCS and PHPCBF accept.
37 - *
38 - * This array is not meant to be accessed directly. Instead, use the settings
39 - * as if they are class member vars so the __get() and __set() magic methods
40 - * can be used to validate the values. For example, to set the verbosity level to
41 - * level 2, use $this->verbosity = 2; instead of accessing this property directly.
42 - *
43 - * The list of settings are:
44 - *
45 - * string[] files The files and directories to check.
46 - * string[] standards The standards being used for checking.
47 - * int verbosity How verbose the output should be.
48 - * 0: no unnecessary output
49 - * 1: basic output for files being checked
50 - * 2: ruleset and file parsing output
51 - * 3: sniff execution output
52 - * bool interactive Enable interactive checking mode.
53 - * bool parallel Check files in parallel.
54 - * bool cache Enable the use of the file cache.
55 - * bool cacheFile A file where the cache data should be written
56 - * bool colors Display colours in output.
57 - * bool explain Explain the coding standards.
58 - * bool local Process local files in directories only (no recursion).
59 - * bool showSources Show sniff source codes in report output.
60 - * bool showProgress Show basic progress information while running.
61 - * bool quiet Quiet mode; disables progress and verbose output.
62 - * bool annotations Process phpcs: annotations.
63 - * int tabWidth How many spaces each tab is worth.
64 - * string encoding The encoding of the files being checked.
65 - * string[] sniffs The sniffs that should be used for checking.
66 - * If empty, all sniffs in the supplied standards will be used.
67 - * string[] exclude The sniffs that should be excluded from checking.
68 - * If empty, all sniffs in the supplied standards will be used.
69 - * string[] ignored Regular expressions used to ignore files and folders during checking.
70 - * string reportFile A file where the report output should be written.
71 - * string generator The documentation generator to use.
72 - * string filter The filter to use for the run.
73 - * string[] bootstrap One of more files to include before the run begins.
74 - * int reportWidth The maximum number of columns that reports should use for output.
75 - * Set to "auto" for have this value changed to the width of the terminal.
76 - * int errorSeverity The minimum severity an error must have to be displayed.
77 - * int warningSeverity The minimum severity a warning must have to be displayed.
78 - * bool recordErrors Record the content of error messages as well as error counts.
79 - * string suffix A suffix to add to fixed files.
80 - * string basepath A file system location to strip from the paths of files shown in reports.
81 - * bool stdin Read content from STDIN instead of supplied files.
82 - * string stdinContent Content passed directly to PHPCS on STDIN.
83 - * string stdinPath The path to use for content passed on STDIN.
84 - *
85 - * array<string, string> extensions File extensions that should be checked, and what tokenizer to use.
86 - * E.g., array('inc' => 'PHP');
87 - * array<string, string|null> reports The reports to use for printing output after the run.
88 - * The format of the array is:
89 - * array(
90 - * 'reportName1' => 'outputFile',
91 - * 'reportName2' => null,
92 - * );
93 - * If the array value is NULL, the report will be written to the screen.
94 - *
95 - * string[] unknown Any arguments gathered on the command line that are unknown to us.
96 - * E.g., using `phpcs -c` will give array('c');
97 - *
98 - * @var array<string, mixed>
99 - */
100 - private $settings = [
101 - 'files' => null,
102 - 'standards' => null,
103 - 'verbosity' => null,
104 - 'interactive' => null,
105 - 'parallel' => null,
106 - 'cache' => null,
107 - 'cacheFile' => null,
108 - 'colors' => null,
109 - 'explain' => null,
110 - 'local' => null,
111 - 'showSources' => null,
112 - 'showProgress' => null,
113 - 'quiet' => null,
114 - 'annotations' => null,
115 - 'tabWidth' => null,
116 - 'encoding' => null,
117 - 'extensions' => null,
118 - 'sniffs' => null,
119 - 'exclude' => null,
120 - 'ignored' => null,
121 - 'reportFile' => null,
122 - 'generator' => null,
123 - 'filter' => null,
124 - 'bootstrap' => null,
125 - 'reports' => null,
126 - 'basepath' => null,
127 - 'reportWidth' => null,
128 - 'errorSeverity' => null,
129 - 'warningSeverity' => null,
130 - 'recordErrors' => null,
131 - 'suffix' => null,
132 - 'stdin' => null,
133 - 'stdinContent' => null,
134 - 'stdinPath' => null,
135 - 'unknown' => null,
136 - ];
34 + /**
35 + * An array of settings that PHPCS and PHPCBF accept.
36 + *
37 + * This array is not meant to be accessed directly. Instead, use the settings
38 + * as if they are class member vars so the __get() and __set() magic methods
39 + * can be used to validate the values. For example, to set the verbosity level to
40 + * level 2, use $this->verbosity = 2; instead of accessing this property directly.
41 + *
42 + * The list of settings are:
43 + *
44 + * string[] files The files and directories to check.
45 + * string[] standards The standards being used for checking.
46 + * int verbosity How verbose the output should be.
47 + * 0: no unnecessary output
48 + * 1: basic output for files being checked
49 + * 2: ruleset and file parsing output
50 + * 3: sniff execution output
51 + * bool interactive Enable interactive checking mode.
52 + * bool parallel Check files in parallel.
53 + * bool cache Enable the use of the file cache.
54 + * bool cacheFile A file where the cache data should be written
55 + * bool colors Display colours in output.
56 + * bool explain Explain the coding standards.
57 + * bool local Process local files in directories only (no recursion).
58 + * bool showSources Show sniff source codes in report output.
59 + * bool showProgress Show basic progress information while running.
60 + * bool quiet Quiet mode; disables progress and verbose output.
61 + * bool annotations Process phpcs: annotations.
62 + * int tabWidth How many spaces each tab is worth.
63 + * string encoding The encoding of the files being checked.
64 + * string[] sniffs The sniffs that should be used for checking.
65 + * If empty, all sniffs in the supplied standards will be used.
66 + * string[] exclude The sniffs that should be excluded from checking.
67 + * If empty, all sniffs in the supplied standards will be used.
68 + * string[] ignored Regular expressions used to ignore files and folders during checking.
69 + * string reportFile A file where the report output should be written.
70 + * string generator The documentation generator to use.
71 + * string filter The filter to use for the run.
72 + * string[] bootstrap One of more files to include before the run begins.
73 + * int reportWidth The maximum number of columns that reports should use for output.
74 + * Set to "auto" for have this value changed to the width of the terminal.
75 + * int errorSeverity The minimum severity an error must have to be displayed.
76 + * int warningSeverity The minimum severity a warning must have to be displayed.
77 + * bool recordErrors Record the content of error messages as well as error counts.
78 + * string suffix A suffix to add to fixed files.
79 + * string basepath A file system location to strip from the paths of files shown in reports.
80 + * bool stdin Read content from STDIN instead of supplied files.
81 + * string stdinContent Content passed directly to PHPCS on STDIN.
82 + * string stdinPath The path to use for content passed on STDIN.
83 + *
84 + * array<string, string> extensions File extensions that should be checked, and what tokenizer to use.
85 + * E.g., array('inc' => 'PHP');
86 + * array<string, string|null> reports The reports to use for printing output after the run.
87 + * The format of the array is:
88 + * array(
89 + * 'reportName1' => 'outputFile',
90 + * 'reportName2' => null,
91 + * );
92 + * If the array value is NULL, the report will be written to the screen.
93 + *
94 + * string[] unknown Any arguments gathered on the command line that are unknown to us.
95 + * E.g., using `phpcs -c` will give array('c');
96 + *
97 + * @var array<string, mixed>
98 + */
99 + private $settings = [
100 + 'files' => null,
101 + 'standards' => null,
102 + 'verbosity' => null,
103 + 'interactive' => null,
104 + 'parallel' => null,
105 + 'cache' => null,
106 + 'cacheFile' => null,
107 + 'colors' => null,
108 + 'explain' => null,
109 + 'local' => null,
110 + 'showSources' => null,
111 + 'showProgress' => null,
112 + 'quiet' => null,
113 + 'annotations' => null,
114 + 'tabWidth' => null,
115 + 'encoding' => null,
116 + 'extensions' => null,
117 + 'sniffs' => null,
118 + 'exclude' => null,
119 + 'ignored' => null,
120 + 'reportFile' => null,
121 + 'generator' => null,
122 + 'filter' => null,
123 + 'bootstrap' => null,
124 + 'reports' => null,
125 + 'basepath' => null,
126 + 'reportWidth' => null,
127 + 'errorSeverity' => null,
128 + 'warningSeverity' => null,
129 + 'recordErrors' => null,
130 + 'suffix' => null,
131 + 'stdin' => null,
132 + 'stdinContent' => null,
133 + 'stdinPath' => null,
134 + 'unknown' => null,
135 + ];
137 136
138 - /**
139 - * Whether or not to kill the process when an unknown command line arg is found.
140 - *
141 - * If FALSE, arguments that are not command line options or file/directory paths
142 - * will be ignored and execution will continue. These values will be stored in
143 - * $this->unknown.
144 - *
145 - * @var boolean
146 - */
147 - public $dieOnUnknownArg;
137 + /**
138 + * Whether or not to kill the process when an unknown command line arg is found.
139 + *
140 + * If FALSE, arguments that are not command line options or file/directory paths
141 + * will be ignored and execution will continue. These values will be stored in
142 + * $this->unknown.
143 + *
144 + * @var boolean
145 + */
146 + public $dieOnUnknownArg;
148 147
149 - /**
150 - * The current command line arguments we are processing.
151 - *
152 - * @var string[]
153 - */
154 - private $cliArgs = [];
148 + /**
149 + * The current command line arguments we are processing.
150 + *
151 + * @var string[]
152 + */
153 + private $cliArgs = [];
155 154
156 - /**
157 - * Command line values that the user has supplied directly.
158 - *
159 - * @var array<string, TRUE>
160 - */
161 - private static $overriddenDefaults = [];
155 + /**
156 + * Command line values that the user has supplied directly.
157 + *
158 + * @var array<string, TRUE>
159 + */
160 + private static $overriddenDefaults = [];
162 161
163 - /**
164 - * Config file data that has been loaded for the run.
165 - *
166 - * @var array<string, string>
167 - */
168 - private static $configData = null;
162 + /**
163 + * Config file data that has been loaded for the run.
164 + *
165 + * @var array<string, string>
166 + */
167 + private static $configData = null;
169 168
170 - /**
171 - * The full path to the config data file that has been loaded.
172 - *
173 - * @var string
174 - */
175 - private static $configDataFile = null;
169 + /**
170 + * The full path to the config data file that has been loaded.
171 + *
172 + * @var string
173 + */
174 + private static $configDataFile = null;
176 175
177 - /**
178 - * Automatically discovered executable utility paths.
179 - *
180 - * @var array<string, string>
181 - */
182 - private static $executablePaths = [];
176 + /**
177 + * Automatically discovered executable utility paths.
178 + *
179 + * @var array<string, string>
180 + */
181 + private static $executablePaths = [];
183 182
184 183
185 - /**
186 - * Get the value of an inaccessible property.
187 - *
188 - * @param string $name The name of the property.
189 - *
190 - * @return mixed
191 - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid.
192 - */
193 - public function __get($name)
194 - {
195 - if (array_key_exists($name, $this->settings) === false) {
196 - throw new RuntimeException("ERROR: unable to get value of property \"$name\"");
197 - }
184 + /**
185 + * Get the value of an inaccessible property.
186 + *
187 + * @param string $name The name of the property.
188 + *
189 + * @return mixed
190 + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid.
191 + */
192 + public function __get( $name ) {
193 + if ( array_key_exists( $name, $this->settings ) === false ) {
194 + throw new RuntimeException( "ERROR: unable to get value of property \"$name\"" );
195 + }
198 196
199 - return $this->settings[$name];
197 + return $this->settings[ $name ];
200 198
201 - }//end __get()
199 + }//end __get()
202 200
203 201
204 - /**
205 - * Set the value of an inaccessible property.
206 - *
207 - * @param string $name The name of the property.
208 - * @param mixed $value The value of the property.
209 - *
210 - * @return void
211 - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid.
212 - */
213 - public function __set($name, $value)
214 - {
215 - if (array_key_exists($name, $this->settings) === false) {
216 - throw new RuntimeException("Can't __set() $name; setting doesn't exist");
217 - }
202 + /**
203 + * Set the value of an inaccessible property.
204 + *
205 + * @param string $name The name of the property.
206 + * @param mixed $value The value of the property.
207 + *
208 + * @return void
209 + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid.
210 + */
211 + public function __set( $name, $value ) {
212 + if ( array_key_exists( $name, $this->settings ) === false ) {
213 + throw new RuntimeException( "Can't __set() $name; setting doesn't exist" );
214 + }
218 215
219 - $this->settings[$name] = $value;
216 + $this->settings[ $name ] = $value;
220 217
221 - }//end __set()
218 + }//end __set()
222 219
223 220
224 - /**
225 - * Check if the value of an inaccessible property is set.
226 - *
227 - * @param string $name The name of the property.
228 - *
229 - * @return bool
230 - */
231 - public function __isset($name)
232 - {
233 - return isset($this->settings[$name]);
221 + /**
222 + * Check if the value of an inaccessible property is set.
223 + *
224 + * @param string $name The name of the property.
225 + *
226 + * @return bool
227 + */
228 + public function __isset( $name ) {
229 + return isset( $this->settings[ $name ] );
234 230
235 - }//end __isset()
231 + }//end __isset()
236 232
237 233
238 - /**
239 - * Unset the value of an inaccessible property.
240 - *
241 - * @param string $name The name of the property.
242 - *
243 - * @return void
244 - */
245 - public function __unset($name)
246 - {
247 - $this->settings[$name] = null;
234 + /**
235 + * Unset the value of an inaccessible property.
236 + *
237 + * @param string $name The name of the property.
238 + *
239 + * @return void
240 + */
241 + public function __unset( $name ) {
242 + $this->settings[ $name ] = null;
248 243
249 - }//end __unset()
244 + }//end __unset()
250 245
251 246
252 - /**
253 - * Get the array of all config settings.
254 - *
255 - * @return array<string, mixed>
256 - */
257 - public function getSettings()
258 - {
259 - return $this->settings;
247 + /**
248 + * Get the array of all config settings.
249 + *
250 + * @return array<string, mixed>
251 + */
252 + public function getSettings() {
253 + return $this->settings;
260 254
261 - }//end getSettings()
255 + }//end getSettings()
262 256
263 257
264 - /**
265 - * Set the array of all config settings.
266 - *
267 - * @param array<string, mixed> $settings The array of config settings.
268 - *
269 - * @return void
270 - */
271 - public function setSettings($settings)
272 - {
273 - return $this->settings = $settings;
258 + /**
259 + * Set the array of all config settings.
260 + *
261 + * @param array<string, mixed> $settings The array of config settings.
262 + *
263 + * @return void
264 + */
265 + public function setSettings( $settings ) {
266 + return $this->settings = $settings;
274 267
275 - }//end setSettings()
268 + }//end setSettings()
276 269
277 270
278 - /**
279 - * Creates a Config object and populates it with command line values.
280 - *
281 - * @param array $cliArgs An array of values gathered from CLI args.
282 - * @param bool $dieOnUnknownArg Whether or not to kill the process when an
283 - * unknown command line arg is found.
284 - *
285 - * @return void
286 - */
287 - public function __construct(array $cliArgs=[], $dieOnUnknownArg=true)
288 - {
289 - if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
290 - // Let everything through during testing so that we can
291 - // make use of PHPUnit command line arguments as well.
292 - $this->dieOnUnknownArg = false;
293 - } else {
294 - $this->dieOnUnknownArg = $dieOnUnknownArg;
295 - }
271 + /**
272 + * Creates a Config object and populates it with command line values.
273 + *
274 + * @param array $cliArgs An array of values gathered from CLI args.
275 + * @param bool $dieOnUnknownArg Whether or not to kill the process when an
276 + * unknown command line arg is found.
277 + *
278 + * @return void
279 + */
280 + public function __construct( array $cliArgs = [], $dieOnUnknownArg = true ) {
281 + if ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) === true ) {
282 + // Let everything through during testing so that we can
283 + // make use of PHPUnit command line arguments as well.
284 + $this->dieOnUnknownArg = false;
285 + } else {
286 + $this->dieOnUnknownArg = $dieOnUnknownArg;
287 + }
296 288
297 - if (empty($cliArgs) === true) {
298 - $cliArgs = $_SERVER['argv'];
299 - array_shift($cliArgs);
300 - }
289 + if ( empty( $cliArgs ) === true ) {
290 + $cliArgs = $_SERVER['argv'];
291 + array_shift( $cliArgs );
292 + }
301 293
302 - $this->restoreDefaults();
303 - $this->setCommandLineValues($cliArgs);
294 + $this->restoreDefaults();
295 + $this->setCommandLineValues( $cliArgs );
304 296
305 - if (isset(self::$overriddenDefaults['standards']) === false) {
306 - // They did not supply a standard to use.
307 - // Look for a default ruleset in the current directory or higher.
308 - $currentDir = getcwd();
297 + if ( isset( self::$overriddenDefaults['standards'] ) === false ) {
298 + // They did not supply a standard to use.
299 + // Look for a default ruleset in the current directory or higher.
300 + $currentDir = getcwd();
309 301
310 - $defaultFiles = [
311 - '.phpcs.xml',
312 - 'phpcs.xml',
313 - '.phpcs.xml.dist',
314 - 'phpcs.xml.dist',
315 - ];
302 + $defaultFiles = [
303 + '.phpcs.xml',
304 + 'phpcs.xml',
305 + '.phpcs.xml.dist',
306 + 'phpcs.xml.dist',
307 + ];
316 308
317 - do {
318 - foreach ($defaultFiles as $defaultFilename) {
319 - $default = $currentDir.DIRECTORY_SEPARATOR.$defaultFilename;
320 - if (is_file($default) === true) {
321 - $this->standards = [$default];
322 - break(2);
323 - }
324 - }
309 + do {
310 + foreach ( $defaultFiles as $defaultFilename ) {
311 + $default = $currentDir . DIRECTORY_SEPARATOR . $defaultFilename;
312 + if ( is_file( $default ) === true ) {
313 + $this->standards = [ $default ];
314 + break( 2 );
315 + }
316 + }
325 317
326 - $lastDir = $currentDir;
327 - $currentDir = dirname($currentDir);
328 - } while ($currentDir !== '.' && $currentDir !== $lastDir && @is_readable($currentDir) === true);
329 - }//end if
318 + $lastDir = $currentDir;
319 + $currentDir = dirname( $currentDir );
320 + } while ( $currentDir !== '.' && $currentDir !== $lastDir && @is_readable( $currentDir ) === true );
321 + }//end if
330 322
331 - if (defined('STDIN') === false
332 - || strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'
333 - ) {
334 - return;
335 - }
323 + if ( defined( 'STDIN' ) === false
324 + || strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN'
325 + ) {
326 + return;
327 + }
336 328
337 - $handle = fopen('php://stdin', 'r');
329 + $handle = fopen( 'php://stdin', 'r' );
338 330
339 - fclose($handle);
331 + fclose( $handle );
340 332
341 - }//end __construct()
333 + }//end __construct()
342 334
343 335
344 - /**
345 - * Set the command line values.
346 - *
347 - * @param array $args An array of command line arguments to set.
348 - *
349 - * @return void
350 - */
351 - public function setCommandLineValues($args)
352 - {
353 - $this->cliArgs = $args;
354 - $numArgs = count($args);
336 + /**
337 + * Set the command line values.
338 + *
339 + * @param array $args An array of command line arguments to set.
340 + *
341 + * @return void
342 + */
343 + public function setCommandLineValues( $args ) {
344 + $this->cliArgs = $args;
345 + $numArgs = count( $args );
355 346
356 - for ($i = 0; $i < $numArgs; $i++) {
357 - $arg = $this->cliArgs[$i];
358 - if ($arg === '') {
359 - continue;
360 - }
347 + for ( $i = 0; $i < $numArgs; $i ++ ) {
348 + $arg = $this->cliArgs[ $i ];
349 + if ( $arg === '' ) {
350 + continue;
351 + }
361 352
362 - if ($arg[0] === '-') {
363 - if ($arg === '-') {
364 - // Asking to read from STDIN.
365 - $this->stdin = true;
366 - self::$overriddenDefaults['stdin'] = true;
367 - continue;
368 - }
353 + if ( $arg[0] === '-' ) {
354 + if ( $arg === '-' ) {
355 + // Asking to read from STDIN.
356 + $this->stdin = true;
357 + self::$overriddenDefaults['stdin'] = true;
358 + continue;
359 + }
369 360
370 - if ($arg === '--') {
371 - // Empty argument, ignore it.
372 - continue;
373 - }
361 + if ( $arg === '--' ) {
362 + // Empty argument, ignore it.
363 + continue;
364 + }
374 365
375 - if ($arg[1] === '-') {
376 - $this->processLongArgument(substr($arg, 2), $i);
377 - } else {
378 - $switches = str_split($arg);
379 - foreach ($switches as $switch) {
380 - if ($switch === '-') {
381 - continue;
382 - }
366 + if ( $arg[1] === '-' ) {
367 + $this->processLongArgument( substr( $arg, 2 ), $i );
368 + } else {
369 + $switches = str_split( $arg );
370 + foreach ( $switches as $switch ) {
371 + if ( $switch === '-' ) {
372 + continue;
373 + }
383 374
384 - $this->processShortArgument($switch, $i);
385 - }
386 - }
387 - } else {
388 - $this->processUnknownArgument($arg, $i);
389 - }//end if
390 - }//end for
375 + $this->processShortArgument( $switch, $i );
376 + }
377 + }
378 + } else {
379 + $this->processUnknownArgument( $arg, $i );
380 + }//end if
381 + }//end for
391 382
392 - }//end setCommandLineValues()
383 + }//end setCommandLineValues()
393 384
394 385
395 - /**
396 - * Restore default values for all possible command line arguments.
397 - *
398 - * @return array
399 - */
400 - public function restoreDefaults()
401 - {
402 - $this->files = [];
403 - $this->standards = ['PEAR'];
404 - $this->verbosity = 0;
405 - $this->interactive = false;
406 - $this->cache = false;
407 - $this->cacheFile = null;
408 - $this->colors = false;
409 - $this->explain = false;
410 - $this->local = false;
411 - $this->showSources = false;
412 - $this->showProgress = false;
413 - $this->quiet = false;
414 - $this->annotations = true;
415 - $this->parallel = 1;
416 - $this->tabWidth = 0;
417 - $this->encoding = 'utf-8';
418 - $this->extensions = [
419 - 'php' => 'PHP',
420 - 'inc' => 'PHP',
421 - 'js' => 'JS',
422 - 'css' => 'CSS',
423 - ];
424 - $this->sniffs = [];
425 - $this->exclude = [];
426 - $this->ignored = [];
427 - $this->reportFile = null;
428 - $this->generator = null;
429 - $this->filter = null;
430 - $this->bootstrap = [];
431 - $this->basepath = null;
432 - $this->reports = ['full' => null];
433 - $this->reportWidth = 'auto';
434 - $this->errorSeverity = 5;
435 - $this->warningSeverity = 5;
436 - $this->recordErrors = true;
437 - $this->suffix = '';
438 - $this->stdin = false;
439 - $this->stdinContent = null;
440 - $this->stdinPath = null;
441 - $this->unknown = [];
386 + /**
387 + * Restore default values for all possible command line arguments.
388 + *
389 + * @return array
390 + */
391 + public function restoreDefaults() {
392 + $this->files = [];
393 + $this->standards = [ 'PEAR' ];
394 + $this->verbosity = 0;
395 + $this->interactive = false;
396 + $this->cache = false;
397 + $this->cacheFile = null;
398 + $this->colors = false;
399 + $this->explain = false;
400 + $this->local = false;
401 + $this->showSources = false;
402 + $this->showProgress = false;
403 + $this->quiet = false;
404 + $this->annotations = true;
405 + $this->parallel = 1;
406 + $this->tabWidth = 0;
407 + $this->encoding = 'utf-8';
408 + $this->extensions = [
409 + 'php' => 'PHP',
410 + 'inc' => 'PHP',
411 + 'js' => 'JS',
412 + 'css' => 'CSS',
413 + ];
414 + $this->sniffs = [];
415 + $this->exclude = [];
416 + $this->ignored = [];
417 + $this->reportFile = null;
418 + $this->generator = null;
419 + $this->filter = null;
420 + $this->bootstrap = [];
421 + $this->basepath = null;
422 + $this->reports = [ 'full' => null ];
423 + $this->reportWidth = 'auto';
424 + $this->errorSeverity = 5;
425 + $this->warningSeverity = 5;
426 + $this->recordErrors = true;
427 + $this->suffix = '';
428 + $this->stdin = false;
429 + $this->stdinContent = null;
430 + $this->stdinPath = null;
431 + $this->unknown = [];
442 432
443 - $standard = self::getConfigData('default_standard');
444 - if ($standard !== null) {
445 - $this->standards = explode(',', $standard);
446 - }
433 + $standard = self::getConfigData( 'default_standard' );
434 + if ( $standard !== null ) {
435 + $this->standards = explode( ',', $standard );
436 + }
447 437
448 - $reportFormat = self::getConfigData('report_format');
449 - if ($reportFormat !== null) {
450 - $this->reports = [$reportFormat => null];
451 - }
438 + $reportFormat = self::getConfigData( 'report_format' );
439 + if ( $reportFormat !== null ) {
440 + $this->reports = [ $reportFormat => null ];
441 + }
452 442
453 - $tabWidth = self::getConfigData('tab_width');
454 - if ($tabWidth !== null) {
455 - $this->tabWidth = (int) $tabWidth;
456 - }
443 + $tabWidth = self::getConfigData( 'tab_width' );
444 + if ( $tabWidth !== null ) {
445 + $this->tabWidth = (int) $tabWidth;
446 + }
457 447
458 - $encoding = self::getConfigData('encoding');
459 - if ($encoding !== null) {
460 - $this->encoding = strtolower($encoding);
461 - }
448 + $encoding = self::getConfigData( 'encoding' );
449 + if ( $encoding !== null ) {
450 + $this->encoding = strtolower( $encoding );
451 + }
462 452
463 - $severity = self::getConfigData('severity');
464 - if ($severity !== null) {
465 - $this->errorSeverity = (int) $severity;
466 - $this->warningSeverity = (int) $severity;
467 - }
453 + $severity = self::getConfigData( 'severity' );
454 + if ( $severity !== null ) {
455 + $this->errorSeverity = (int) $severity;
456 + $this->warningSeverity = (int) $severity;
457 + }
468 458
469 - $severity = self::getConfigData('error_severity');
470 - if ($severity !== null) {
471 - $this->errorSeverity = (int) $severity;
472 - }
459 + $severity = self::getConfigData( 'error_severity' );
460 + if ( $severity !== null ) {
461 + $this->errorSeverity = (int) $severity;
462 + }
473 463
474 - $severity = self::getConfigData('warning_severity');
475 - if ($severity !== null) {
476 - $this->warningSeverity = (int) $severity;
477 - }
464 + $severity = self::getConfigData( 'warning_severity' );
465 + if ( $severity !== null ) {
466 + $this->warningSeverity = (int) $severity;
467 + }
478 468
479 - $showWarnings = self::getConfigData('show_warnings');
480 - if ($showWarnings !== null) {
481 - $showWarnings = (bool) $showWarnings;
482 - if ($showWarnings === false) {
483 - $this->warningSeverity = 0;
484 - }
485 - }
469 + $showWarnings = self::getConfigData( 'show_warnings' );
470 + if ( $showWarnings !== null ) {
471 + $showWarnings = (bool) $showWarnings;
472 + if ( $showWarnings === false ) {
473 + $this->warningSeverity = 0;
474 + }
475 + }
486 476
487 - $reportWidth = self::getConfigData('report_width');
488 - if ($reportWidth !== null) {
489 - $this->reportWidth = $reportWidth;
490 - }
477 + $reportWidth = self::getConfigData( 'report_width' );
478 + if ( $reportWidth !== null ) {
479 + $this->reportWidth = $reportWidth;
480 + }
491 481
492 - $showProgress = self::getConfigData('show_progress');
493 - if ($showProgress !== null) {
494 - $this->showProgress = (bool) $showProgress;
495 - }
482 + $showProgress = self::getConfigData( 'show_progress' );
483 + if ( $showProgress !== null ) {
484 + $this->showProgress = (bool) $showProgress;
485 + }
496 486
497 - $quiet = self::getConfigData('quiet');
498 - if ($quiet !== null) {
499 - $this->quiet = (bool) $quiet;
500 - }
487 + $quiet = self::getConfigData( 'quiet' );
488 + if ( $quiet !== null ) {
489 + $this->quiet = (bool) $quiet;
490 + }
501 491
502 - $colors = self::getConfigData('colors');
503 - if ($colors !== null) {
504 - $this->colors = (bool) $colors;
505 - }
492 + $colors = self::getConfigData( 'colors' );
493 + if ( $colors !== null ) {
494 + $this->colors = (bool) $colors;
495 + }
506 496
507 - if (defined('PHP_CODESNIFFER_IN_TESTS') === false) {
508 - $cache = self::getConfigData('cache');
509 - if ($cache !== null) {
510 - $this->cache = (bool) $cache;
511 - }
497 + if ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) === false ) {
498 + $cache = self::getConfigData( 'cache' );
499 + if ( $cache !== null ) {
500 + $this->cache = (bool) $cache;
501 + }
512 502
513 - $parallel = self::getConfigData('parallel');
514 - if ($parallel !== null) {
515 - $this->parallel = max((int) $parallel, 1);
516 - }
517 - }
503 + $parallel = self::getConfigData( 'parallel' );
504 + if ( $parallel !== null ) {
505 + $this->parallel = max( (int) $parallel, 1 );
506 + }
507 + }
518 508
519 - }//end restoreDefaults()
509 + }//end restoreDefaults()
520 510
521 511
522 - /**
523 - * Processes a short (-e) command line argument.
524 - *
525 - * @param string $arg The command line argument.
526 - * @param int $pos The position of the argument on the command line.
527 - *
528 - * @return void
529 - * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
530 - */
531 - public function processShortArgument($arg, $pos)
532 - {
533 - switch ($arg) {
534 - case 'h':
535 - case '?':
536 - ob_start();
537 - $this->printUsage();
538 - $output = ob_get_contents();
539 - ob_end_clean();
540 - throw new DeepExitException($output, 0);
541 - case 'i' :
542 - ob_start();
543 - Util\Standards::printInstalledStandards();
544 - $output = ob_get_contents();
545 - ob_end_clean();
546 - throw new DeepExitException($output, 0);
547 - case 'v' :
548 - if ($this->quiet === true) {
549 - // Ignore when quiet mode is enabled.
550 - break;
551 - }
512 + /**
513 + * Processes a short (-e) command line argument.
514 + *
515 + * @param string $arg The command line argument.
516 + * @param int $pos The position of the argument on the command line.
517 + *
518 + * @return void
519 + * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
520 + */
521 + public function processShortArgument( $arg, $pos ) {
522 + switch ( $arg ) {
523 + case 'h':
524 + case '?':
525 + ob_start();
526 + $this->printUsage();
527 + $output = ob_get_contents();
528 + ob_end_clean();
529 + throw new DeepExitException( $output, 0 );
530 + case 'i' :
531 + ob_start();
532 + Util\Standards::printInstalledStandards();
533 + $output = ob_get_contents();
534 + ob_end_clean();
535 + throw new DeepExitException( $output, 0 );
536 + case 'v' :
537 + if ( $this->quiet === true ) {
538 + // Ignore when quiet mode is enabled.
539 + break;
540 + }
552 541
553 - $this->verbosity++;
554 - self::$overriddenDefaults['verbosity'] = true;
555 - break;
556 - case 'l' :
557 - $this->local = true;
558 - self::$overriddenDefaults['local'] = true;
559 - break;
560 - case 's' :
561 - $this->showSources = true;
562 - self::$overriddenDefaults['showSources'] = true;
563 - break;
564 - case 'a' :
565 - $this->interactive = true;
566 - self::$overriddenDefaults['interactive'] = true;
567 - break;
568 - case 'e':
569 - $this->explain = true;
570 - self::$overriddenDefaults['explain'] = true;
571 - break;
572 - case 'p' :
573 - if ($this->quiet === true) {
574 - // Ignore when quiet mode is enabled.
575 - break;
576 - }
542 + $this->verbosity ++;
543 + self::$overriddenDefaults['verbosity'] = true;
544 + break;
545 + case 'l' :
546 + $this->local = true;
547 + self::$overriddenDefaults['local'] = true;
548 + break;
549 + case 's' :
550 + $this->showSources = true;
551 + self::$overriddenDefaults['showSources'] = true;
552 + break;
553 + case 'a' :
554 + $this->interactive = true;
555 + self::$overriddenDefaults['interactive'] = true;
556 + break;
557 + case 'e':
558 + $this->explain = true;
559 + self::$overriddenDefaults['explain'] = true;
560 + break;
561 + case 'p' :
562 + if ( $this->quiet === true ) {
563 + // Ignore when quiet mode is enabled.
564 + break;
565 + }
577 566
578 - $this->showProgress = true;
579 - self::$overriddenDefaults['showProgress'] = true;
580 - break;
581 - case 'q' :
582 - // Quiet mode disables a few other settings as well.
583 - $this->quiet = true;
584 - $this->showProgress = false;
585 - $this->verbosity = 0;
567 + $this->showProgress = true;
568 + self::$overriddenDefaults['showProgress'] = true;
569 + break;
570 + case 'q' :
571 + // Quiet mode disables a few other settings as well.
572 + $this->quiet = true;
573 + $this->showProgress = false;
574 + $this->verbosity = 0;
586 575
587 - self::$overriddenDefaults['quiet'] = true;
588 - break;
589 - case 'm' :
590 - $this->recordErrors = false;
591 - self::$overriddenDefaults['recordErrors'] = true;
592 - break;
593 - case 'd' :
594 - $ini = explode('=', $this->cliArgs[($pos + 1)]);
595 - $this->cliArgs[($pos + 1)] = '';
596 - if (isset($ini[1]) === true) {
597 - ini_set($ini[0], $ini[1]);
598 - } else {
599 - ini_set($ini[0], true);
600 - }
601 - break;
602 - case 'n' :
603 - if (isset(self::$overriddenDefaults['warningSeverity']) === false) {
604 - $this->warningSeverity = 0;
605 - self::$overriddenDefaults['warningSeverity'] = true;
606 - }
607 - break;
608 - case 'w' :
609 - if (isset(self::$overriddenDefaults['warningSeverity']) === false) {
610 - $this->warningSeverity = $this->errorSeverity;
611 - self::$overriddenDefaults['warningSeverity'] = true;
612 - }
613 - break;
614 - default:
615 - if ($this->dieOnUnknownArg === false) {
616 - $unknown = $this->unknown;
617 - $unknown[] = $arg;
618 - $this->unknown = $unknown;
619 - } else {
620 - $this->processUnknownArgument('-'.$arg, $pos);
621 - }
622 - }//end switch
576 + self::$overriddenDefaults['quiet'] = true;
577 + break;
578 + case 'm' :
579 + $this->recordErrors = false;
580 + self::$overriddenDefaults['recordErrors'] = true;
581 + break;
582 + case 'd' :
583 + $ini = explode( '=', $this->cliArgs[ ( $pos + 1 ) ] );
584 + $this->cliArgs[ ( $pos + 1 ) ] = '';
585 + if ( isset( $ini[1] ) === true ) {
586 + ini_set( $ini[0], $ini[1] );
587 + } else {
588 + ini_set( $ini[0], true );
589 + }
590 + break;
591 + case 'n' :
592 + if ( isset( self::$overriddenDefaults['warningSeverity'] ) === false ) {
593 + $this->warningSeverity = 0;
594 + self::$overriddenDefaults['warningSeverity'] = true;
595 + }
596 + break;
597 + case 'w' :
598 + if ( isset( self::$overriddenDefaults['warningSeverity'] ) === false ) {
599 + $this->warningSeverity = $this->errorSeverity;
600 + self::$overriddenDefaults['warningSeverity'] = true;
601 + }
602 + break;
603 + default:
604 + if ( $this->dieOnUnknownArg === false ) {
605 + $unknown = $this->unknown;
606 + $unknown[] = $arg;
607 + $this->unknown = $unknown;
608 + } else {
609 + $this->processUnknownArgument( '-' . $arg, $pos );
610 + }
611 + }//end switch
623 612
624 - }//end processShortArgument()
613 + }//end processShortArgument()
625 614
626 615
627 - /**
628 - * Processes a long (--example) command line argument.
629 - *
630 - * @param string $arg The command line argument.
631 - * @param int $pos The position of the argument on the command line.
632 - *
633 - * @return void
634 - * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
635 - */
636 - public function processLongArgument($arg, $pos)
637 - {
638 - switch ($arg) {
639 - case 'help':
640 - ob_start();
641 - $this->printUsage();
642 - $output = ob_get_contents();
643 - ob_end_clean();
644 - throw new DeepExitException($output, 0);
645 - case 'version':
646 - $output = 'PHP_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') ';
647 - $output .= 'by Squiz (http://www.squiz.net)'.PHP_EOL;
648 - throw new DeepExitException($output, 0);
649 - case 'colors':
650 - if (isset(self::$overriddenDefaults['colors']) === true) {
651 - break;
652 - }
616 + /**
617 + * Processes a long (--example) command line argument.
618 + *
619 + * @param string $arg The command line argument.
620 + * @param int $pos The position of the argument on the command line.
621 + *
622 + * @return void
623 + * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
624 + */
625 + public function processLongArgument( $arg, $pos ) {
626 + switch ( $arg ) {
627 + case 'help':
628 + ob_start();
629 + $this->printUsage();
630 + $output = ob_get_contents();
631 + ob_end_clean();
632 + throw new DeepExitException( $output, 0 );
633 + case 'version':
634 + $output = 'PHP_CodeSniffer version ' . self::VERSION . ' (' . self::STABILITY . ') ';
635 + $output .= 'by Squiz (http://www.squiz.net)' . PHP_EOL;
636 + throw new DeepExitException( $output, 0 );
637 + case 'colors':
638 + if ( isset( self::$overriddenDefaults['colors'] ) === true ) {
639 + break;
640 + }
653 641
654 - $this->colors = true;
655 - self::$overriddenDefaults['colors'] = true;
656 - break;
657 - case 'no-colors':
658 - if (isset(self::$overriddenDefaults['colors']) === true) {
659 - break;
660 - }
642 + $this->colors = true;
643 + self::$overriddenDefaults['colors'] = true;
644 + break;
645 + case 'no-colors':
646 + if ( isset( self::$overriddenDefaults['colors'] ) === true ) {
647 + break;
648 + }
661 649
662 - $this->colors = false;
663 - self::$overriddenDefaults['colors'] = true;
664 - break;
665 - case 'cache':
666 - if (isset(self::$overriddenDefaults['cache']) === true) {
667 - break;
668 - }
650 + $this->colors = false;
651 + self::$overriddenDefaults['colors'] = true;
652 + break;
653 + case 'cache':
654 + if ( isset( self::$overriddenDefaults['cache'] ) === true ) {
655 + break;
656 + }
669 657
670 - if (defined('PHP_CODESNIFFER_IN_TESTS') === false) {
671 - $this->cache = true;
672 - self::$overriddenDefaults['cache'] = true;
673 - }
674 - break;
675 - case 'no-cache':
676 - if (isset(self::$overriddenDefaults['cache']) === true) {
677 - break;
678 - }
658 + if ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) === false ) {
659 + $this->cache = true;
660 + self::$overriddenDefaults['cache'] = true;
661 + }
662 + break;
663 + case 'no-cache':
664 + if ( isset( self::$overriddenDefaults['cache'] ) === true ) {
665 + break;
666 + }
679 667
680 - $this->cache = false;
681 - self::$overriddenDefaults['cache'] = true;
682 - break;
683 - case 'ignore-annotations':
684 - if (isset(self::$overriddenDefaults['annotations']) === true) {
685 - break;
686 - }
668 + $this->cache = false;
669 + self::$overriddenDefaults['cache'] = true;
670 + break;
671 + case 'ignore-annotations':
672 + if ( isset( self::$overriddenDefaults['annotations'] ) === true ) {
673 + break;
674 + }
687 675
688 - $this->annotations = false;
689 - self::$overriddenDefaults['annotations'] = true;
690 - break;
691 - case 'config-set':
692 - if (isset($this->cliArgs[($pos + 1)]) === false
693 - || isset($this->cliArgs[($pos + 2)]) === false
694 - ) {
695 - $error = 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL;
696 - $error .= $this->printShortUsage(true);
697 - throw new DeepExitException($error, 3);
698 - }
676 + $this->annotations = false;
677 + self::$overriddenDefaults['annotations'] = true;
678 + break;
679 + case 'config-set':
680 + if ( isset( $this->cliArgs[ ( $pos + 1 ) ] ) === false
681 + || isset( $this->cliArgs[ ( $pos + 2 ) ] ) === false
682 + ) {
683 + $error = 'ERROR: Setting a config option requires a name and value' . PHP_EOL . PHP_EOL;
684 + $error .= $this->printShortUsage( true );
685 + throw new DeepExitException( $error, 3 );
686 + }
699 687
700 - $key = $this->cliArgs[($pos + 1)];
701 - $value = $this->cliArgs[($pos + 2)];
702 - $current = self::getConfigData($key);
688 + $key = $this->cliArgs[ ( $pos + 1 ) ];
689 + $value = $this->cliArgs[ ( $pos + 2 ) ];
690 + $current = self::getConfigData( $key );
703 691
704 - try {
705 - $this->setConfigData($key, $value);
706 - } catch (\Exception $e) {
707 - throw new DeepExitException($e->getMessage().PHP_EOL, 3);
708 - }
692 + try {
693 + $this->setConfigData( $key, $value );
694 + } catch ( \Exception $e ) {
695 + throw new DeepExitException( $e->getMessage() . PHP_EOL, 3 );
696 + }
709 697
710 - $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL;
698 + $output = 'Using config file: ' . self::$configDataFile . PHP_EOL . PHP_EOL;
711 699
712 - if ($current === null) {
713 - $output .= "Config value \"$key\" added successfully".PHP_EOL;
714 - } else {
715 - $output .= "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL;
716 - }
717 - throw new DeepExitException($output, 0);
718 - case 'config-delete':
719 - if (isset($this->cliArgs[($pos + 1)]) === false) {
720 - $error = 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL;
721 - $error .= $this->printShortUsage(true);
722 - throw new DeepExitException($error, 3);
723 - }
700 + if ( $current === null ) {
701 + $output .= "Config value \"$key\" added successfully" . PHP_EOL;
702 + } else {
703 + $output .= "Config value \"$key\" updated successfully; old value was \"$current\"" . PHP_EOL;
704 + }
705 + throw new DeepExitException( $output, 0 );
706 + case 'config-delete':
707 + if ( isset( $this->cliArgs[ ( $pos + 1 ) ] ) === false ) {
708 + $error = 'ERROR: Deleting a config option requires the name of the option' . PHP_EOL . PHP_EOL;
709 + $error .= $this->printShortUsage( true );
710 + throw new DeepExitException( $error, 3 );
711 + }
724 712
725 - $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL;
713 + $output = 'Using config file: ' . self::$configDataFile . PHP_EOL . PHP_EOL;
726 714
727 - $key = $this->cliArgs[($pos + 1)];
728 - $current = self::getConfigData($key);
729 - if ($current === null) {
730 - $output .= "Config value \"$key\" has not been set".PHP_EOL;
731 - } else {
732 - try {
733 - $this->setConfigData($key, null);
734 - } catch (\Exception $e) {
735 - throw new DeepExitException($e->getMessage().PHP_EOL, 3);
736 - }
715 + $key = $this->cliArgs[ ( $pos + 1 ) ];
716 + $current = self::getConfigData( $key );
717 + if ( $current === null ) {
718 + $output .= "Config value \"$key\" has not been set" . PHP_EOL;
719 + } else {
720 + try {
721 + $this->setConfigData( $key, null );
722 + } catch ( \Exception $e ) {
723 + throw new DeepExitException( $e->getMessage() . PHP_EOL, 3 );
724 + }
737 725
738 - $output .= "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL;
739 - }
740 - throw new DeepExitException($output, 0);
741 - case 'config-show':
742 - ob_start();
743 - $data = self::getAllConfigData();
744 - echo 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL;
745 - $this->printConfigData($data);
746 - $output = ob_get_contents();
747 - ob_end_clean();
748 - throw new DeepExitException($output, 0);
749 - case 'runtime-set':
750 - if (isset($this->cliArgs[($pos + 1)]) === false
751 - || isset($this->cliArgs[($pos + 2)]) === false
752 - ) {
753 - $error = 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL;
754 - $error .= $this->printShortUsage(true);
755 - throw new DeepExitException($error, 3);
756 - }
726 + $output .= "Config value \"$key\" removed successfully; old value was \"$current\"" . PHP_EOL;
727 + }
728 + throw new DeepExitException( $output, 0 );
729 + case 'config-show':
730 + ob_start();
731 + $data = self::getAllConfigData();
732 + echo 'Using config file: ' . self::$configDataFile . PHP_EOL . PHP_EOL;
733 + $this->printConfigData( $data );
734 + $output = ob_get_contents();
735 + ob_end_clean();
736 + throw new DeepExitException( $output, 0 );
737 + case 'runtime-set':
738 + if ( isset( $this->cliArgs[ ( $pos + 1 ) ] ) === false
739 + || isset( $this->cliArgs[ ( $pos + 2 ) ] ) === false
740 + ) {
741 + $error = 'ERROR: Setting a runtime config option requires a name and value' . PHP_EOL . PHP_EOL;
742 + $error .= $this->printShortUsage( true );
743 + throw new DeepExitException( $error, 3 );
744 + }
757 745
758 - $key = $this->cliArgs[($pos + 1)];
759 - $value = $this->cliArgs[($pos + 2)];
760 - $this->cliArgs[($pos + 1)] = '';
761 - $this->cliArgs[($pos + 2)] = '';
762 - self::setConfigData($key, $value, true);
763 - if (isset(self::$overriddenDefaults['runtime-set']) === false) {
764 - self::$overriddenDefaults['runtime-set'] = [];
765 - }
746 + $key = $this->cliArgs[ ( $pos + 1 ) ];
747 + $value = $this->cliArgs[ ( $pos + 2 ) ];
748 + $this->cliArgs[ ( $pos + 1 ) ] = '';
749 + $this->cliArgs[ ( $pos + 2 ) ] = '';
750 + self::setConfigData( $key, $value, true );
751 + if ( isset( self::$overriddenDefaults['runtime-set'] ) === false ) {
752 + self::$overriddenDefaults['runtime-set'] = [];
753 + }
766 754
767 - self::$overriddenDefaults['runtime-set'][$key] = true;
768 - break;
769 - default:
770 - if (substr($arg, 0, 7) === 'sniffs=') {
771 - if (isset(self::$overriddenDefaults['sniffs']) === true) {
772 - break;
773 - }
755 + self::$overriddenDefaults['runtime-set'][ $key ] = true;
756 + break;
757 + default:
758 + if ( substr( $arg, 0, 7 ) === 'sniffs=' ) {
759 + if ( isset( self::$overriddenDefaults['sniffs'] ) === true ) {
760 + break;
761 + }
774 762
775 - $sniffs = explode(',', substr($arg, 7));
776 - foreach ($sniffs as $sniff) {
777 - if (substr_count($sniff, '.') !== 2) {
778 - $error = 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
779 - $error .= $this->printShortUsage(true);
780 - throw new DeepExitException($error, 3);
781 - }
782 - }
763 + $sniffs = explode( ',', substr( $arg, 7 ) );
764 + foreach ( $sniffs as $sniff ) {
765 + if ( substr_count( $sniff, '.' ) !== 2 ) {
766 + $error = 'ERROR: The specified sniff code "' . $sniff . '" is invalid' . PHP_EOL . PHP_EOL;
767 + $error .= $this->printShortUsage( true );
768 + throw new DeepExitException( $error, 3 );
769 + }
770 + }
783 771
784 - $this->sniffs = $sniffs;
785 - self::$overriddenDefaults['sniffs'] = true;
786 - } else if (substr($arg, 0, 8) === 'exclude=') {
787 - if (isset(self::$overriddenDefaults['exclude']) === true) {
788 - break;
789 - }
772 + $this->sniffs = $sniffs;
773 + self::$overriddenDefaults['sniffs'] = true;
774 + } else if ( substr( $arg, 0, 8 ) === 'exclude=' ) {
775 + if ( isset( self::$overriddenDefaults['exclude'] ) === true ) {
776 + break;
777 + }
790 778
791 - $sniffs = explode(',', substr($arg, 8));
792 - foreach ($sniffs as $sniff) {
793 - if (substr_count($sniff, '.') !== 2) {
794 - $error = 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
795 - $error .= $this->printShortUsage(true);
796 - throw new DeepExitException($error, 3);
797 - }
798 - }
779 + $sniffs = explode( ',', substr( $arg, 8 ) );
780 + foreach ( $sniffs as $sniff ) {
781 + if ( substr_count( $sniff, '.' ) !== 2 ) {
782 + $error = 'ERROR: The specified sniff code "' . $sniff . '" is invalid' . PHP_EOL . PHP_EOL;
783 + $error .= $this->printShortUsage( true );
784 + throw new DeepExitException( $error, 3 );
785 + }
786 + }
799 787
800 - $this->exclude = $sniffs;
801 - self::$overriddenDefaults['exclude'] = true;
802 - } else if (defined('PHP_CODESNIFFER_IN_TESTS') === false
803 - && substr($arg, 0, 6) === 'cache='
804 - ) {
805 - if ((isset(self::$overriddenDefaults['cache']) === true
806 - && $this->cache === false)
807 - || isset(self::$overriddenDefaults['cacheFile']) === true
808 - ) {
809 - break;
810 - }
788 + $this->exclude = $sniffs;
789 + self::$overriddenDefaults['exclude'] = true;
790 + } else if ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) === false
791 + && substr( $arg, 0, 6 ) === 'cache='
792 + ) {
793 + if ( ( isset( self::$overriddenDefaults['cache'] ) === true
794 + && $this->cache === false )
795 + || isset( self::$overriddenDefaults['cacheFile'] ) === true
796 + ) {
797 + break;
798 + }
811 799
812 - // Turn caching on.
813 - $this->cache = true;
814 - self::$overriddenDefaults['cache'] = true;
800 + // Turn caching on.
801 + $this->cache = true;
802 + self::$overriddenDefaults['cache'] = true;
815 803
816 - $this->cacheFile = Util\Common::realpath(substr($arg, 6));
804 + $this->cacheFile = Util\Common::realpath( substr( $arg, 6 ) );
817 805
818 - // It may not exist and return false instead.
819 - if ($this->cacheFile === false) {
820 - $this->cacheFile = substr($arg, 6);
806 + // It may not exist and return false instead.
807 + if ( $this->cacheFile === false ) {
808 + $this->cacheFile = substr( $arg, 6 );
821 809
822 - $dir = dirname($this->cacheFile);
823 - if (is_dir($dir) === false) {
824 - $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
825 - $error .= $this->printShortUsage(true);
826 - throw new DeepExitException($error, 3);
827 - }
810 + $dir = dirname( $this->cacheFile );
811 + if ( is_dir( $dir ) === false ) {
812 + $error = 'ERROR: The specified cache file path "' . $this->cacheFile . '" points to a non-existent directory' . PHP_EOL . PHP_EOL;
813 + $error .= $this->printShortUsage( true );
814 + throw new DeepExitException( $error, 3 );
815 + }
828 816
829 - if ($dir === '.') {
830 - // Passed cache file is a file in the current directory.
831 - $this->cacheFile = getcwd().'/'.basename($this->cacheFile);
832 - } else {
833 - if ($dir[0] === '/') {
834 - // An absolute path.
835 - $dir = Util\Common::realpath($dir);
836 - } else {
837 - $dir = Util\Common::realpath(getcwd().'/'.$dir);
838 - }
817 + if ( $dir === '.' ) {
818 + // Passed cache file is a file in the current directory.
819 + $this->cacheFile = getcwd() . '/' . basename( $this->cacheFile );
820 + } else {
821 + if ( $dir[0] === '/' ) {
822 + // An absolute path.
823 + $dir = Util\Common::realpath( $dir );
824 + } else {
825 + $dir = Util\Common::realpath( getcwd() . '/' . $dir );
826 + }
839 827
840 - if ($dir !== false) {
841 - // Cache file path is relative.
842 - $this->cacheFile = $dir.'/'.basename($this->cacheFile);
843 - }
844 - }
845 - }//end if
828 + if ( $dir !== false ) {
829 + // Cache file path is relative.
830 + $this->cacheFile = $dir . '/' . basename( $this->cacheFile );
831 + }
832 + }
833 + }//end if
846 834
847 - self::$overriddenDefaults['cacheFile'] = true;
835 + self::$overriddenDefaults['cacheFile'] = true;
848 836
849 - if (is_dir($this->cacheFile) === true) {
850 - $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" is a directory'.PHP_EOL.PHP_EOL;
851 - $error .= $this->printShortUsage(true);
852 - throw new DeepExitException($error, 3);
853 - }
854 - } else if (substr($arg, 0, 10) === 'bootstrap=') {
855 - $files = explode(',', substr($arg, 10));
856 - $bootstrap = [];
857 - foreach ($files as $file) {
858 - $path = Util\Common::realpath($file);
859 - if ($path === false) {
860 - $error = 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
861 - $error .= $this->printShortUsage(true);
862 - throw new DeepExitException($error, 3);
863 - }
837 + if ( is_dir( $this->cacheFile ) === true ) {
838 + $error = 'ERROR: The specified cache file path "' . $this->cacheFile . '" is a directory' . PHP_EOL . PHP_EOL;
839 + $error .= $this->printShortUsage( true );
840 + throw new DeepExitException( $error, 3 );
841 + }
842 + } else if ( substr( $arg, 0, 10 ) === 'bootstrap=' ) {
843 + $files = explode( ',', substr( $arg, 10 ) );
844 + $bootstrap = [];
845 + foreach ( $files as $file ) {
846 + $path = Util\Common::realpath( $file );
847 + if ( $path === false ) {
848 + $error = 'ERROR: The specified bootstrap file "' . $file . '" does not exist' . PHP_EOL . PHP_EOL;
849 + $error .= $this->printShortUsage( true );
850 + throw new DeepExitException( $error, 3 );
851 + }
864 852
865 - $bootstrap[] = $path;
866 - }
853 + $bootstrap[] = $path;
854 + }
867 855
868 - $this->bootstrap = array_merge($this->bootstrap, $bootstrap);
869 - self::$overriddenDefaults['bootstrap'] = true;
870 - } else if (substr($arg, 0, 10) === 'file-list=') {
871 - $fileList = substr($arg, 10);
872 - $path = Util\Common::realpath($fileList);
873 - if ($path === false) {
874 - $error = 'ERROR: The specified file list "'.$fileList.'" does not exist'.PHP_EOL.PHP_EOL;
875 - $error .= $this->printShortUsage(true);
876 - throw new DeepExitException($error, 3);
877 - }
856 + $this->bootstrap = array_merge( $this->bootstrap, $bootstrap );
857 + self::$overriddenDefaults['bootstrap'] = true;
858 + } else if ( substr( $arg, 0, 10 ) === 'file-list=' ) {
859 + $fileList = substr( $arg, 10 );
860 + $path = Util\Common::realpath( $fileList );
861 + if ( $path === false ) {
862 + $error = 'ERROR: The specified file list "' . $fileList . '" does not exist' . PHP_EOL . PHP_EOL;
863 + $error .= $this->printShortUsage( true );
864 + throw new DeepExitException( $error, 3 );
865 + }
878 866
879 - $files = file($path);
880 - foreach ($files as $inputFile) {
881 - $inputFile = trim($inputFile);
867 + $files = file( $path );
868 + foreach ( $files as $inputFile ) {
869 + $inputFile = trim( $inputFile );
882 870
883 - // Skip empty lines.
884 - if ($inputFile === '') {
885 - continue;
886 - }
871 + // Skip empty lines.
872 + if ( $inputFile === '' ) {
873 + continue;
874 + }
887 875
888 - $this->processFilePath($inputFile);
889 - }
890 - } else if (substr($arg, 0, 11) === 'stdin-path=') {
891 - if (isset(self::$overriddenDefaults['stdinPath']) === true) {
892 - break;
893 - }
876 + $this->processFilePath( $inputFile );
877 + }
878 + } else if ( substr( $arg, 0, 11 ) === 'stdin-path=' ) {
879 + if ( isset( self::$overriddenDefaults['stdinPath'] ) === true ) {
880 + break;
881 + }
894 882
895 - $this->stdinPath = Util\Common::realpath(substr($arg, 11));
883 + $this->stdinPath = Util\Common::realpath( substr( $arg, 11 ) );
896 884
897 - // It may not exist and return false instead, so use whatever they gave us.
898 - if ($this->stdinPath === false) {
899 - $this->stdinPath = trim(substr($arg, 11));
900 - }
885 + // It may not exist and return false instead, so use whatever they gave us.
886 + if ( $this->stdinPath === false ) {
887 + $this->stdinPath = trim( substr( $arg, 11 ) );
888 + }
901 889
902 - self::$overriddenDefaults['stdinPath'] = true;
903 - } else if (PHP_CODESNIFFER_CBF === false && substr($arg, 0, 12) === 'report-file=') {
904 - if (isset(self::$overriddenDefaults['reportFile']) === true) {
905 - break;
906 - }
890 + self::$overriddenDefaults['stdinPath'] = true;
891 + } else if ( PHP_CODESNIFFER_CBF === false && substr( $arg, 0, 12 ) === 'report-file=' ) {
892 + if ( isset( self::$overriddenDefaults['reportFile'] ) === true ) {
893 + break;
894 + }
907 895
908 - $this->reportFile = Util\Common::realpath(substr($arg, 12));
896 + $this->reportFile = Util\Common::realpath( substr( $arg, 12 ) );
909 897
910 - // It may not exist and return false instead.
911 - if ($this->reportFile === false) {
912 - $this->reportFile = substr($arg, 12);
898 + // It may not exist and return false instead.
899 + if ( $this->reportFile === false ) {
900 + $this->reportFile = substr( $arg, 12 );
913 901
914 - $dir = Util\Common::realpath(dirname($this->reportFile));
915 - if (is_dir($dir) === false) {
916 - $error = 'ERROR: The specified report file path "'.$this->reportFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
917 - $error .= $this->printShortUsage(true);
918 - throw new DeepExitException($error, 3);
919 - }
902 + $dir = Util\Common::realpath( dirname( $this->reportFile ) );
903 + if ( is_dir( $dir ) === false ) {
904 + $error = 'ERROR: The specified report file path "' . $this->reportFile . '" points to a non-existent directory' . PHP_EOL . PHP_EOL;
905 + $error .= $this->printShortUsage( true );
906 + throw new DeepExitException( $error, 3 );
907 + }
920 908
921 - $this->reportFile = $dir.'/'.basename($this->reportFile);
922 - }//end if
909 + $this->reportFile = $dir . '/' . basename( $this->reportFile );
910 + }//end if
923 911
924 - self::$overriddenDefaults['reportFile'] = true;
912 + self::$overriddenDefaults['reportFile'] = true;
925 913
926 - if (is_dir($this->reportFile) === true) {
927 - $error = 'ERROR: The specified report file path "'.$this->reportFile.'" is a directory'.PHP_EOL.PHP_EOL;
928 - $error .= $this->printShortUsage(true);
929 - throw new DeepExitException($error, 3);
930 - }
931 - } else if (substr($arg, 0, 13) === 'report-width=') {
932 - if (isset(self::$overriddenDefaults['reportWidth']) === true) {
933 - break;
934 - }
914 + if ( is_dir( $this->reportFile ) === true ) {
915 + $error = 'ERROR: The specified report file path "' . $this->reportFile . '" is a directory' . PHP_EOL . PHP_EOL;
916 + $error .= $this->printShortUsage( true );
917 + throw new DeepExitException( $error, 3 );
918 + }
919 + } else if ( substr( $arg, 0, 13 ) === 'report-width=' ) {
920 + if ( isset( self::$overriddenDefaults['reportWidth'] ) === true ) {
921 + break;
922 + }
935 923
936 - $this->reportWidth = substr($arg, 13);
937 - self::$overriddenDefaults['reportWidth'] = true;
938 - } else if (substr($arg, 0, 9) === 'basepath=') {
939 - if (isset(self::$overriddenDefaults['basepath']) === true) {
940 - break;
941 - }
924 + $this->reportWidth = substr( $arg, 13 );
925 + self::$overriddenDefaults['reportWidth'] = true;
926 + } else if ( substr( $arg, 0, 9 ) === 'basepath=' ) {
927 + if ( isset( self::$overriddenDefaults['basepath'] ) === true ) {
928 + break;
929 + }
942 930
943 - self::$overriddenDefaults['basepath'] = true;
931 + self::$overriddenDefaults['basepath'] = true;
944 932
945 - if (substr($arg, 9) === '') {
946 - $this->basepath = null;
947 - break;
948 - }
933 + if ( substr( $arg, 9 ) === '' ) {
934 + $this->basepath = null;
935 + break;
936 + }
949 937
950 - $this->basepath = Util\Common::realpath(substr($arg, 9));
938 + $this->basepath = Util\Common::realpath( substr( $arg, 9 ) );
951 939
952 - // It may not exist and return false instead.
953 - if ($this->basepath === false) {
954 - $this->basepath = substr($arg, 9);
955 - }
940 + // It may not exist and return false instead.
941 + if ( $this->basepath === false ) {
942 + $this->basepath = substr( $arg, 9 );
943 + }
956 944
957 - if (is_dir($this->basepath) === false) {
958 - $error = 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
959 - $error .= $this->printShortUsage(true);
960 - throw new DeepExitException($error, 3);
961 - }
962 - } else if ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) {
963 - $reports = [];
945 + if ( is_dir( $this->basepath ) === false ) {
946 + $error = 'ERROR: The specified basepath "' . $this->basepath . '" points to a non-existent directory' . PHP_EOL . PHP_EOL;
947 + $error .= $this->printShortUsage( true );
948 + throw new DeepExitException( $error, 3 );
949 + }
950 + } else if ( ( substr( $arg, 0, 7 ) === 'report=' || substr( $arg, 0, 7 ) === 'report-' ) ) {
951 + $reports = [];
964 952
965 - if ($arg[6] === '-') {
966 - // This is a report with file output.
967 - $split = strpos($arg, '=');
968 - if ($split === false) {
969 - $report = substr($arg, 7);
970 - $output = null;
971 - } else {
972 - $report = substr($arg, 7, ($split - 7));
973 - $output = substr($arg, ($split + 1));
974 - if ($output === false) {
975 - $output = null;
976 - } else {
977 - $dir = Util\Common::realpath(dirname($output));
978 - if (is_dir($dir) === false) {
979 - $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
980 - $error .= $this->printShortUsage(true);
981 - throw new DeepExitException($error, 3);
982 - }
953 + if ( $arg[6] === '-' ) {
954 + // This is a report with file output.
955 + $split = strpos( $arg, '=' );
956 + if ( $split === false ) {
957 + $report = substr( $arg, 7 );
958 + $output = null;
959 + } else {
960 + $report = substr( $arg, 7, ( $split - 7 ) );
961 + $output = substr( $arg, ( $split + 1 ) );
962 + if ( $output === false ) {
963 + $output = null;
964 + } else {
965 + $dir = Util\Common::realpath( dirname( $output ) );
966 + if ( is_dir( $dir ) === false ) {
967 + $error = 'ERROR: The specified ' . $report . ' report file path "' . $output . '" points to a non-existent directory' . PHP_EOL . PHP_EOL;
968 + $error .= $this->printShortUsage( true );
969 + throw new DeepExitException( $error, 3 );
970 + }
983 971
984 - $output = $dir.'/'.basename($output);
972 + $output = $dir . '/' . basename( $output );
985 973
986 - if (is_dir($output) === true) {
987 - $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" is a directory'.PHP_EOL.PHP_EOL;
988 - $error .= $this->printShortUsage(true);
989 - throw new DeepExitException($error, 3);
990 - }
991 - }//end if
992 - }//end if
974 + if ( is_dir( $output ) === true ) {
975 + $error = 'ERROR: The specified ' . $report . ' report file path "' . $output . '" is a directory' . PHP_EOL . PHP_EOL;
976 + $error .= $this->printShortUsage( true );
977 + throw new DeepExitException( $error, 3 );
978 + }
979 + }//end if
980 + }//end if
993 981
994 - $reports[$report] = $output;
995 - } else {
996 - // This is a single report.
997 - if (isset(self::$overriddenDefaults['reports']) === true) {
998 - break;
999 - }
982 + $reports[ $report ] = $output;
983 + } else {
984 + // This is a single report.
985 + if ( isset( self::$overriddenDefaults['reports'] ) === true ) {
986 + break;
987 + }
1000 988
1001 - $reportNames = explode(',', substr($arg, 7));
1002 - foreach ($reportNames as $report) {
1003 - $reports[$report] = null;
1004 - }
1005 - }//end if
989 + $reportNames = explode( ',', substr( $arg, 7 ) );
990 + foreach ( $reportNames as $report ) {
991 + $reports[ $report ] = null;
992 + }
993 + }//end if
1006 994
1007 - // Remove the default value so the CLI value overrides it.
1008 - if (isset(self::$overriddenDefaults['reports']) === false) {
1009 - $this->reports = $reports;
1010 - } else {
1011 - $this->reports = array_merge($this->reports, $reports);
1012 - }
995 + // Remove the default value so the CLI value overrides it.
996 + if ( isset( self::$overriddenDefaults['reports'] ) === false ) {
997 + $this->reports = $reports;
998 + } else {
999 + $this->reports = array_merge( $this->reports, $reports );
1000 + }
1013 1001
1014 - self::$overriddenDefaults['reports'] = true;
1015 - } else if (substr($arg, 0, 7) === 'filter=') {
1016 - if (isset(self::$overriddenDefaults['filter']) === true) {
1017 - break;
1018 - }
1002 + self::$overriddenDefaults['reports'] = true;
1003 + } else if ( substr( $arg, 0, 7 ) === 'filter=' ) {
1004 + if ( isset( self::$overriddenDefaults['filter'] ) === true ) {
1005 + break;
1006 + }
1019 1007
1020 - $this->filter = substr($arg, 7);
1021 - self::$overriddenDefaults['filter'] = true;
1022 - } else if (substr($arg, 0, 9) === 'standard=') {
1023 - $standards = trim(substr($arg, 9));
1024 - if ($standards !== '') {
1025 - $this->standards = explode(',', $standards);
1026 - }
1008 + $this->filter = substr( $arg, 7 );
1009 + self::$overriddenDefaults['filter'] = true;
1010 + } else if ( substr( $arg, 0, 9 ) === 'standard=' ) {
1011 + $standards = trim( substr( $arg, 9 ) );
1012 + if ( $standards !== '' ) {
1013 + $this->standards = explode( ',', $standards );
1014 + }
1027 1015
1028 - self::$overriddenDefaults['standards'] = true;
1029 - } else if (substr($arg, 0, 11) === 'extensions=') {
1030 - if (isset(self::$overriddenDefaults['extensions']) === true) {
1031 - break;
1032 - }
1016 + self::$overriddenDefaults['standards'] = true;
1017 + } else if ( substr( $arg, 0, 11 ) === 'extensions=' ) {
1018 + if ( isset( self::$overriddenDefaults['extensions'] ) === true ) {
1019 + break;
1020 + }
1033 1021
1034 - $extensions = explode(',', substr($arg, 11));
1035 - $newExtensions = [];
1036 - foreach ($extensions as $ext) {
1037 - $slash = strpos($ext, '/');
1038 - if ($slash !== false) {
1039 - // They specified the tokenizer too.
1040 - list($ext, $tokenizer) = explode('/', $ext);
1041 - $newExtensions[$ext] = strtoupper($tokenizer);
1042 - continue;
1043 - }
1022 + $extensions = explode( ',', substr( $arg, 11 ) );
1023 + $newExtensions = [];
1024 + foreach ( $extensions as $ext ) {
1025 + $slash = strpos( $ext, '/' );
1026 + if ( $slash !== false ) {
1027 + // They specified the tokenizer too.
1028 + list( $ext, $tokenizer ) = explode( '/', $ext );
1029 + $newExtensions[ $ext ] = strtoupper( $tokenizer );
1030 + continue;
1031 + }
1044 1032
1045 - if (isset($this->extensions[$ext]) === true) {
1046 - $newExtensions[$ext] = $this->extensions[$ext];
1047 - } else {
1048 - $newExtensions[$ext] = 'PHP';
1049 - }
1050 - }
1033 + if ( isset( $this->extensions[ $ext ] ) === true ) {
1034 + $newExtensions[ $ext ] = $this->extensions[ $ext ];
1035 + } else {
1036 + $newExtensions[ $ext ] = 'PHP';
1037 + }
1038 + }
1051 1039
1052 - $this->extensions = $newExtensions;
1053 - self::$overriddenDefaults['extensions'] = true;
1054 - } else if (substr($arg, 0, 7) === 'suffix=') {
1055 - if (isset(self::$overriddenDefaults['suffix']) === true) {
1056 - break;
1057 - }
1040 + $this->extensions = $newExtensions;
1041 + self::$overriddenDefaults['extensions'] = true;
1042 + } else if ( substr( $arg, 0, 7 ) === 'suffix=' ) {
1043 + if ( isset( self::$overriddenDefaults['suffix'] ) === true ) {
1044 + break;
1045 + }
1058 1046
1059 - $this->suffix = substr($arg, 7);
1060 - self::$overriddenDefaults['suffix'] = true;
1061 - } else if (substr($arg, 0, 9) === 'parallel=') {
1062 - if (isset(self::$overriddenDefaults['parallel']) === true) {
1063 - break;
1064 - }
1047 + $this->suffix = substr( $arg, 7 );
1048 + self::$overriddenDefaults['suffix'] = true;
1049 + } else if ( substr( $arg, 0, 9 ) === 'parallel=' ) {
1050 + if ( isset( self::$overriddenDefaults['parallel'] ) === true ) {
1051 + break;
1052 + }
1065 1053
1066 - $this->parallel = max((int) substr($arg, 9), 1);
1067 - self::$overriddenDefaults['parallel'] = true;
1068 - } else if (substr($arg, 0, 9) === 'severity=') {
1069 - $this->errorSeverity = (int) substr($arg, 9);
1070 - $this->warningSeverity = $this->errorSeverity;
1071 - if (isset(self::$overriddenDefaults['errorSeverity']) === false) {
1072 - self::$overriddenDefaults['errorSeverity'] = true;
1073 - }
1054 + $this->parallel = max( (int) substr( $arg, 9 ), 1 );
1055 + self::$overriddenDefaults['parallel'] = true;
1056 + } else if ( substr( $arg, 0, 9 ) === 'severity=' ) {
1057 + $this->errorSeverity = (int) substr( $arg, 9 );
1058 + $this->warningSeverity = $this->errorSeverity;
1059 + if ( isset( self::$overriddenDefaults['errorSeverity'] ) === false ) {
1060 + self::$overriddenDefaults['errorSeverity'] = true;
1061 + }
1074 1062
1075 - if (isset(self::$overriddenDefaults['warningSeverity']) === false) {
1076 - self::$overriddenDefaults['warningSeverity'] = true;
1077 - }
1078 - } else if (substr($arg, 0, 15) === 'error-severity=') {
1079 - if (isset(self::$overriddenDefaults['errorSeverity']) === true) {
1080 - break;
1081 - }
1063 + if ( isset( self::$overriddenDefaults['warningSeverity'] ) === false ) {
1064 + self::$overriddenDefaults['warningSeverity'] = true;
1065 + }
1066 + } else if ( substr( $arg, 0, 15 ) === 'error-severity=' ) {
1067 + if ( isset( self::$overriddenDefaults['errorSeverity'] ) === true ) {
1068 + break;
1069 + }
1082 1070
1083 - $this->errorSeverity = (int) substr($arg, 15);
1084 - self::$overriddenDefaults['errorSeverity'] = true;
1085 - } else if (substr($arg, 0, 17) === 'warning-severity=') {
1086 - if (isset(self::$overriddenDefaults['warningSeverity']) === true) {
1087 - break;
1088 - }
1071 + $this->errorSeverity = (int) substr( $arg, 15 );
1072 + self::$overriddenDefaults['errorSeverity'] = true;
1073 + } else if ( substr( $arg, 0, 17 ) === 'warning-severity=' ) {
1074 + if ( isset( self::$overriddenDefaults['warningSeverity'] ) === true ) {
1075 + break;
1076 + }
1089 1077
1090 - $this->warningSeverity = (int) substr($arg, 17);
1091 - self::$overriddenDefaults['warningSeverity'] = true;
1092 - } else if (substr($arg, 0, 7) === 'ignore=') {
1093 - if (isset(self::$overriddenDefaults['ignored']) === true) {
1094 - break;
1095 - }
1078 + $this->warningSeverity = (int) substr( $arg, 17 );
1079 + self::$overriddenDefaults['warningSeverity'] = true;
1080 + } else if ( substr( $arg, 0, 7 ) === 'ignore=' ) {
1081 + if ( isset( self::$overriddenDefaults['ignored'] ) === true ) {
1082 + break;
1083 + }
1096 1084
1097 - // Split the ignore string on commas, unless the comma is escaped
1098 - // using 1 or 3 slashes (\, or \\\,).
1099 - $patterns = preg_split(
1100 - '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/',
1101 - substr($arg, 7)
1102 - );
1085 + // Split the ignore string on commas, unless the comma is escaped
1086 + // using 1 or 3 slashes (\, or \\\,).
1087 + $patterns = preg_split(
1088 + '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/',
1089 + substr( $arg, 7 )
1090 + );
1103 1091
1104 - $ignored = [];
1105 - foreach ($patterns as $pattern) {
1106 - $pattern = trim($pattern);
1107 - if ($pattern === '') {
1108 - continue;
1109 - }
1092 + $ignored = [];
1093 + foreach ( $patterns as $pattern ) {
1094 + $pattern = trim( $pattern );
1095 + if ( $pattern === '' ) {
1096 + continue;
1097 + }
1110 1098
1111 - $ignored[$pattern] = 'absolute';
1112 - }
1099 + $ignored[ $pattern ] = 'absolute';
1100 + }
1113 1101
1114 - $this->ignored = $ignored;
1115 - self::$overriddenDefaults['ignored'] = true;
1116 - } else if (substr($arg, 0, 10) === 'generator='
1117 - && PHP_CODESNIFFER_CBF === false
1118 - ) {
1119 - if (isset(self::$overriddenDefaults['generator']) === true) {
1120 - break;
1121 - }
1102 + $this->ignored = $ignored;
1103 + self::$overriddenDefaults['ignored'] = true;
1104 + } else if ( substr( $arg, 0, 10 ) === 'generator='
1105 + && PHP_CODESNIFFER_CBF === false
1106 + ) {
1107 + if ( isset( self::$overriddenDefaults['generator'] ) === true ) {
1108 + break;
1109 + }
1122 1110
1123 - $this->generator = substr($arg, 10);
1124 - self::$overriddenDefaults['generator'] = true;
1125 - } else if (substr($arg, 0, 9) === 'encoding=') {
1126 - if (isset(self::$overriddenDefaults['encoding']) === true) {
1127 - break;
1128 - }
1111 + $this->generator = substr( $arg, 10 );
1112 + self::$overriddenDefaults['generator'] = true;
1113 + } else if ( substr( $arg, 0, 9 ) === 'encoding=' ) {
1114 + if ( isset( self::$overriddenDefaults['encoding'] ) === true ) {
1115 + break;
1116 + }
1129 1117
1130 - $this->encoding = strtolower(substr($arg, 9));
1131 - self::$overriddenDefaults['encoding'] = true;
1132 - } else if (substr($arg, 0, 10) === 'tab-width=') {
1133 - if (isset(self::$overriddenDefaults['tabWidth']) === true) {
1134 - break;
1135 - }
1118 + $this->encoding = strtolower( substr( $arg, 9 ) );
1119 + self::$overriddenDefaults['encoding'] = true;
1120 + } else if ( substr( $arg, 0, 10 ) === 'tab-width=' ) {
1121 + if ( isset( self::$overriddenDefaults['tabWidth'] ) === true ) {
1122 + break;
1123 + }
1136 1124
1137 - $this->tabWidth = (int) substr($arg, 10);
1138 - self::$overriddenDefaults['tabWidth'] = true;
1139 - } else {
1140 - if ($this->dieOnUnknownArg === false) {
1141 - $eqPos = strpos($arg, '=');
1142 - try {
1143 - if ($eqPos === false) {
1144 - $this->values[$arg] = $arg;
1145 - } else {
1146 - $value = substr($arg, ($eqPos + 1));
1147 - $arg = substr($arg, 0, $eqPos);
1148 - $this->values[$arg] = $value;
1149 - }
1150 - } catch (RuntimeException $e) {
1151 - // Value is not valid, so just ignore it.
1152 - }
1153 - } else {
1154 - $this->processUnknownArgument('--'.$arg, $pos);
1155 - }
1156 - }//end if
1157 - break;
1158 - }//end switch
1125 + $this->tabWidth = (int) substr( $arg, 10 );
1126 + self::$overriddenDefaults['tabWidth'] = true;
1127 + } else {
1128 + if ( $this->dieOnUnknownArg === false ) {
1129 + $eqPos = strpos( $arg, '=' );
1130 + try {
1131 + if ( $eqPos === false ) {
1132 + $this->values[ $arg ] = $arg;
1133 + } else {
1134 + $value = substr( $arg, ( $eqPos + 1 ) );
1135 + $arg = substr( $arg, 0, $eqPos );
1136 + $this->values[ $arg ] = $value;
1137 + }
1138 + } catch ( RuntimeException $e ) {
1139 + // Value is not valid, so just ignore it.
1140 + }
1141 + } else {
1142 + $this->processUnknownArgument( '--' . $arg, $pos );
1143 + }
1144 + }//end if
1145 + break;
1146 + }//end switch
1159 1147
1160 - }//end processLongArgument()
1148 + }//end processLongArgument()
1161 1149
1162 1150
1163 - /**
1164 - * Processes an unknown command line argument.
1165 - *
1166 - * Assumes all unknown arguments are files and folders to check.
1167 - *
1168 - * @param string $arg The command line argument.
1169 - * @param int $pos The position of the argument on the command line.
1170 - *
1171 - * @return void
1172 - * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
1173 - */
1174 - public function processUnknownArgument($arg, $pos)
1175 - {
1176 - // We don't know about any additional switches; just files.
1177 - if ($arg[0] === '-') {
1178 - if ($this->dieOnUnknownArg === false) {
1179 - return;
1180 - }
1151 + /**
1152 + * Processes an unknown command line argument.
1153 + *
1154 + * Assumes all unknown arguments are files and folders to check.
1155 + *
1156 + * @param string $arg The command line argument.
1157 + * @param int $pos The position of the argument on the command line.
1158 + *
1159 + * @return void
1160 + * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
1161 + */
1162 + public function processUnknownArgument( $arg, $pos ) {
1163 + // We don't know about any additional switches; just files.
1164 + if ( $arg[0] === '-' ) {
1165 + if ( $this->dieOnUnknownArg === false ) {
1166 + return;
1167 + }
1181 1168
1182 - $error = "ERROR: option \"$arg\" not known".PHP_EOL.PHP_EOL;
1183 - $error .= $this->printShortUsage(true);
1184 - throw new DeepExitException($error, 3);
1185 - }
1169 + $error = "ERROR: option \"$arg\" not known" . PHP_EOL . PHP_EOL;
1170 + $error .= $this->printShortUsage( true );
1171 + throw new DeepExitException( $error, 3 );
1172 + }
1186 1173
1187 - $this->processFilePath($arg);
1174 + $this->processFilePath( $arg );
1188 1175
1189 - }//end processUnknownArgument()
1176 + }//end processUnknownArgument()
1190 1177
1191 1178
1192 - /**
1193 - * Processes a file path and add it to the file list.
1194 - *
1195 - * @param string $path The path to the file to add.
1196 - *
1197 - * @return void
1198 - * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
1199 - */
1200 - public function processFilePath($path)
1201 - {
1202 - // If we are processing STDIN, don't record any files to check.
1203 - if ($this->stdin === true) {
1204 - return;
1205 - }
1179 + /**
1180 + * Processes a file path and add it to the file list.
1181 + *
1182 + * @param string $path The path to the file to add.
1183 + *
1184 + * @return void
1185 + * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
1186 + */
1187 + public function processFilePath( $path ) {
1188 + // If we are processing STDIN, don't record any files to check.
1189 + if ( $this->stdin === true ) {
1190 + return;
1191 + }
1206 1192
1207 - $file = Util\Common::realpath($path);
1208 - if (file_exists($file) === false) {
1209 - if ($this->dieOnUnknownArg === false) {
1210 - return;
1211 - }
1193 + $file = Util\Common::realpath( $path );
1194 + if ( file_exists( $file ) === false ) {
1195 + if ( $this->dieOnUnknownArg === false ) {
1196 + return;
1197 + }
1212 1198
1213 - $error = 'ERROR: The file "'.$path.'" does not exist.'.PHP_EOL.PHP_EOL;
1214 - $error .= $this->printShortUsage(true);
1215 - throw new DeepExitException($error, 3);
1216 - } else {
1217 - // Can't modify the files array directly because it's not a real
1218 - // class member, so need to use this little get/modify/set trick.
1219 - $files = $this->files;
1220 - $files[] = $file;
1221 - $this->files = $files;
1222 - self::$overriddenDefaults['files'] = true;
1223 - }
1199 + $error = 'ERROR: The file "' . $path . '" does not exist.' . PHP_EOL . PHP_EOL;
1200 + $error .= $this->printShortUsage( true );
1201 + throw new DeepExitException( $error, 3 );
1202 + } else {
1203 + // Can't modify the files array directly because it's not a real
1204 + // class member, so need to use this little get/modify/set trick.
1205 + $files = $this->files;
1206 + $files[] = $file;
1207 + $this->files = $files;
1208 + self::$overriddenDefaults['files'] = true;
1209 + }
1224 1210
1225 - }//end processFilePath()
1211 + }//end processFilePath()
1226 1212
1227 1213
1228 - /**
1229 - * Prints out the usage information for this script.
1230 - *
1231 - * @return void
1232 - */
1233 - public function printUsage()
1234 - {
1235 - echo PHP_EOL;
1214 + /**
1215 + * Prints out the usage information for this script.
1216 + *
1217 + * @return void
1218 + */
1219 + public function printUsage() {
1220 + echo PHP_EOL;
1236 1221
1237 - if (PHP_CODESNIFFER_CBF === true) {
1238 - $this->printPHPCBFUsage();
1239 - } else {
1240 - $this->printPHPCSUsage();
1241 - }
1222 + if ( PHP_CODESNIFFER_CBF === true ) {
1223 + $this->printPHPCBFUsage();
1224 + } else {
1225 + $this->printPHPCSUsage();
1226 + }
1242 1227
1243 - echo PHP_EOL;
1228 + echo PHP_EOL;
1244 1229
1245 - }//end printUsage()
1230 + }//end printUsage()
1246 1231
1247 1232
1248 - /**
1249 - * Prints out the short usage information for this script.
1250 - *
1251 - * @param bool $return If TRUE, the usage string is returned
1252 - * instead of output to screen.
1253 - *
1254 - * @return string|void
1255 - */
1256 - public function printShortUsage($return=false)
1257 - {
1258 - if (PHP_CODESNIFFER_CBF === true) {
1259 - $usage = 'Run "phpcbf --help" for usage information';
1260 - } else {
1261 - $usage = 'Run "phpcs --help" for usage information';
1262 - }
1233 + /**
1234 + * Prints out the short usage information for this script.
1235 + *
1236 + * @param bool $return If TRUE, the usage string is returned
1237 + * instead of output to screen.
1238 + *
1239 + * @return string|void
1240 + */
1241 + public function printShortUsage( $return = false ) {
1242 + if ( PHP_CODESNIFFER_CBF === true ) {
1243 + $usage = 'Run "phpcbf --help" for usage information';
1244 + } else {
1245 + $usage = 'Run "phpcs --help" for usage information';
1246 + }
1263 1247
1264 - $usage .= PHP_EOL.PHP_EOL;
1248 + $usage .= PHP_EOL . PHP_EOL;
1265 1249
1266 - if ($return === true) {
1267 - return $usage;
1268 - }
1250 + if ( $return === true ) {
1251 + return $usage;
1252 + }
1269 1253
1270 - echo $usage;
1254 + echo $usage;
1271 1255
1272 - }//end printShortUsage()
1256 + }//end printShortUsage()
1273 1257
1274 1258
1275 - /**
1276 - * Prints out the usage information for PHPCS.
1277 - *
1278 - * @return void
1279 - */
1280 - public function printPHPCSUsage()
1281 - {
1282 - echo 'Usage: phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors]'.PHP_EOL;
1283 - echo ' [--cache[=<cacheFile>]] [--no-cache] [--tab-width=<tabWidth>]'.PHP_EOL;
1284 - echo ' [--report=<report>] [--report-file=<reportFile>] [--report-<report>=<reportFile>]'.PHP_EOL;
1285 - echo ' [--report-width=<reportWidth>] [--basepath=<basepath>] [--bootstrap=<bootstrap>]'.PHP_EOL;
1286 - echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1287 - echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL;
1288 - echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>]'.PHP_EOL;
1289 - echo ' [--encoding=<encoding>] [--parallel=<processes>] [--generator=<generator>]'.PHP_EOL;
1290 - echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--ignore-annotations]'.PHP_EOL;
1291 - echo ' [--stdin-path=<stdinPath>] [--file-list=<fileList>] [--filter=<filter>] <file> - ...'.PHP_EOL;
1292 - echo PHP_EOL;
1293 - echo ' - Check STDIN instead of local files and directories'.PHP_EOL;
1294 - echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL;
1295 - echo ' -w Print both warnings and errors (this is the default)'.PHP_EOL;
1296 - echo ' -l Local directory only, no recursion'.PHP_EOL;
1297 - echo ' -s Show sniff codes in all reports'.PHP_EOL;
1298 - echo ' -a Run interactively'.PHP_EOL;
1299 - echo ' -e Explain a standard by showing the sniffs it includes'.PHP_EOL;
1300 - echo ' -p Show progress of the run'.PHP_EOL;
1301 - echo ' -q Quiet mode; disables progress and verbose output'.PHP_EOL;
1302 - echo ' -m Stop error messages from being recorded'.PHP_EOL;
1303 - echo ' (saves a lot of memory, but stops many reports from being used)'.PHP_EOL;
1304 - echo ' -v Print processed files'.PHP_EOL;
1305 - echo ' -vv Print ruleset and token output'.PHP_EOL;
1306 - echo ' -vvv Print sniff processing information'.PHP_EOL;
1307 - echo ' -i Show a list of installed coding standards'.PHP_EOL;
1308 - echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL;
1309 - echo PHP_EOL;
1310 - echo ' --help Print this help message'.PHP_EOL;
1311 - echo ' --version Print version information'.PHP_EOL;
1312 - echo ' --colors Use colors in output'.PHP_EOL;
1313 - echo ' --no-colors Do not use colors in output (this is the default)'.PHP_EOL;
1314 - echo ' --cache Cache results between runs'.PHP_EOL;
1315 - echo ' --no-cache Do not cache results between runs (this is the default)'.PHP_EOL;
1316 - echo ' --ignore-annotations Ignore all phpcs: annotations in code comments'.PHP_EOL;
1317 - echo PHP_EOL;
1318 - echo ' <cacheFile> Use a specific file for caching (uses a temporary file by default)'.PHP_EOL;
1319 - echo ' <basepath> A path to strip from the front of file paths inside reports'.PHP_EOL;
1320 - echo ' <bootstrap> A comma separated list of files to run before processing begins'.PHP_EOL;
1321 - echo ' <encoding> The encoding of the files being checked (default is utf-8)'.PHP_EOL;
1322 - echo ' <extensions> A comma separated list of file extensions to check'.PHP_EOL;
1323 - echo ' The type of the file can be specified using: ext/type'.PHP_EOL;
1324 - echo ' e.g., module/php,es/js'.PHP_EOL;
1325 - echo ' <file> One or more files and/or directories to check'.PHP_EOL;
1326 - echo ' <fileList> A file containing a list of files and/or directories to check (one per line)'.PHP_EOL;
1327 - echo ' <filter> Use either the "gitmodified" or "gitstaged" filter,'.PHP_EOL;
1328 - echo ' or specify the path to a custom filter class'.PHP_EOL;
1329 - echo ' <generator> Use either the "HTML", "Markdown" or "Text" generator'.PHP_EOL;
1330 - echo ' (forces documentation generation instead of checking)'.PHP_EOL;
1331 - echo ' <patterns> A comma separated list of patterns to ignore files and directories'.PHP_EOL;
1332 - echo ' <processes> How many files should be checked simultaneously (default is 1)'.PHP_EOL;
1333 - echo ' <report> Print either the "full", "xml", "checkstyle", "csv"'.PHP_EOL;
1334 - echo ' "json", "junit", "emacs", "source", "summary", "diff"'.PHP_EOL;
1335 - echo ' "svnblame", "gitblame", "hgblame" or "notifysend" report,'.PHP_EOL;
1336 - echo ' or specify the path to a custom report class'.PHP_EOL;
1337 - echo ' (the "full" report is printed by default)'.PHP_EOL;
1338 - echo ' <reportFile> Write the report to the specified file path'.PHP_EOL;
1339 - echo ' <reportWidth> How many columns wide screen reports should be printed'.PHP_EOL;
1340 - echo ' or set to "auto" to use current screen width, where supported'.PHP_EOL;
1341 - echo ' <severity> The minimum severity required to display an error or warning'.PHP_EOL;
1342 - echo ' <sniffs> A comma separated list of sniff codes to include or exclude from checking'.PHP_EOL;
1343 - echo ' (all sniffs must be part of the specified standard)'.PHP_EOL;
1344 - echo ' <standard> The name or path of the coding standard to use'.PHP_EOL;
1345 - echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as'.PHP_EOL;
1346 - echo ' <tabWidth> The number of spaces each tab represents'.PHP_EOL;
1259 + /**
1260 + * Prints out the usage information for PHPCS.
1261 + *
1262 + * @return void
1263 + */
1264 + public function printPHPCSUsage() {
1265 + echo 'Usage: phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors]' . PHP_EOL;
1266 + echo ' [--cache[=<cacheFile>]] [--no-cache] [--tab-width=<tabWidth>]' . PHP_EOL;
1267 + echo ' [--report=<report>] [--report-file=<reportFile>] [--report-<report>=<reportFile>]' . PHP_EOL;
1268 + echo ' [--report-width=<reportWidth>] [--basepath=<basepath>] [--bootstrap=<bootstrap>]' . PHP_EOL;
1269 + echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]' . PHP_EOL;
1270 + echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]' . PHP_EOL;
1271 + echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>]' . PHP_EOL;
1272 + echo ' [--encoding=<encoding>] [--parallel=<processes>] [--generator=<generator>]' . PHP_EOL;
1273 + echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--ignore-annotations]' . PHP_EOL;
1274 + echo ' [--stdin-path=<stdinPath>] [--file-list=<fileList>] [--filter=<filter>] <file> - ...' . PHP_EOL;
1275 + echo PHP_EOL;
1276 + echo ' - Check STDIN instead of local files and directories' . PHP_EOL;
1277 + echo ' -n Do not print warnings (shortcut for --warning-severity=0)' . PHP_EOL;
1278 + echo ' -w Print both warnings and errors (this is the default)' . PHP_EOL;
1279 + echo ' -l Local directory only, no recursion' . PHP_EOL;
1280 + echo ' -s Show sniff codes in all reports' . PHP_EOL;
1281 + echo ' -a Run interactively' . PHP_EOL;
1282 + echo ' -e Explain a standard by showing the sniffs it includes' . PHP_EOL;
1283 + echo ' -p Show progress of the run' . PHP_EOL;
1284 + echo ' -q Quiet mode; disables progress and verbose output' . PHP_EOL;
1285 + echo ' -m Stop error messages from being recorded' . PHP_EOL;
1286 + echo ' (saves a lot of memory, but stops many reports from being used)' . PHP_EOL;
1287 + echo ' -v Print processed files' . PHP_EOL;
1288 + echo ' -vv Print ruleset and token output' . PHP_EOL;
1289 + echo ' -vvv Print sniff processing information' . PHP_EOL;
1290 + echo ' -i Show a list of installed coding standards' . PHP_EOL;
1291 + echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted' . PHP_EOL;
1292 + echo PHP_EOL;
1293 + echo ' --help Print this help message' . PHP_EOL;
1294 + echo ' --version Print version information' . PHP_EOL;
1295 + echo ' --colors Use colors in output' . PHP_EOL;
1296 + echo ' --no-colors Do not use colors in output (this is the default)' . PHP_EOL;
1297 + echo ' --cache Cache results between runs' . PHP_EOL;
1298 + echo ' --no-cache Do not cache results between runs (this is the default)' . PHP_EOL;
1299 + echo ' --ignore-annotations Ignore all phpcs: annotations in code comments' . PHP_EOL;
1300 + echo PHP_EOL;
1301 + echo ' <cacheFile> Use a specific file for caching (uses a temporary file by default)' . PHP_EOL;
1302 + echo ' <basepath> A path to strip from the front of file paths inside reports' . PHP_EOL;
1303 + echo ' <bootstrap> A comma separated list of files to run before processing begins' . PHP_EOL;
1304 + echo ' <encoding> The encoding of the files being checked (default is utf-8)' . PHP_EOL;
1305 + echo ' <extensions> A comma separated list of file extensions to check' . PHP_EOL;
1306 + echo ' The type of the file can be specified using: ext/type' . PHP_EOL;
1307 + echo ' e.g., module/php,es/js' . PHP_EOL;
1308 + echo ' <file> One or more files and/or directories to check' . PHP_EOL;
1309 + echo ' <fileList> A file containing a list of files and/or directories to check (one per line)' . PHP_EOL;
1310 + echo ' <filter> Use either the "gitmodified" or "gitstaged" filter,' . PHP_EOL;
1311 + echo ' or specify the path to a custom filter class' . PHP_EOL;
1312 + echo ' <generator> Use either the "HTML", "Markdown" or "Text" generator' . PHP_EOL;
1313 + echo ' (forces documentation generation instead of checking)' . PHP_EOL;
1314 + echo ' <patterns> A comma separated list of patterns to ignore files and directories' . PHP_EOL;
1315 + echo ' <processes> How many files should be checked simultaneously (default is 1)' . PHP_EOL;
1316 + echo ' <report> Print either the "full", "xml", "checkstyle", "csv"' . PHP_EOL;
1317 + echo ' "json", "junit", "emacs", "source", "summary", "diff"' . PHP_EOL;
1318 + echo ' "svnblame", "gitblame", "hgblame" or "notifysend" report,' . PHP_EOL;
1319 + echo ' or specify the path to a custom report class' . PHP_EOL;
1320 + echo ' (the "full" report is printed by default)' . PHP_EOL;
1321 + echo ' <reportFile> Write the report to the specified file path' . PHP_EOL;
1322 + echo ' <reportWidth> How many columns wide screen reports should be printed' . PHP_EOL;
1323 + echo ' or set to "auto" to use current screen width, where supported' . PHP_EOL;
1324 + echo ' <severity> The minimum severity required to display an error or warning' . PHP_EOL;
1325 + echo ' <sniffs> A comma separated list of sniff codes to include or exclude from checking' . PHP_EOL;
1326 + echo ' (all sniffs must be part of the specified standard)' . PHP_EOL;
1327 + echo ' <standard> The name or path of the coding standard to use' . PHP_EOL;
1328 + echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as' . PHP_EOL;
1329 + echo ' <tabWidth> The number of spaces each tab represents' . PHP_EOL;
1347 1330
1348 - }//end printPHPCSUsage()
1331 + }//end printPHPCSUsage()
1349 1332
1350 1333
1351 - /**
1352 - * Prints out the usage information for PHPCBF.
1353 - *
1354 - * @return void
1355 - */
1356 - public function printPHPCBFUsage()
1357 - {
1358 - echo 'Usage: phpcbf [-nwli] [-d key[=value]] [--ignore-annotations] [--bootstrap=<bootstrap>]'.PHP_EOL;
1359 - echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--suffix=<suffix>]'.PHP_EOL;
1360 - echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1361 - echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>] [--parallel=<processes>]'.PHP_EOL;
1362 - echo ' [--basepath=<basepath>] [--extensions=<extensions>] [--ignore=<patterns>]'.PHP_EOL;
1363 - echo ' [--stdin-path=<stdinPath>] [--file-list=<fileList>] [--filter=<filter>] <file> - ...'.PHP_EOL;
1364 - echo PHP_EOL;
1365 - echo ' - Fix STDIN instead of local files and directories'.PHP_EOL;
1366 - echo ' -n Do not fix warnings (shortcut for --warning-severity=0)'.PHP_EOL;
1367 - echo ' -w Fix both warnings and errors (on by default)'.PHP_EOL;
1368 - echo ' -l Local directory only, no recursion'.PHP_EOL;
1369 - echo ' -p Show progress of the run'.PHP_EOL;
1370 - echo ' -q Quiet mode; disables progress and verbose output'.PHP_EOL;
1371 - echo ' -v Print processed files'.PHP_EOL;
1372 - echo ' -vv Print ruleset and token output'.PHP_EOL;
1373 - echo ' -vvv Print sniff processing information'.PHP_EOL;
1374 - echo ' -i Show a list of installed coding standards'.PHP_EOL;
1375 - echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL;
1376 - echo PHP_EOL;
1377 - echo ' --help Print this help message'.PHP_EOL;
1378 - echo ' --version Print version information'.PHP_EOL;
1379 - echo ' --ignore-annotations Ignore all phpcs: annotations in code comments'.PHP_EOL;
1380 - echo PHP_EOL;
1381 - echo ' <basepath> A path to strip from the front of file paths inside reports'.PHP_EOL;
1382 - echo ' <bootstrap> A comma separated list of files to run before processing begins'.PHP_EOL;
1383 - echo ' <encoding> The encoding of the files being fixed (default is utf-8)'.PHP_EOL;
1384 - echo ' <extensions> A comma separated list of file extensions to fix'.PHP_EOL;
1385 - echo ' The type of the file can be specified using: ext/type'.PHP_EOL;
1386 - echo ' e.g., module/php,es/js'.PHP_EOL;
1387 - echo ' <file> One or more files and/or directories to fix'.PHP_EOL;
1388 - echo ' <fileList> A file containing a list of files and/or directories to fix (one per line)'.PHP_EOL;
1389 - echo ' <filter> Use either the "gitmodified" or "gitstaged" filter,'.PHP_EOL;
1390 - echo ' or specify the path to a custom filter class'.PHP_EOL;
1391 - echo ' <patterns> A comma separated list of patterns to ignore files and directories'.PHP_EOL;
1392 - echo ' <processes> How many files should be fixed simultaneously (default is 1)'.PHP_EOL;
1393 - echo ' <severity> The minimum severity required to fix an error or warning'.PHP_EOL;
1394 - echo ' <sniffs> A comma separated list of sniff codes to include or exclude from fixing'.PHP_EOL;
1395 - echo ' (all sniffs must be part of the specified standard)'.PHP_EOL;
1396 - echo ' <standard> The name or path of the coding standard to use'.PHP_EOL;
1397 - echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as'.PHP_EOL;
1398 - echo ' <suffix> Write modified files to a filename using this suffix'.PHP_EOL;
1399 - echo ' ("diff" and "patch" are not used in this mode)'.PHP_EOL;
1400 - echo ' <tabWidth> The number of spaces each tab represents'.PHP_EOL;
1334 + /**
1335 + * Prints out the usage information for PHPCBF.
1336 + *
1337 + * @return void
1338 + */
1339 + public function printPHPCBFUsage() {
1340 + echo 'Usage: phpcbf [-nwli] [-d key[=value]] [--ignore-annotations] [--bootstrap=<bootstrap>]' . PHP_EOL;
1341 + echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--suffix=<suffix>]' . PHP_EOL;
1342 + echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]' . PHP_EOL;
1343 + echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>] [--parallel=<processes>]' . PHP_EOL;
1344 + echo ' [--basepath=<basepath>] [--extensions=<extensions>] [--ignore=<patterns>]' . PHP_EOL;
1345 + echo ' [--stdin-path=<stdinPath>] [--file-list=<fileList>] [--filter=<filter>] <file> - ...' . PHP_EOL;
1346 + echo PHP_EOL;
1347 + echo ' - Fix STDIN instead of local files and directories' . PHP_EOL;
1348 + echo ' -n Do not fix warnings (shortcut for --warning-severity=0)' . PHP_EOL;
1349 + echo ' -w Fix both warnings and errors (on by default)' . PHP_EOL;
1350 + echo ' -l Local directory only, no recursion' . PHP_EOL;
1351 + echo ' -p Show progress of the run' . PHP_EOL;
1352 + echo ' -q Quiet mode; disables progress and verbose output' . PHP_EOL;
1353 + echo ' -v Print processed files' . PHP_EOL;
1354 + echo ' -vv Print ruleset and token output' . PHP_EOL;
1355 + echo ' -vvv Print sniff processing information' . PHP_EOL;
1356 + echo ' -i Show a list of installed coding standards' . PHP_EOL;
1357 + echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted' . PHP_EOL;
1358 + echo PHP_EOL;
1359 + echo ' --help Print this help message' . PHP_EOL;
1360 + echo ' --version Print version information' . PHP_EOL;
1361 + echo ' --ignore-annotations Ignore all phpcs: annotations in code comments' . PHP_EOL;
1362 + echo PHP_EOL;
1363 + echo ' <basepath> A path to strip from the front of file paths inside reports' . PHP_EOL;
1364 + echo ' <bootstrap> A comma separated list of files to run before processing begins' . PHP_EOL;
1365 + echo ' <encoding> The encoding of the files being fixed (default is utf-8)' . PHP_EOL;
1366 + echo ' <extensions> A comma separated list of file extensions to fix' . PHP_EOL;
1367 + echo ' The type of the file can be specified using: ext/type' . PHP_EOL;
1368 + echo ' e.g., module/php,es/js' . PHP_EOL;
1369 + echo ' <file> One or more files and/or directories to fix' . PHP_EOL;
1370 + echo ' <fileList> A file containing a list of files and/or directories to fix (one per line)' . PHP_EOL;
1371 + echo ' <filter> Use either the "gitmodified" or "gitstaged" filter,' . PHP_EOL;
1372 + echo ' or specify the path to a custom filter class' . PHP_EOL;
1373 + echo ' <patterns> A comma separated list of patterns to ignore files and directories' . PHP_EOL;
1374 + echo ' <processes> How many files should be fixed simultaneously (default is 1)' . PHP_EOL;
1375 + echo ' <severity> The minimum severity required to fix an error or warning' . PHP_EOL;
1376 + echo ' <sniffs> A comma separated list of sniff codes to include or exclude from fixing' . PHP_EOL;
1377 + echo ' (all sniffs must be part of the specified standard)' . PHP_EOL;
1378 + echo ' <standard> The name or path of the coding standard to use' . PHP_EOL;
1379 + echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as' . PHP_EOL;
1380 + echo ' <suffix> Write modified files to a filename using this suffix' . PHP_EOL;
1381 + echo ' ("diff" and "patch" are not used in this mode)' . PHP_EOL;
1382 + echo ' <tabWidth> The number of spaces each tab represents' . PHP_EOL;
1401 1383
1402 - }//end printPHPCBFUsage()
1384 + }//end printPHPCBFUsage()
1403 1385
1404 1386
1405 - /**
1406 - * Get a single config value.
1407 - *
1408 - * @param string $key The name of the config value.
1409 - *
1410 - * @return string|null
1411 - * @see setConfigData()
1412 - * @see getAllConfigData()
1413 - */
1414 - public static function getConfigData($key)
1415 - {
1416 - $phpCodeSnifferConfig = self::getAllConfigData();
1387 + /**
1388 + * Get a single config value.
1389 + *
1390 + * @param string $key The name of the config value.
1391 + *
1392 + * @return string|null
1393 + * @see setConfigData()
1394 + * @see getAllConfigData()
1395 + */
1396 + public static function getConfigData( $key ) {
1397 + $phpCodeSnifferConfig = self::getAllConfigData();
1417 1398
1418 - if ($phpCodeSnifferConfig === null) {
1419 - return null;
1420 - }
1399 + if ( $phpCodeSnifferConfig === null ) {
1400 + return null;
1401 + }
1421 1402
1422 - if (isset($phpCodeSnifferConfig[$key]) === false) {
1423 - return null;
1424 - }
1403 + if ( isset( $phpCodeSnifferConfig[ $key ] ) === false ) {
1404 + return null;
1405 + }
1425 1406
1426 - return $phpCodeSnifferConfig[$key];
1407 + return $phpCodeSnifferConfig[ $key ];
1427 1408
1428 - }//end getConfigData()
1409 + }//end getConfigData()
1429 1410
1430 1411
1431 - /**
1432 - * Set a single config value.
1433 - *
1434 - * @param string $key The name of the config value.
1435 - * @param string|null $value The value to set. If null, the config
1436 - * entry is deleted, reverting it to the
1437 - * default value.
1438 - * @param boolean $temp Set this config data temporarily for this
1439 - * script run. This will not write the config
1440 - * data to the config file.
1441 - *
1442 - * @return bool
1443 - * @see getConfigData()
1444 - * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the config file can not be written.
1445 - */
1446 - public static function setConfigData($key, $value, $temp=false)
1447 - {
1448 - if (isset(self::$overriddenDefaults['runtime-set']) === true
1449 - && isset(self::$overriddenDefaults['runtime-set'][$key]) === true
1450 - ) {
1451 - return false;
1452 - }
1412 + /**
1413 + * Set a single config value.
1414 + *
1415 + * @param string $key The name of the config value.
1416 + * @param string|null $value The value to set. If null, the config
1417 + * entry is deleted, reverting it to the
1418 + * default value.
1419 + * @param boolean $temp Set this config data temporarily for this
1420 + * script run. This will not write the config
1421 + * data to the config file.
1422 + *
1423 + * @return bool
1424 + * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the config file can not be written.
1425 + * @see getConfigData()
1426 + */
1427 + public static function setConfigData( $key, $value, $temp = false ) {
1428 + if ( isset( self::$overriddenDefaults['runtime-set'] ) === true
1429 + && isset( self::$overriddenDefaults['runtime-set'][ $key ] ) === true
1430 + ) {
1431 + return false;
1432 + }
1453 1433
1454 - if ($temp === false) {
1455 - $path = '';
1456 - if (is_callable('\Phar::running') === true) {
1457 - $path = \Phar::running(false);
1458 - }
1434 + if ( $temp === false ) {
1435 + $path = '';
1436 + if ( is_callable( '\Phar::running' ) === true ) {
1437 + $path = \Phar::running( false );
1438 + }
1459 1439
1460 - if ($path !== '') {
1461 - $configFile = dirname($path).DIRECTORY_SEPARATOR.'CodeSniffer.conf';
1462 - } else {
1463 - $configFile = dirname(__DIR__).DIRECTORY_SEPARATOR.'CodeSniffer.conf';
1464 - if (is_file($configFile) === false
1465 - && strpos('@data_dir@', '@data_dir') === false
1466 - ) {
1467 - // If data_dir was replaced, this is a PEAR install and we can
1468 - // use the PEAR data dir to store the conf file.
1469 - $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf';
1470 - }
1471 - }
1440 + if ( $path !== '' ) {
1441 + $configFile = dirname( $path ) . DIRECTORY_SEPARATOR . 'CodeSniffer.conf';
1442 + } else {
1443 + $configFile = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'CodeSniffer.conf';
1444 + if ( is_file( $configFile ) === false
1445 + && strpos( '@data_dir@', '@data_dir' ) === false
1446 + ) {
1447 + // If data_dir was replaced, this is a PEAR install and we can
1448 + // use the PEAR data dir to store the conf file.
1449 + $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf';
1450 + }
1451 + }
1472 1452
1473 - if (is_file($configFile) === true
1474 - && is_writable($configFile) === false
1475 - ) {
1476 - $error = 'ERROR: Config file '.$configFile.' is not writable'.PHP_EOL.PHP_EOL;
1477 - throw new DeepExitException($error, 3);
1478 - }
1479 - }//end if
1453 + if ( is_file( $configFile ) === true
1454 + && is_writable( $configFile ) === false
1455 + ) {
1456 + $error = 'ERROR: Config file ' . $configFile . ' is not writable' . PHP_EOL . PHP_EOL;
1457 + throw new DeepExitException( $error, 3 );
1458 + }
1459 + }//end if
1480 1460
1481 - $phpCodeSnifferConfig = self::getAllConfigData();
1461 + $phpCodeSnifferConfig = self::getAllConfigData();
1482 1462
1483 - if ($value === null) {
1484 - if (isset($phpCodeSnifferConfig[$key]) === true) {
1485 - unset($phpCodeSnifferConfig[$key]);
1486 - }
1487 - } else {
1488 - $phpCodeSnifferConfig[$key] = $value;
1489 - }
1463 + if ( $value === null ) {
1464 + if ( isset( $phpCodeSnifferConfig[ $key ] ) === true ) {
1465 + unset( $phpCodeSnifferConfig[ $key ] );
1466 + }
1467 + } else {
1468 + $phpCodeSnifferConfig[ $key ] = $value;
1469 + }
1490 1470
1491 - if ($temp === false) {
1492 - $output = '<'.'?php'."\n".' $phpCodeSnifferConfig = ';
1493 - $output .= var_export($phpCodeSnifferConfig, true);
1494 - $output .= "\n?".'>';
1471 + if ( $temp === false ) {
1472 + $output = '<' . '?php' . "\n" . ' $phpCodeSnifferConfig = ';
1473 + $output .= var_export( $phpCodeSnifferConfig, true );
1474 + $output .= "\n?" . '>';
1495 1475
1496 - if (file_put_contents($configFile, $output) === false) {
1497 - $error = 'ERROR: Config file '.$configFile.' could not be written'.PHP_EOL.PHP_EOL;
1498 - throw new DeepExitException($error, 3);
1499 - }
1476 + if ( file_put_contents( $configFile, $output ) === false ) {
1477 + $error = 'ERROR: Config file ' . $configFile . ' could not be written' . PHP_EOL . PHP_EOL;
1478 + throw new DeepExitException( $error, 3 );
1479 + }
1500 1480
1501 - self::$configDataFile = $configFile;
1502 - }
1481 + self::$configDataFile = $configFile;
1482 + }
1503 1483
1504 - self::$configData = $phpCodeSnifferConfig;
1484 + self::$configData = $phpCodeSnifferConfig;
1505 1485
1506 - // If the installed paths are being set, make sure all known
1507 - // standards paths are added to the autoloader.
1508 - if ($key === 'installed_paths') {
1509 - $installedStandards = Util\Standards::getInstalledStandardDetails();
1510 - foreach ($installedStandards as $name => $details) {
1511 - Autoload::addSearchPath($details['path'], $details['namespace']);
1512 - }
1513 - }
1486 + // If the installed paths are being set, make sure all known
1487 + // standards paths are added to the autoloader.
1488 + if ( $key === 'installed_paths' ) {
1489 + $installedStandards = Util\Standards::getInstalledStandardDetails();
1490 + foreach ( $installedStandards as $name => $details ) {
1491 + Autoload::addSearchPath( $details['path'], $details['namespace'] );
1492 + }
1493 + }
1514 1494
1515 - return true;
1495 + return true;
1516 1496
1517 - }//end setConfigData()
1497 + }//end setConfigData()
1518 1498
1519 1499
1520 - /**
1521 - * Get all config data.
1522 - *
1523 - * @return array<string, string>
1524 - * @see getConfigData()
1525 - * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the config file could not be read.
1526 - */
1527 - public static function getAllConfigData()
1528 - {
1529 - if (self::$configData !== null) {
1530 - return self::$configData;
1531 - }
1500 + /**
1501 + * Get all config data.
1502 + *
1503 + * @return array<string, string>
1504 + * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the config file could not be read.
1505 + * @see getConfigData()
1506 + */
1507 + public static function getAllConfigData() {
1508 + if ( self::$configData !== null ) {
1509 + return self::$configData;
1510 + }
1532 1511
1533 - $path = '';
1534 - if (is_callable('\Phar::running') === true) {
1535 - $path = \Phar::running(false);
1536 - }
1512 + $path = '';
1513 + if ( is_callable( '\Phar::running' ) === true ) {
1514 + $path = \Phar::running( false );
1515 + }
1537 1516
1538 - if ($path !== '') {
1539 - $configFile = dirname($path).DIRECTORY_SEPARATOR.'CodeSniffer.conf';
1540 - } else {
1541 - $configFile = dirname(__DIR__).DIRECTORY_SEPARATOR.'CodeSniffer.conf';
1542 - if (is_file($configFile) === false
1543 - && strpos('@data_dir@', '@data_dir') === false
1544 - ) {
1545 - $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf';
1546 - }
1547 - }
1517 + if ( $path !== '' ) {
1518 + $configFile = dirname( $path ) . DIRECTORY_SEPARATOR . 'CodeSniffer.conf';
1519 + } else {
1520 + $configFile = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'CodeSniffer.conf';
1521 + if ( is_file( $configFile ) === false
1522 + && strpos( '@data_dir@', '@data_dir' ) === false
1523 + ) {
1524 + $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf';
1525 + }
1526 + }
1548 1527
1549 - if (is_file($configFile) === false) {
1550 - self::$configData = [];
1551 - return [];
1552 - }
1528 + if ( is_file( $configFile ) === false ) {
1529 + self::$configData = [];
1553 1530
1554 - if (is_readable($configFile) === false) {
1555 - $error = 'ERROR: Config file '.$configFile.' is not readable'.PHP_EOL.PHP_EOL;
1556 - throw new DeepExitException($error, 3);
1557 - }
1531 + return [];
1532 + }
1558 1533
1559 - include $configFile;
1560 - self::$configDataFile = $configFile;
1561 - self::$configData = $phpCodeSnifferConfig;
1562 - return self::$configData;
1534 + if ( is_readable( $configFile ) === false ) {
1535 + $error = 'ERROR: Config file ' . $configFile . ' is not readable' . PHP_EOL . PHP_EOL;
1536 + throw new DeepExitException( $error, 3 );
1537 + }
1563 1538
1564 - }//end getAllConfigData()
1539 + include $configFile;
1540 + self::$configDataFile = $configFile;
1541 + self::$configData = $phpCodeSnifferConfig;
1565 1542
1543 + return self::$configData;
1566 1544
1567 - /**
1568 - * Prints out the gathered config data.
1569 - *
1570 - * @param array $data The config data to print.
1571 - *
1572 - * @return void
1573 - */
1574 - public function printConfigData($data)
1575 - {
1576 - $max = 0;
1577 - $keys = array_keys($data);
1578 - foreach ($keys as $key) {
1579 - $len = strlen($key);
1580 - if (strlen($key) > $max) {
1581 - $max = $len;
1582 - }
1583 - }
1545 + }//end getAllConfigData()
1584 1546
1585 - if ($max === 0) {
1586 - return;
1587 - }
1588 1547
1589 - $max += 2;
1590 - ksort($data);
1591 - foreach ($data as $name => $value) {
1592 - echo str_pad($name.': ', $max).$value.PHP_EOL;
1593 - }
1548 + /**
1549 + * Prints out the gathered config data.
1550 + *
1551 + * @param array $data The config data to print.
1552 + *
1553 + * @return void
1554 + */
1555 + public function printConfigData( $data ) {
1556 + $max = 0;
1557 + $keys = array_keys( $data );
1558 + foreach ( $keys as $key ) {
1559 + $len = strlen( $key );
1560 + if ( strlen( $key ) > $max ) {
1561 + $max = $len;
1562 + }
1563 + }
1594 1564
1595 - }//end printConfigData()
1565 + if ( $max === 0 ) {
1566 + return;
1567 + }
1568 +
1569 + $max += 2;
1570 + ksort( $data );
1571 + foreach ( $data as $name => $value ) {
1572 + echo str_pad( $name . ': ', $max ) . $value . PHP_EOL;
1573 + }
1574 +
1575 + }//end printConfigData()
1596 1576
1597 1577
1598 1578 }//end class