Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/phpcs-fixer' into phar
Browse files Browse the repository at this point in the history
Conflicts:
	CodeSniffer.php
	CodeSniffer/CLI.php
  • Loading branch information
Benjamin Pearson committed Jan 22, 2014
2 parents 9b2bb87 + 472bfb3 commit d3ac790
Show file tree
Hide file tree
Showing 332 changed files with 6,758 additions and 7,471 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ php:
script:
- phpunit tests/AllTests.php
- pear package-validate package.xml
- php scripts/phpcs CodeSniffer.php CodeSniffer --standard=PEAR --report=summary --ignore=*/tests/* -np
- php scripts/phpcs CodeSniffer.php CodeSniffer --standard=PHPCS --report=summary -np
53 changes: 30 additions & 23 deletions CodeSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_File not found');
}

if (class_exists('PHP_CodeSniffer_Fixer', true) === false) {
throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Fixer not found');
}

if (class_exists('PHP_CodeSniffer_Tokens', true) === false) {
throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Tokens not found');
}
Expand Down Expand Up @@ -69,14 +73,14 @@ class PHP_CodeSniffer
*
* @var string
*/
const VERSION = '1.5.2';
const VERSION = '1.6.0a1';

/**
* Package stability; either stable or beta.
* Package stability; either stable, beta or alpha.
*
* @var string
*/
const STABILITY = 'stable';
const STABILITY = 'alpha';

/**
* The file or directory that is currently being processed.
Expand Down Expand Up @@ -236,6 +240,10 @@ public function __construct(
define('PHPCS_DEFAULT_WARN_SEV', 5);
}

if (defined('PHP_CODESNIFFER_CBF') === false) {
define('PHP_CODESNIFFER_CBF', false);
}

// Set default CLI object in case someone is running us
// without using the command line script.
$this->cli = new PHP_CodeSniffer_CLI();
Expand Down Expand Up @@ -399,9 +407,9 @@ public function process($files, $standards, array $restrictions=array(), $local=
}

// Reset the members.
$this->listeners = array();
$this->sniffs = array();
$this->ruleset = array();
$this->listeners = array();
$this->sniffs = array();
$this->ruleset = array();
$this->_tokenListeners = array();
self::$rulesetDirs = array();

Expand Down Expand Up @@ -477,12 +485,12 @@ public function process($files, $standards, array $restrictions=array(), $local=
}

$numProcessed = 0;
$dots = 0;
$maxLength = strlen($numFiles);
$lastDir = '';
$dots = 0;
$maxLength = strlen($numFiles);
$lastDir = '';
foreach ($todo as $file) {
$this->file = $file;
$currDir = dirname($file);
$currDir = dirname($file);
if ($lastDir !== $currDir) {
if (PHP_CODESNIFFER_VERBOSITY > 0) {
echo 'Changing into directory '.$currDir.PHP_EOL;
Expand Down Expand Up @@ -566,7 +574,7 @@ public function processRuleset($rulesetPath, $depth=0)
$includedSniffs = array();
$excludedSniffs = array();

$rulesetDir = dirname($rulesetPath);
$rulesetDir = dirname($rulesetPath);
self::$rulesetDirs[] = $rulesetDir;

if (is_dir($rulesetDir.'/Sniffs') === true) {
Expand Down Expand Up @@ -1386,7 +1394,8 @@ public function processFile($file, $contents=null, $restrictions=array())
$filename = (string) $filename;
}

$error = 'An error occurred during processing; checking has been aborted. The error message was: '.$e->getMessage();
$errorMessage = '"'.$e->getMessage().'" at '.$e->getFile().':'.$e->getLine();
$error = "An error occurred during processing; checking has been aborted. The error message was: $errorMessage";

$phpcsFile = new PHP_CodeSniffer_File(
$filename,
Expand All @@ -1405,6 +1414,7 @@ public function processFile($file, $contents=null, $restrictions=array())
if (PHP_CODESNIFFER_INTERACTIVE === false) {
// Cache the report data for this file so we can unset it to save memory.
$this->reporting->cacheFileReport($phpcsFile, $cliValues);
$phpcsFile->cleanUp();
return $phpcsFile;
}

Expand All @@ -1424,7 +1434,7 @@ public function processFile($file, $contents=null, $restrictions=array())

$reportClass = $this->reporting->factory('full');
$reportData = $this->reporting->prepareFileReport($phpcsFile);
$reportClass->generateFileReport($reportData, $cliValues['showSources'], $cliValues['reportWidth']);
$reportClass->generateFileReport($reportData, $phpcsFile, $cliValues['showSources'], $cliValues['reportWidth']);

echo '<ENTER> to recheck, [s] to skip or [q] to quit : ';
$input = fgets(STDIN);
Expand Down Expand Up @@ -1485,7 +1495,6 @@ private function _processFile($file, $contents, $restrictions)
);

$phpcsFile->start($contents);
$phpcsFile->cleanUp();

if (PHP_CODESNIFFER_VERBOSITY > 0) {
$timeTaken = (time() - $startTime);
Expand Down Expand Up @@ -1814,7 +1823,7 @@ public static function isCamelCaps(

if ($strict === true) {
// Check that there are not two capital letters next to each other.
$length = strlen($string);
$length = strlen($string);
$lastCharWasCaps = $classFormat;

for ($i = 1; $i < $length; $i++) {
Expand Down Expand Up @@ -1966,7 +1975,7 @@ public static function suggestType($varType)
* look in its default locations.
*
* @return array
* @see isInstalledStandard()
* @see isInstalledStandard()
*/
public static function getInstalledStandards(
$includeGeneric=false,
Expand Down Expand Up @@ -2020,7 +2029,7 @@ public static function getInstalledStandards(
* @param string $standard The name of the coding standard.
*
* @return boolean
* @see getInstalledStandards()
* @see getInstalledStandards()
*/
public static function isInstalledStandard($standard)
{
Expand Down Expand Up @@ -2095,8 +2104,8 @@ public static function getInstalledStandardPath($standard)
* @param string $key The name of the config value.
*
* @return string|null
* @see setConfigData()
* @see getAllConfigData()
* @see setConfigData()
* @see getAllConfigData()
*/
public static function getConfigData($key)
{
Expand Down Expand Up @@ -2130,7 +2139,7 @@ public static function getConfigData($key)
* data to the config file.
*
* @return boolean
* @see getConfigData()
* @see getConfigData()
* @throws PHP_CodeSniffer_Exception If the config file can not be written.
*/
public static function setConfigData($key, $value, $temp=false)
Expand Down Expand Up @@ -2184,7 +2193,7 @@ public static function setConfigData($key, $value, $temp=false)
* Get all config data in an array.
*
* @return string
* @see getConfigData()
* @see getConfigData()
*/
public static function getAllConfigData()
{
Expand Down Expand Up @@ -2305,5 +2314,3 @@ public static function chdir($path)


}//end class

?>
Loading

0 comments on commit d3ac790

Please sign in to comment.