Skip to content

Commit

Permalink
PHPCBF fixes for new multiple statement alignment rules
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jan 20, 2014
1 parent fdd01c2 commit 0f7d9dc
Show file tree
Hide file tree
Showing 41 changed files with 194 additions and 197 deletions.
22 changes: 11 additions & 11 deletions CodeSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,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 @@ -479,9 +479,9 @@ 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);
Expand Down Expand Up @@ -524,7 +524,7 @@ public function process($files, $standards, array $restrictions=array(), $local=
echo str_repeat(' ', $padding);
$percent = round($numProcessed / $numFiles * 100);
echo " $numProcessed / $numFiles ($percent%)".PHP_EOL;
$dots = 0;
$dots = 0;
}
}//end foreach

Expand Down Expand Up @@ -568,7 +568,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 @@ -1329,8 +1329,8 @@ public function processFile($file, $contents=null, $restrictions=array())
if ($contents === null && is_readable($filePath) === true) {
$handle = fopen($filePath, 'r');
if ($handle !== false) {
$firstContent = fgets($handle);
$firstContent .= fgets($handle);
$firstContent = fgets($handle);
$firstContent.= fgets($handle);
fclose($handle);

if (strpos($firstContent, '@codingStandardsIgnoreFile') !== false) {
Expand Down Expand Up @@ -1796,7 +1796,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
38 changes: 19 additions & 19 deletions CodeSniffer/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ public function checkRequirements()
public function getDefaults()
{
// The default values for config settings.
$defaults['files'] = array();
$defaults['standard'] = null;
$defaults['verbosity'] = 0;
$defaults['interactive'] = false;
$defaults['explain'] = false;
$defaults['local'] = false;
$defaults['showSources'] = false;
$defaults['extensions'] = array();
$defaults['sniffs'] = array();
$defaults['ignored'] = array();
$defaults['reportFile'] = null;
$defaults['generator'] = '';
$defaults['reports'] = array();
$defaults['files'] = array();
$defaults['standard'] = null;
$defaults['verbosity'] = 0;
$defaults['interactive'] = false;
$defaults['explain'] = false;
$defaults['local'] = false;
$defaults['showSources'] = false;
$defaults['extensions'] = array();
$defaults['sniffs'] = array();
$defaults['ignored'] = array();
$defaults['reportFile'] = null;
$defaults['generator'] = '';
$defaults['reports'] = array();
$defaults['errorSeverity'] = null;
$defaults['warningSeverity'] = null;

Expand Down Expand Up @@ -329,7 +329,7 @@ public function processLongArgument($arg, $pos, $values)
print_r($data);
exit(0);
case 'runtime-set':
$key = $_SERVER['argv'][($pos + 1)];
$key = $_SERVER['argv'][($pos + 1)];
$value = $_SERVER['argv'][($pos + 2)];
$_SERVER['argv'][($pos + 1)] = '';
$_SERVER['argv'][($pos + 2)] = '';
Expand Down Expand Up @@ -443,8 +443,8 @@ public function processLongArgument($arg, $pos, $values)
if ($eqPos === false) {
$values[$arg] = $arg;
} else {
$value = substr($arg, ($eqPos + 1));
$arg = substr($arg, 0, $eqPos);
$value = substr($arg, ($eqPos + 1));
$arg = substr($arg, 0, $eqPos);
$values[$arg] = $value;
}
} else {
Expand Down Expand Up @@ -747,7 +747,7 @@ public function validateStandard($standards)
*/
public function explainStandard($standard)
{
$phpcs = new PHP_CodeSniffer();
$phpcs = new PHP_CodeSniffer();
$phpcs->process(array(), $standard);
$sniffs = $phpcs->getSniffs();
$sniffs = array_keys($sniffs);
Expand Down Expand Up @@ -914,8 +914,8 @@ public function printInstalledStandards()
if ($numStandards === 1) {
echo "The only coding standard installed is $lastStandard".PHP_EOL;
} else {
$standardList = implode(', ', $installedStandards);
$standardList .= ' and '.$lastStandard;
$standardList = implode(', ', $installedStandards);
$standardList.= ' and '.$lastStandard;
echo 'The installed coding standards are '.$standardList.PHP_EOL;
}
}
Expand Down
2 changes: 1 addition & 1 deletion CodeSniffer/DocGenerators/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function generate()
*/
protected function getStandardFiles()
{
$phpcs = new PHP_CodeSniffer();
$phpcs = new PHP_CodeSniffer();
$phpcs->process(array(), $this->_standard);
$sniffs = $phpcs->getSniffs();

Expand Down
2 changes: 1 addition & 1 deletion CodeSniffer/DocGenerators/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function printToc($standardFiles)
$doc = new DOMDocument();
$doc->load($standard);
$documentation = $doc->getElementsByTagName('documentation')->item(0);
$title = $this->getTitle($documentation);
$title = $this->getTitle($documentation);
echo ' <li><a href="#'.str_replace(' ', '-', $title)."\">$title</a></li>".PHP_EOL;
}

Expand Down
16 changes: 8 additions & 8 deletions CodeSniffer/DocGenerators/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ protected function printCodeComparisonBlock($node)

$firstTitleLines = array();
$tempTitle = '';
$words = explode(' ', $firstTitle);
$words = explode(' ', $firstTitle);

foreach ($words as $word) {
if (strlen($tempTitle.$word) >= 45) {
if (strlen($tempTitle.$word) === 45) {
// Adding the extra space will push us to the edge
// so we are done.
$firstTitleLines[] = $tempTitle.$word;
$tempTitle = '';
$tempTitle = '';
} else if (strlen($tempTitle.$word) === 46) {
// We are already at the edge, so we are done.
$firstTitleLines[] = $tempTitle.$word;
$tempTitle = '';
$tempTitle = '';
} else {
$firstTitleLines[] = $tempTitle;
$tempTitle = $word;
$tempTitle = $word;
}
} else {
$tempTitle .= $word.' ';
Expand All @@ -178,22 +178,22 @@ protected function printCodeComparisonBlock($node)

$secondTitleLines = array();
$tempTitle = '';
$words = explode(' ', $secondTitle);
$words = explode(' ', $secondTitle);

foreach ($words as $word) {
if (strlen($tempTitle.$word) >= 45) {
if (strlen($tempTitle.$word) === 45) {
// Adding the extra space will push us to the edge
// so we are done.
$secondTitleLines[] = $tempTitle.$word;
$tempTitle = '';
$tempTitle = '';
} else if (strlen($tempTitle.$word) === 46) {
// We are already at the edge, so we are done.
$secondTitleLines[] = $tempTitle.$word;
$tempTitle = '';
$tempTitle = '';
} else {
$secondTitleLines[] = $tempTitle;
$tempTitle = $word;
$tempTitle = $word;
}
} else {
$tempTitle .= $word.' ';
Expand Down
50 changes: 25 additions & 25 deletions CodeSniffer/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,10 @@ public function start($contents=null)
$this->_fixableCount = 0;
return;
} else if (strpos($token['content'], '@codingStandardsChangeSetting') !== false) {
$start = strpos($token['content'], '@codingStandardsChangeSetting');
$comment = substr($token['content'], $start + 30);
$parts = explode(' ', $comment);
$sniffParts = explode('.', $parts[0]);
$start = strpos($token['content'], '@codingStandardsChangeSetting');
$comment = substr($token['content'], $start + 30);
$parts = explode(' ', $comment);
$sniffParts = explode('.', $parts[0]);
$listenerClass = $sniffParts[0].'_Sniffs_'.$sniffParts[1].'_'.$sniffParts[2].'Sniff';
$this->phpcs->setSniffProperty($listenerClass, $parts[1], $parts[2]);
}//end if
Expand Down Expand Up @@ -667,8 +667,8 @@ public function start($contents=null)
*/
public function cleanUp()
{
$this->_tokens = null;
$this->_listeners = null;
$this->_tokens = null;
$this->_listeners = null;
$this->_listenerIgnoreTo = null;

}//end cleanUp()
Expand Down Expand Up @@ -1463,7 +1463,7 @@ private static function _createBracketMap(&$tokens, $tokenizer, $eolChar)
break;
case T_CLOSE_SQUARE_BRACKET:
if (empty($squareOpeners) === false) {
$opener = array_pop($squareOpeners);
$opener = array_pop($squareOpeners);
$tokens[$i]['bracket_opener'] = $opener;
$tokens[$i]['bracket_closer'] = $i;
$tokens[$opener]['bracket_opener'] = $opener;
Expand All @@ -1480,7 +1480,7 @@ private static function _createBracketMap(&$tokens, $tokenizer, $eolChar)
if (empty($curlyOpeners) === false
&& isset($tokens[$i]['scope_opener']) === false
) {
$opener = array_pop($curlyOpeners);
$opener = array_pop($curlyOpeners);
$tokens[$i]['bracket_opener'] = $opener;
$tokens[$i]['bracket_closer'] = $i;
$tokens[$opener]['bracket_opener'] = $opener;
Expand Down Expand Up @@ -1529,14 +1529,14 @@ private static function _createParenthesisMap(&$tokens, $tokenizer, $eolChar)
$tokens[$i]['parenthesis_opener'] = null;
$tokens[$i]['parenthesis_closer'] = null;
$tokens[$i]['parenthesis_owner'] = $i;
$openOwner = $i;
$openOwner = $i;
} else if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
$openers[] = $i;
$openers[] = $i;
$tokens[$i]['parenthesis_opener'] = $i;
if ($openOwner !== null) {
$tokens[$openOwner]['parenthesis_opener'] = $i;
$tokens[$i]['parenthesis_owner'] = $openOwner;
$openOwner = null;
$tokens[$i]['parenthesis_owner'] = $openOwner;
$openOwner = null;
}
} else if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
// Did we set an owner for this set of parenthesis?
Expand Down Expand Up @@ -2132,7 +2132,7 @@ private static function _createLevelMap(&$tokens, $tokenizer, $eolChar)
if ($tokens[$opener]['scope_closer'] === $i) {
$oldOpener = array_pop($openers);
if (empty($openers) === false) {
$lastOpener = array_pop($openers);
$lastOpener = array_pop($openers);
$openers[$lastOpener] = $lastOpener;
} else {
$lastOpener = null;
Expand Down Expand Up @@ -2323,8 +2323,8 @@ public function getMethodParameters($stackPtr)
$opener = $this->_tokens[$stackPtr]['parenthesis_opener'];
$closer = $this->_tokens[$stackPtr]['parenthesis_closer'];

$vars = array();
$currVar = null;
$vars = array();
$currVar = null;
$defaultStart = null;
$paramCount = 0;
$passByReference = false;
Expand Down Expand Up @@ -2384,7 +2384,7 @@ public function getMethodParameters($stackPtr)
continue;
}

$vars[$paramCount] = array();
$vars[$paramCount] = array();
$vars[$paramCount]['name'] = $this->_tokens[$currVar]['content'];

if ($defaultStart !== null) {
Expand All @@ -2396,7 +2396,7 @@ public function getMethodParameters($stackPtr)
}

$vars[$paramCount]['pass_by_reference'] = $passByReference;
$vars[$paramCount]['type_hint'] = $typeHint;
$vars[$paramCount]['type_hint'] = $typeHint;

// Reset the vars, as we are about to process the next parameter.
$defaultStart = null;
Expand Down Expand Up @@ -2456,7 +2456,7 @@ public function getMethodProperties($stackPtr)
T_DOC_COMMENT,
);

$scope = 'public';
$scope = 'public';
$scopeSpecified = false;
$isAbstract = false;
$isFinal = false;
Expand All @@ -2470,15 +2470,15 @@ public function getMethodProperties($stackPtr)

switch ($this->_tokens[$i]['code']) {
case T_PUBLIC:
$scope = 'public';
$scope = 'public';
$scopeSpecified = true;
break;
case T_PRIVATE:
$scope = 'private';
$scope = 'private';
$scopeSpecified = true;
break;
case T_PROTECTED:
$scope = 'protected';
$scope = 'protected';
$scopeSpecified = true;
break;
case T_ABSTRACT:
Expand Down Expand Up @@ -2568,7 +2568,7 @@ public function getMemberProperties($stackPtr)
T_COMMA,
);

$scope = 'public';
$scope = 'public';
$scopeSpecified = false;
$isStatic = false;

Expand All @@ -2579,15 +2579,15 @@ public function getMemberProperties($stackPtr)

switch ($this->_tokens[$i]['code']) {
case T_PUBLIC:
$scope = 'public';
$scope = 'public';
$scopeSpecified = true;
break;
case T_PRIVATE:
$scope = 'private';
$scope = 'private';
$scopeSpecified = true;
break;
case T_PROTECTED:
$scope = 'protected';
$scope = 'protected';
$scopeSpecified = true;
break;
case T_STATIC:
Expand Down
2 changes: 1 addition & 1 deletion CodeSniffer/Fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public function replaceToken($stackPtr, $content)

$this->_tokens[$stackPtr] = $content;
$this->_numFixes++;
$this->_fixedTokens[] = $stackPtr;
$this->_fixedTokens[] = $stackPtr;

if (PHP_CODESNIFFER_VERBOSITY > 1) {
$indent = "\t";
Expand Down
Loading

0 comments on commit 0f7d9dc

Please sign in to comment.