Skip to content

Commit

Permalink
Added changelog + realpath fixes for new bootstrap option (ref #783)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Nov 27, 2015
1 parent 7c4f138 commit fd8a382
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CodeSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 11 additions & 12 deletions CodeSniffer/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public function getDefaults()
$defaults['reportFile'] = null;
$defaults['generator'] = '';
$defaults['reports'] = array();
$defaults['bootstrap'] = array();
$defaults['errorSeverity'] = null;
$defaults['warningSeverity'] = null;

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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'] !== '') {
Expand Down Expand Up @@ -1180,8 +1181,7 @@ public function printPHPCSUsage()
echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL;
echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--encoding=<encoding>]'.PHP_EOL;
echo ' [--extensions=<extensions>] [--ignore=<patterns>]'.PHP_EOL;
echo ' [--bootstrap=<bootstrap>] <file> ...'.PHP_EOL;
echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>] <file> ...'.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;
Expand All @@ -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 ' <file> One or more files and/or directories to check'.PHP_EOL;
echo ' <bootstrap> A file to run before processing sniffs'.PHP_EOL;
echo ' <bootstrap> A comma separated list of files to run before processing starts'.PHP_EOL;
echo ' <encoding> The encoding of the files being checked (default is iso-8859-1)'.PHP_EOL;
echo ' <extensions> A comma separated list of file extensions to check'.PHP_EOL;
echo ' (extension filtering only valid when checking a directory)'.PHP_EOL;
Expand Down Expand Up @@ -1234,8 +1234,7 @@ public function printPHPCBFUsage()
echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--suffix=<suffix>]'.PHP_EOL;
echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>]'.PHP_EOL;
echo ' [--extensions=<extensions>] [--ignore=<patterns>]'.PHP_EOL;
echo ' [--bootstrap=<bootstrap>] <file> ...'.PHP_EOL;
echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>] <file> ...'.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;
Expand All @@ -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 ' <file> One or more files and/or directories to fix'.PHP_EOL;
echo ' <bootstrap> A file to run before processing sniffs'.PHP_EOL;
echo ' <bootstrap> A comma separated list of files to run before processing starts'.PHP_EOL;
echo ' <encoding> The encoding of the files being fixed (default is iso-8859-1)'.PHP_EOL;
echo ' <extensions> A comma separated list of file extensions to fix'.PHP_EOL;
echo ' (extension filtering only valid when checking a directory)'.PHP_EOL;
Expand Down
8 changes: 6 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
<date>2015-11-24</date>
<time>08:26:00</time>
<version>
<release>2.4.1</release>
<api>2.4.1</api>
<release>2.5.0</release>
<api>2.5.0</api>
</version>
<stability>
<release>stable</release>
Expand All @@ -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
Expand Down

0 comments on commit fd8a382

Please sign in to comment.