From fd8a3822c336e1a89fcc9657361e33d616e0daef Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Fri, 27 Nov 2015 14:36:56 +1100 Subject: [PATCH] Added changelog + realpath fixes for new bootstrap option (ref #783) --- CodeSniffer.php | 2 +- CodeSniffer/CLI.php | 23 +++++++++++------------ package.xml | 8 ++++++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CodeSniffer.php b/CodeSniffer.php index b43ea3043f..32a353b60f 100644 --- a/CodeSniffer.php +++ b/CodeSniffer.php @@ -73,7 +73,7 @@ class PHP_CodeSniffer * * @var string */ - const VERSION = '2.4.1'; + const VERSION = '2.5.0'; /** * Package stability; either stable, beta or alpha. diff --git a/CodeSniffer/CLI.php b/CodeSniffer/CLI.php index 90f00c219f..58ba505956 100644 --- a/CodeSniffer/CLI.php +++ b/CodeSniffer/CLI.php @@ -273,6 +273,7 @@ public function getDefaults() $defaults['reportFile'] = null; $defaults['generator'] = ''; $defaults['reports'] = array(); + $defaults['bootstrap'] = array(); $defaults['errorSeverity'] = null; $defaults['warningSeverity'] = null; @@ -603,14 +604,15 @@ public function processLongArgument($arg, $pos) } else if (substr($arg, 0, 10) === 'bootstrap=') { $files = explode(',', substr($arg, 10)); foreach ($files as $file) { + $file = PHP_CodeSniffer::realpath($file); if (file_exists($file) === false) { echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; $this->printUsage(); exit(2); } - } - $this->values['bootstrap'] = $files; + $this->values['bootstrap'][] = $file; + } } else if (substr($arg, 0, 12) === 'report-file=') { $this->values['reportFile'] = PHP_CodeSniffer::realpath(substr($arg, 12)); @@ -791,10 +793,9 @@ public function process($values=array()) $this->values = $values; } - if (empty($values['bootstrap']) === false) { - foreach ($values['bootstrap'] as $bootstrap) { - include $bootstrap; - } + // Include bootstrap files. + foreach ($values['bootstrap'] as $bootstrap) { + include $bootstrap; } if ($values['generator'] !== '') { @@ -1180,8 +1181,7 @@ public function printPHPCSUsage() echo ' [--severity=] [--error-severity=] [--warning-severity=]'.PHP_EOL; echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL; echo ' [--standard=] [--sniffs=] [--encoding=]'.PHP_EOL; - echo ' [--extensions=] [--ignore=]'.PHP_EOL; - echo ' [--bootstrap=] ...'.PHP_EOL; + echo ' [--extensions=] [--ignore=] [--bootstrap=] ...'.PHP_EOL; echo ' Set runtime value (see --config-set) '.PHP_EOL; echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL; echo ' -w Print both warnings and errors (this is the default)'.PHP_EOL; @@ -1198,7 +1198,7 @@ public function printPHPCSUsage() echo ' --colors Use colors in output'.PHP_EOL; echo ' --no-colors Do not use colors in output (this is the default)'.PHP_EOL; echo ' One or more files and/or directories to check'.PHP_EOL; - echo ' A file to run before processing sniffs'.PHP_EOL; + echo ' A comma separated list of files to run before processing starts'.PHP_EOL; echo ' The encoding of the files being checked (default is iso-8859-1)'.PHP_EOL; echo ' A comma separated list of file extensions to check'.PHP_EOL; echo ' (extension filtering only valid when checking a directory)'.PHP_EOL; @@ -1234,8 +1234,7 @@ public function printPHPCBFUsage() echo ' [--standard=] [--sniffs=] [--suffix=]'.PHP_EOL; echo ' [--severity=] [--error-severity=] [--warning-severity=]'.PHP_EOL; echo ' [--tab-width=] [--encoding=]'.PHP_EOL; - echo ' [--extensions=] [--ignore=]'.PHP_EOL; - echo ' [--bootstrap=] ...'.PHP_EOL; + echo ' [--extensions=] [--ignore=] [--bootstrap=] ...'.PHP_EOL; echo ' -n Do not fix warnings (shortcut for --warning-severity=0)'.PHP_EOL; echo ' -w Fix both warnings and errors (on by default)'.PHP_EOL; echo ' -l Local directory only, no recursion'.PHP_EOL; @@ -1245,7 +1244,7 @@ public function printPHPCBFUsage() echo ' --version Print version information'.PHP_EOL; echo ' --no-patch Do not make use of the "diff" or "patch" programs'.PHP_EOL; echo ' One or more files and/or directories to fix'.PHP_EOL; - echo ' A file to run before processing sniffs'.PHP_EOL; + echo ' A comma separated list of files to run before processing starts'.PHP_EOL; echo ' The encoding of the files being fixed (default is iso-8859-1)'.PHP_EOL; echo ' A comma separated list of file extensions to fix'.PHP_EOL; echo ' (extension filtering only valid when checking a directory)'.PHP_EOL; diff --git a/package.xml b/package.xml index 7a813e7eba..403be9782f 100644 --- a/package.xml +++ b/package.xml @@ -17,8 +17,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> 2015-11-24 - 2.4.1 - 2.4.1 + 2.5.0 + 2.5.0 stable @@ -31,6 +31,10 @@ http://pear.php.net/dtd/package-2.0.xsd"> -- This file is still only used if no standard is specified on the command line - Added support for a phpcs.xml.dist file (request #583) -- If both a phpcs.xml and phpcs.xml.dist file are present, the phpcs.xml file will be used + - Added support for one or more bootstrap files to be run before processing begins + -- Use the --bootstrap=file,file,file command line argument to include bootstrap files + -- Ueeful if you want to override some of the high-level settings of PHPCS or PHPCBF + -- Thanks to John Maguire for the patch - Fixed bug #784 : $this->trait is seen as a T_TRAIT token - Fixed bug #786 : Switch indent issue with short array notation - Fixed bug #787 : SpacingAfterDefaultBreak confused by multi-line statements