From 0f7d9dc438760178bbcd695f4b3a8346c19beab0 Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Mon, 20 Jan 2014 11:43:25 +1100 Subject: [PATCH] PHPCBF fixes for new multiple statement alignment rules --- CodeSniffer.php | 22 ++++---- CodeSniffer/CLI.php | 38 +++++++------- CodeSniffer/DocGenerators/Generator.php | 2 +- CodeSniffer/DocGenerators/HTML.php | 2 +- CodeSniffer/DocGenerators/Text.php | 16 +++--- CodeSniffer/File.php | 50 +++++++++---------- CodeSniffer/Fixer.php | 2 +- .../Standards/AbstractPatternSniff.php | 20 ++++---- .../UselessOverridingMethodSniff.php | 2 +- .../Generic/Sniffs/Commenting/FixmeSniff.php | 4 +- .../Generic/Sniffs/Files/LineLengthSniff.php | 2 +- .../Sniffs/Files/LowercasedFilenameSniff.php | 2 +- .../MultipleStatementAlignmentSniff.php | 4 +- .../Sniffs/PHP/ForbiddenFunctionsSniff.php | 6 +-- .../Sniffs/WhiteSpace/ScopeIndentSniff.php | 2 +- .../Sniffs/Channels/IncludeSystemSniff.php | 8 +-- .../Commenting/FunctionCommentSniff.php | 2 +- .../Sniffs/Commenting/InlineCommentSniff.php | 4 +- .../PEAR/Sniffs/Files/IncludingFileSniff.php | 16 +++--- .../Formatting/MultiLineAssignmentSniff.php | 2 +- .../Functions/FunctionCallSignatureSniff.php | 2 +- .../Functions/FunctionDeclarationSniff.php | 2 +- .../ValidFunctionNameSniff.php | 6 +-- .../ValidVariableNameSniff.php | 6 +-- .../Sniffs/Classes/ClassDeclarationSniff.php | 4 +- .../SwitchDeclarationSniff.php | 2 +- .../Sniffs/Arrays/ArrayDeclarationSniff.php | 12 ++--- .../CSS/DuplicateClassDefinitionSniff.php | 2 +- .../Classes/SelfMemberReferenceSniff.php | 8 +-- .../Sniffs/Commenting/BlockCommentSniff.php | 36 ++++++------- .../Commenting/FunctionCommentSniff.php | 2 +- .../SwitchDeclarationSniff.php | 2 +- .../IncrementDecrementUsageSniff.php | 2 +- .../Sniffs/PHP/CommentedOutCodeSniff.php | 2 +- .../Sniffs/PHP/NonExecutableCodeSniff.php | 12 ++--- .../Sniffs/Strings/DoubleQuoteUsageSniff.php | 4 +- .../WhiteSpace/FunctionSpacingSniff.php | 4 +- CodeSniffer/Tokenizers/CSS.php | 8 +-- CodeSniffer/Tokenizers/JS.php | 46 ++++++++--------- CodeSniffer/Tokenizers/PHP.php | 16 +++--- scripts/phpcbf | 7 +-- 41 files changed, 194 insertions(+), 197 deletions(-) diff --git a/CodeSniffer.php b/CodeSniffer.php index 1314fe1f7d..5d4be6dd95 100644 --- a/CodeSniffer.php +++ b/CodeSniffer.php @@ -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(); @@ -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); @@ -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 @@ -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) { @@ -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) { @@ -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++) { diff --git a/CodeSniffer/CLI.php b/CodeSniffer/CLI.php index 976a5b0b42..de205b3866 100644 --- a/CodeSniffer/CLI.php +++ b/CodeSniffer/CLI.php @@ -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; @@ -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)] = ''; @@ -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 { @@ -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); @@ -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; } } diff --git a/CodeSniffer/DocGenerators/Generator.php b/CodeSniffer/DocGenerators/Generator.php index 6b89b46dc7..06ed91ad8f 100644 --- a/CodeSniffer/DocGenerators/Generator.php +++ b/CodeSniffer/DocGenerators/Generator.php @@ -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(); diff --git a/CodeSniffer/DocGenerators/HTML.php b/CodeSniffer/DocGenerators/HTML.php index ef2e7c79be..0ac2fc8855 100644 --- a/CodeSniffer/DocGenerators/HTML.php +++ b/CodeSniffer/DocGenerators/HTML.php @@ -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 '
  • $title
  • ".PHP_EOL; } diff --git a/CodeSniffer/DocGenerators/Text.php b/CodeSniffer/DocGenerators/Text.php index 3a58a87d77..48bebf23d6 100644 --- a/CodeSniffer/DocGenerators/Text.php +++ b/CodeSniffer/DocGenerators/Text.php @@ -143,7 +143,7 @@ protected function printCodeComparisonBlock($node) $firstTitleLines = array(); $tempTitle = ''; - $words = explode(' ', $firstTitle); + $words = explode(' ', $firstTitle); foreach ($words as $word) { if (strlen($tempTitle.$word) >= 45) { @@ -151,14 +151,14 @@ protected function printCodeComparisonBlock($node) // 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.' '; @@ -178,7 +178,7 @@ protected function printCodeComparisonBlock($node) $secondTitleLines = array(); $tempTitle = ''; - $words = explode(' ', $secondTitle); + $words = explode(' ', $secondTitle); foreach ($words as $word) { if (strlen($tempTitle.$word) >= 45) { @@ -186,14 +186,14 @@ protected function printCodeComparisonBlock($node) // 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.' '; diff --git a/CodeSniffer/File.php b/CodeSniffer/File.php index 0dbbfc135b..34d52bd234 100644 --- a/CodeSniffer/File.php +++ b/CodeSniffer/File.php @@ -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 @@ -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() @@ -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; @@ -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; @@ -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? @@ -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; @@ -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; @@ -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) { @@ -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; @@ -2456,7 +2456,7 @@ public function getMethodProperties($stackPtr) T_DOC_COMMENT, ); - $scope = 'public'; + $scope = 'public'; $scopeSpecified = false; $isAbstract = false; $isFinal = false; @@ -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: @@ -2568,7 +2568,7 @@ public function getMemberProperties($stackPtr) T_COMMA, ); - $scope = 'public'; + $scope = 'public'; $scopeSpecified = false; $isStatic = false; @@ -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: diff --git a/CodeSniffer/Fixer.php b/CodeSniffer/Fixer.php index 016384723e..44017a0a35 100644 --- a/CodeSniffer/Fixer.php +++ b/CodeSniffer/Fixer.php @@ -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"; diff --git a/CodeSniffer/Standards/AbstractPatternSniff.php b/CodeSniffer/Standards/AbstractPatternSniff.php index 17d7897b20..49c351b96e 100644 --- a/CodeSniffer/Standards/AbstractPatternSniff.php +++ b/CodeSniffer/Standards/AbstractPatternSniff.php @@ -109,8 +109,8 @@ public final function register() // Find a token position in the pattern that we can use // for a listener token. - $pos = $this->_getListenerTokenPos($parsedPattern); - $tokenType = $parsedPattern[$pos]['token']; + $pos = $this->_getListenerTokenPos($parsedPattern); + $tokenType = $parsedPattern[$pos]['token']; $listenTypes[] = $tokenType; $patternArray = array( @@ -435,7 +435,7 @@ protected function processPattern( }//end for }//end if - $stackPtr = $origStackPtr; + $stackPtr = $origStackPtr; $lastAddedStackPtr = null; $patternLen = count($pattern); @@ -478,7 +478,7 @@ protected function processPattern( ); $lastAddedStackPtr = $stackPtr; - $stackPtr = $next; + $stackPtr = $next; }//end if if ($stackPtr !== $lastAddedStackPtr) { @@ -486,7 +486,7 @@ protected function processPattern( } } else { if ($stackPtr !== $lastAddedStackPtr) { - $found .= $tokens[$stackPtr]['content']; + $found .= $tokens[$stackPtr]['content']; $lastAddedStackPtr = $stackPtr; } }//end if @@ -578,7 +578,7 @@ protected function processPattern( }//end if if ($next !== $lastAddedStackPtr) { - $found .= $tokens[$next]['content']; + $found .= $tokens[$next]['content']; $lastAddedStackPtr = $next; } @@ -636,7 +636,7 @@ protected function processPattern( } if ($stackPtr !== $lastAddedStackPtr) { - $found .= 'abc'; + $found .= 'abc'; $lastAddedStackPtr = $stackPtr; } @@ -804,7 +804,7 @@ private function _parse($pattern) $specialPattern = $this->_createSkipPattern($pattern, ($i - 1)); $lastToken = ($i - $firstToken); $firstToken = ($i + 3); - $i = ($i + 2); + $i = ($i + 2); if ($specialPattern['to'] !== 'unknown') { $firstToken++; @@ -813,12 +813,12 @@ private function _parse($pattern) $specialPattern = array('type' => 'string'); $lastToken = ($i - $firstToken); $firstToken = ($i + 3); - $i = ($i + 2); + $i = ($i + 2); } else if (substr($pattern, $i, 3) === 'EOL') { $specialPattern = array('type' => 'newline'); $lastToken = ($i - $firstToken); $firstToken = ($i + 3); - $i = ($i + 2); + $i = ($i + 2); }//end if if ($specialPattern !== false || $isLastChar === true) { diff --git a/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php b/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php index 6e2c30b3da..958dca6727 100644 --- a/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php +++ b/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php @@ -132,7 +132,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $parameters = array(''); $parenthesisCount = 1; - $count = count($tokens); + $count = count($tokens); for (++$next; $next < $count; ++$next) { $code = $tokens[$next]['code']; diff --git a/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php b/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php index bdccc3410b..dd914366d0 100644 --- a/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php +++ b/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php @@ -71,11 +71,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) if (preg_match('/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches) !== 0) { // Clear whitespace and some common characters not required at // the end of a fixme message to make the error more informative. - $type = 'CommentFound'; + $type = 'CommentFound'; $fixmeMessage = trim($matches[1]); $fixmeMessage = trim($fixmeMessage, '-:[](). '); $error = 'Comment refers to a FIXME task'; - $data = array($fixmeMessage); + $data = array($fixmeMessage); if ($fixmeMessage !== '') { $type = 'TaskFound'; $error .= ' "%s"'; diff --git a/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php b/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php index 724c5fa332..4223cb3e92 100644 --- a/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php +++ b/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php @@ -74,7 +74,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $tokenCount = 0; + $tokenCount = 0; $currentLineContent = ''; $currentLine = 1; diff --git a/CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php b/CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php index aefe6f950c..7d30ee8201 100644 --- a/CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php +++ b/CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php @@ -50,7 +50,7 @@ public function register() */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { - $fileName = basename($phpcsFile->getFilename()); + $fileName = basename($phpcsFile->getFilename()); $lowercaseFileName = strtolower($fileName); if ($fileName !== $lowercaseFileName) { $data = array( diff --git a/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index f301530d8b..82837fcc6f 100644 --- a/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -246,8 +246,8 @@ public function checkAlignment(PHP_CodeSniffer_File $phpcsFile, $stackPtr) continue; } - $expectedText = $data['expected']; - $expectedText .= ($data['expected'] === 1) ? ' space' : ' spaces'; + $expectedText = $data['expected']; + $expectedText.= ($data['expected'] === 1) ? ' space' : ' spaces'; $foundText = $data['found']; if ($foundText === null) { diff --git a/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php b/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php index 6fbca34039..42f213735c 100644 --- a/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php +++ b/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php @@ -186,9 +186,9 @@ protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) } if ($this->forbiddenFunctions[$pattern] !== null) { - $type .= 'WithAlternative'; - $data[] = $this->forbiddenFunctions[$pattern]; - $error .= '; use %s() instead'; + $type .= 'WithAlternative'; + $data[] = $this->forbiddenFunctions[$pattern]; + $error.= '; use %s() instead'; } if ($this->error === true) { diff --git a/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 4d14507ef2..449f5e9848 100644 --- a/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -338,7 +338,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) continue; } - $contentLength = strlen($tokens[$firstToken]['content']); + $contentLength = strlen($tokens[$firstToken]['content']); $trimmedContentLength = strlen(ltrim($tokens[$firstToken]['content'])); diff --git a/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php b/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php index a5061a6cc4..7a9194474d 100644 --- a/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php +++ b/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php @@ -132,8 +132,8 @@ protected function processTokenWithinScope( $includedClasses[] = $name; // Special case for Widgets cause they are, well, special. } else if (strtolower($tokens[$i]['content']) === 'includewidget') { - $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($i + 1)); - $typeName = trim($tokens[$typeName]['content'], " '"); + $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($i + 1)); + $typeName = trim($tokens[$typeName]['content'], " '"); $includedClasses[] = strtolower($typeName).'widgettype'; } } @@ -279,8 +279,8 @@ protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $st $includedClasses[] = $name; // Special case for Widgets cause they are, well, special. } else if (strtolower($tokens[$i]['content']) === 'includewidget') { - $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($i + 1)); - $typeName = trim($tokens[$typeName]['content'], " '"); + $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($i + 1)); + $typeName = trim($tokens[$typeName]['content'], " '"); $includedClasses[] = strtolower($typeName).'widgettype'; } }//end for diff --git a/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index 578506a85f..b91b02a012 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -191,7 +191,7 @@ protected function processThrows(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co $exception = null; $comment = null; if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) { - $matches = array(); + $matches = array(); preg_match('/([^\s]+)(?:\s+(.*))?/', $tokens[($tag + 2)]['content'], $matches); $exception = $matches[1]; if (isset($matches[2]) === true) { diff --git a/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php index c72fdbcb9a..2941aebf4d 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php @@ -57,8 +57,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); if ($tokens[$stackPtr]['content']{0} === '#') { - $error = 'Perl-style comments are not allowed. Use "// Comment."'; - $error .= ' or "/* comment */" instead.'; + $error = 'Perl-style comments are not allowed. Use "// Comment."'; + $error.= ' or "/* comment */" instead.'; $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); } diff --git a/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php index 88c327c82e..479c8da1eb 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php @@ -108,23 +108,23 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) if ($inCondition === true) { // We are inside a conditional statement. We need an include_once. if ($tokenCode === T_REQUIRE_ONCE) { - $error = 'File is being conditionally included; '; - $error .= 'use "include_once" instead'; + $error = 'File is being conditionally included; '; + $error.= 'use "include_once" instead'; $phpcsFile->addError($error, $stackPtr, 'UseIncludeOnce'); } else if ($tokenCode === T_REQUIRE) { - $error = 'File is being conditionally included; '; - $error .= 'use "include" instead'; + $error = 'File is being conditionally included; '; + $error.= 'use "include" instead'; $phpcsFile->addError($error, $stackPtr, 'UseInclude'); } } else { // We are unconditionally including, we need a require_once. if ($tokenCode === T_INCLUDE_ONCE) { - $error = 'File is being unconditionally included; '; - $error .= 'use "require_once" instead'; + $error = 'File is being unconditionally included; '; + $error.= 'use "require_once" instead'; $phpcsFile->addError($error, $stackPtr, 'UseRequireOnce'); } else if ($tokenCode === T_INCLUDE) { - $error = 'File is being unconditionally included; '; - $error .= 'use "require" instead'; + $error = 'File is being unconditionally included; '; + $error.= 'use "require" instead'; $phpcsFile->addError($error, $stackPtr, 'UseRequire'); } }//end if diff --git a/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php index f1b9d2f58d..ba903e1b67 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php @@ -87,7 +87,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // Find the required indent based on the ident of the previous line. $assignmentIndent = 0; - $prevLine = $tokens[$prev]['line']; + $prevLine = $tokens[$prev]['line']; for ($i = ($prev - 1); $i >= 0; $i--) { if ($tokens[$i]['line'] !== $prevLine) { $i++; diff --git a/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index b417b91b6e..cdea70d92c 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -224,7 +224,7 @@ public function processMultiLineCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr, } $closeBracket = $tokens[$openBracket]['parenthesis_closer']; - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBracket - 1), null, true); + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBracket - 1), null, true); if ($tokens[$prev]['line'] === $tokens[$closeBracket]['line']) { $error = 'Closing parenthesis of a multi-line function call must be on a line by itself'; $fix = $phpcsFile->addFixableError($error, $closeBracket, 'CloseBracketLine'); diff --git a/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 8757c4dde5..b5964700be 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -224,7 +224,7 @@ public function processMultiLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $st if ($tokens[$stackPtr]['code'] === T_CLOSURE) { $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']); if ($use !== false) { - $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1)); + $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1)); $closeBracket = $tokens[$open]['parenthesis_closer']; $prev = $phpcsFile->findPrevious( diff --git a/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php index 356919c331..ba727bdaf1 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -118,9 +118,9 @@ protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $sta return; } - $methodProps = $phpcsFile->getMethodProperties($stackPtr); - $isPublic = ($methodProps['scope'] === 'private') ? false : true; - $scope = $methodProps['scope']; + $methodProps = $phpcsFile->getMethodProperties($stackPtr); + $isPublic = ($methodProps['scope'] === 'private') ? false : true; + $scope = $methodProps['scope']; $scopeSpecified = $methodProps['scope_specified']; // If it's a private method, it must have an underscore on the front. diff --git a/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php index c1dbcc3153..1ddbbb66f3 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -52,9 +52,9 @@ protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) return; } - $memberName = ltrim($tokens[$stackPtr]['content'], '$'); - $isPublic = ($memberProps['scope'] === 'private') ? false : true; - $scope = $memberProps['scope']; + $memberName = ltrim($tokens[$stackPtr]['content'], '$'); + $isPublic = ($memberProps['scope'] === 'private') ? false : true; + $scope = $memberProps['scope']; $scopeSpecified = $memberProps['scope_specified']; // If it's a private member, it must have an underscore on the front. diff --git a/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php index dd73e8b76c..653f1ad4a4 100644 --- a/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +++ b/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php @@ -211,7 +211,7 @@ public function processOpen(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $keywordTokenType = T_IMPLEMENTS; } - $implements = $phpcsFile->findNext($keywordTokenType, ($stackPtr + 1), $openingBrace); + $implements = $phpcsFile->findNext($keywordTokenType, ($stackPtr + 1), $openingBrace); $multiLineImplements = false; if ($implements !== false) { $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($implements + 1), $openingBrace, true); @@ -232,7 +232,7 @@ public function processOpen(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $nextClass = $phpcsFile->findNext($find, ($nextClass + 1), ($openingBrace - 1)); } - $classCount = count($classNames); + $classCount = count($classNames); $checkingImplements = false; foreach ($classNames as $i => $className) { if ($tokens[$className]['code'] == $keywordTokenType) { diff --git a/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 28501a4e0a..bc557eb455 100644 --- a/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -76,7 +76,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) while (($nextCase = $this->_findNextCase($phpcsFile, ($nextCase + 1), $switch['scope_closer'])) !== false) { if ($tokens[$nextCase]['code'] === T_DEFAULT) { - $type = 'default'; + $type = 'default'; $foundDefault = true; } else { $type = 'case'; diff --git a/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index c9135034e2..6fbcf02f7e 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -365,7 +365,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } $currentEntry['arrow'] = $nextToken; - $keyUsed = true; + $keyUsed = true; // Find the start of index that uses this double arrow. $indexEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($nextToken - 1), $arrayStart, true); @@ -377,7 +377,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $index = ($indexStart + 1); } - $currentEntry['index'] = $index; + $currentEntry['index'] = $index; $currentEntry['index_content'] = $phpcsFile->getTokensAsString($index, ($indexEnd - $index + 1)); $indexLength = strlen($currentEntry['index_content']); @@ -386,10 +386,10 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } // Find the value of this index. - $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($nextToken + 1), $arrayEnd, true); + $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($nextToken + 1), $arrayEnd, true); $currentEntry['value'] = $nextContent; - $indices[] = $currentEntry; - $lastToken = T_DOUBLE_ARROW; + $indices[] = $currentEntry; + $lastToken = T_DOUBLE_ARROW; }//end if }//end while @@ -641,7 +641,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) for ($i = ($index['value'] + 1); $i < $arrayEnd; $i++) { // Skip bracketed statements, like function calls. if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { - $i = $tokens[$i]['parenthesis_closer']; + $i = $tokens[$i]['parenthesis_closer']; $valueLine = $tokens[$i]['line']; continue; } diff --git a/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php index e8ec970746..a8de649365 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php @@ -92,7 +92,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $names = explode(',', $name); sort($names); - $name = implode(',', $names); + $name = implode(',', $names); if (isset($classNames[$name]) === true) { $first = $classNames[$name]; diff --git a/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php index daf3a98f3d..3c477e3cc0 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php @@ -80,10 +80,10 @@ protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $sta // If the class is called with a namespace prefix, build fully qualified // namespace calls for both current scope class and requested class. if ($tokens[($className - 1)]['code'] === T_NS_SEPARATOR) { - $declarationName = $this->getDeclarationNameWithNamespace($tokens, $className); - $declarationName = substr($declarationName, 1); - $fullQualifiedClassName = $this->getNamespaceOfScope($phpcsFile, $currScope); - $fullQualifiedClassName .= '\\'.$tokens[$className]['content']; + $declarationName = $this->getDeclarationNameWithNamespace($tokens, $className); + $declarationName = substr($declarationName, 1); + $fullQualifiedClassName = $this->getNamespaceOfScope($phpcsFile, $currScope); + $fullQualifiedClassName.= '\\'.$tokens[$className]['content']; } if ($declarationName === $fullQualifiedClassName) { diff --git a/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php index 7600adb5cb..54f07f0d91 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php @@ -188,12 +188,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $commentText = ltrim($content); $leadingSpace = (strlen($content) - strlen($commentText)); if ($leadingSpace !== $starColumn) { - $expected = $starColumn; - $expected .= ($starColumn === 1) ? ' space' : ' spaces'; - $data = array( - $expected, - $leadingSpace, - ); + $expected = $starColumn; + $expected.= ($starColumn === 1) ? ' space' : ' spaces'; + $data = array( + $expected, + $leadingSpace, + ); $error = 'First line of comment not aligned correctly; expected %s but found %s'; $fix = $phpcsFile->addFixableError($error, $commentLines[1], 'FirstLineIndent', $data); @@ -228,12 +228,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } if ($leadingSpace < $starColumn) { - $expected = $starColumn; - $expected .= ($starColumn === 1) ? ' space' : ' spaces'; - $data = array( - $expected, - $leadingSpace, - ); + $expected = $starColumn; + $expected.= ($starColumn === 1) ? ' space' : ' spaces'; + $data = array( + $expected, + $leadingSpace, + ); $error = 'Comment line indented incorrectly; expected at least %s but found %s'; $fix = $phpcsFile->addFixableError($error, $line, 'LineIndent', $data); @@ -255,12 +255,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $commentText = ltrim($content); $leadingSpace = (strlen($content) - strlen($commentText)); if ($leadingSpace !== ($tokens[$stackPtr]['column'] - 1)) { - $expected = ($tokens[$stackPtr]['column'] - 1); - $expected .= ($expected === 1) ? ' space' : ' spaces'; - $data = array( - $expected, - $leadingSpace, - ); + $expected = ($tokens[$stackPtr]['column'] - 1); + $expected.= ($expected === 1) ? ' space' : ' spaces'; + $data = array( + $expected, + $leadingSpace, + ); $error = 'Last line of comment aligned incorrectly; expected %s but found %s'; $phpcsFile->addError($error, $commentLines[$lastIndex], 'LastLineIndent', $data); diff --git a/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index 53d2b8a43f..e44daef551 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -261,7 +261,7 @@ protected function processThrows(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co $exception = null; $comment = null; if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) { - $matches = array(); + $matches = array(); preg_match('/([^\s]+)(?:\s+(.*))?/', $tokens[($tag + 2)]['content'], $matches); $exception = $matches[1]; if (isset($matches[2]) === true) { diff --git a/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 0c034b512c..e1f5824cc6 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -95,7 +95,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } if ($tokens[$nextCase]['code'] === T_DEFAULT) { - $type = 'Default'; + $type = 'Default'; $foundDefault = true; } else { $type = 'Case'; diff --git a/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index 9840b3bfb9..9dcb6424f6 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -156,7 +156,7 @@ protected function processAssignment(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } if ($tokens[$stackPtr]['code'] === T_EQUAL) { - $nextVar = ($stackPtr + 1); + $nextVar = ($stackPtr + 1); $previousVariable = ($stackPtr + 1); $variableCount = 0; while (($nextVar = $phpcsFile->findNext(T_VARIABLE, ($nextVar + 1), $statementEnd)) !== false) { diff --git a/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php index 717ddef0a6..8ba14824c5 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php @@ -139,7 +139,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // Because we are not really parsing code, the tokenizer can throw all sorts // of errors that don't mean anything, so ignore them. - $oldErrors = ini_get('error_reporting'); + $oldErrors = ini_get('error_reporting'); ini_set('error_reporting', 0); $stringTokens = PHP_CodeSniffer_File::tokenizeString($content, $phpcsFile->tokenizer, $phpcsFile->eolChar); ini_set('error_reporting', $oldErrors); diff --git a/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index e25cd928cd..9fcd2d0606 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -132,9 +132,9 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $line = $tokens[$i]['line']; if ($line > $lastLine) { - $type = substr($tokens[$stackPtr]['type'], 2); - $warning = 'Code after %s statement cannot be executed'; - $data = array($type); + $type = substr($tokens[$stackPtr]['type'], 2); + $warning = 'Code after %s statement cannot be executed'; + $data = array($type); $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); $lastLine = $line; } @@ -256,9 +256,9 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $line = $tokens[$i]['line']; if ($line > $lastLine) { - $type = substr($tokens[$stackPtr]['type'], 2); - $warning = 'Code after %s statement cannot be executed'; - $data = array($type); + $type = substr($tokens[$stackPtr]['type'], 2); + $warning = 'Code after %s statement cannot be executed'; + $data = array($type); $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); $lastLine = $line; } diff --git a/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php index 754c6d8026..bbd04af518 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php @@ -68,8 +68,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $lastStringToken = $stackPtr; $i = ($stackPtr + 1); while ($tokens[$i]['code'] === $tokens[$stackPtr]['code']) { - $workingString .= $tokens[$i]['content']; - $lastStringToken = $i; + $workingString .= $tokens[$i]['content']; + $lastStringToken = $i; $i++; } diff --git a/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php index 24110b4738..250aa0ac11 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php @@ -181,8 +181,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // the previous function and no blank lines before this one as well. $currentLine = $tokens[$stackPtr]['line']; $prevLine = ($tokens[$prevContent]['line'] - 1); - $i = ($stackPtr - 1); - $foundLines = 0; + $i = ($stackPtr - 1); + $foundLines = 0; while ($currentLine !== $prevLine && $currentLine > 1 && $i > 0) { if (isset($tokens[$i]['scope_condition']) === true) { $scopeCondition = $tokens[$i]['scope_condition']; diff --git a/CodeSniffer/Tokenizers/CSS.php b/CodeSniffer/Tokenizers/CSS.php index b086756533..e6eb8cdb15 100644 --- a/CodeSniffer/Tokenizers/CSS.php +++ b/CodeSniffer/Tokenizers/CSS.php @@ -51,8 +51,8 @@ public function tokenizeString($string, $eolChar='\n') // the open and close tags we add are parsed correctly. $eolAdded = false; if (substr($string, (strlen($eolChar) * -1)) !== $eolChar) { - $string .= $eolChar; - $eolAdded = true; + $string .= $eolChar; + $eolAdded = true; } $tokens = parent::tokenizeString('', $eolChar); @@ -120,7 +120,7 @@ public function tokenizeString($string, $eolChar='\n') $moreTokens = parent::tokenizeString($content, $eolChar); array_shift($moreTokens); array_pop($moreTokens); - $lastSpace = array_pop($moreTokens); + $lastSpace = array_pop($moreTokens); if ($lastSpace['content'] !== ' ') { // The space we added before the closing tag was not the only // space at the end of the content, so add the whitespace back, @@ -182,7 +182,7 @@ public function tokenizeString($string, $eolChar='\n') && (substr($token['content'], 0, 2) === '//' || $token['content']{0} === '#') ) { - $content = ltrim($token['content'], '#/'); + $content = ltrim($token['content'], '#/'); $commentTokens = parent::tokenizeString('', $eolChar); diff --git a/CodeSniffer/Tokenizers/JS.php b/CodeSniffer/Tokenizers/JS.php index 6afa7640d5..d5704a8955 100644 --- a/CodeSniffer/Tokenizers/JS.php +++ b/CodeSniffer/Tokenizers/JS.php @@ -268,11 +268,11 @@ public function tokenizeString($string, $eolChar='\n') } } - $tokens = array(); - $inString = ''; - $stringChar = null; - $inComment = ''; - $buffer = ''; + $tokens = array(); + $inString = ''; + $stringChar = null; + $inComment = ''; + $buffer = ''; $preStringBuffer = ''; $cleanBuffer = false; @@ -379,7 +379,7 @@ public function tokenizeString($string, $eolChar='\n') echo "\t=> Added token T_CONSTANT_ENCAPSED_STRING ($content)".PHP_EOL; } - $buffer = ''; + $buffer = ''; $preStringBuffer = ''; $inString = ''; $stringChar = null; @@ -401,12 +401,12 @@ public function tokenizeString($string, $eolChar='\n') // end before the end of the line, which means it probably // wasn't a string at all (maybe a regex). if ($chars[($i - 1)] !== '\\') { - $i = $stringChar; - $buffer = $preStringBuffer; + $i = $stringChar; + $buffer = $preStringBuffer; $preStringBuffer = ''; $inString = ''; $stringChar = null; - $char = $chars[$i]; + $char = $chars[$i]; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo "\t\t* found newline before end of string, bailing *".PHP_EOL; @@ -447,8 +447,8 @@ public function tokenizeString($string, $eolChar='\n') echo "\t=> Added token T_REGULAR_EXPRESSION ($content)".PHP_EOL; } - $i = $regex['end']; - $buffer = ''; + $i = $regex['end']; + $buffer = ''; $cleanBuffer = false; continue; } @@ -802,8 +802,8 @@ public function tokenizeString($string, $eolChar='\n') $newToken['content'] .= $eolChar; } - $newToken['type'] = $token['type']; - $newToken['code'] = $token['code']; + $newToken['type'] = $token['type']; + $newToken['code'] = $token['code']; $finalTokens[$newStackPtr] = $newToken; $newStackPtr++; } @@ -1057,14 +1057,14 @@ public function processAdditional(&$tokens, $eolChar) } $closer = $tokens[$i]['bracket_closer']; - $tokens[$i]['scope_condition'] = $x; - $tokens[$i]['scope_closer'] = $closer; + $tokens[$i]['scope_condition'] = $x; + $tokens[$i]['scope_closer'] = $closer; $tokens[$closer]['scope_condition'] = $x; $tokens[$closer]['scope_opener'] = $i; - $tokens[$x]['scope_opener'] = $i; - $tokens[$x]['scope_closer'] = $closer; - $tokens[$x]['code'] = T_OBJECT; - $tokens[$x]['type'] = 'T_OBJECT'; + $tokens[$x]['scope_opener'] = $i; + $tokens[$x]['scope_closer'] = $closer; + $tokens[$x]['code'] = T_OBJECT; + $tokens[$x]['type'] = 'T_OBJECT'; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo str_repeat("\t", count($classStack)); @@ -1139,10 +1139,10 @@ public function processAdditional(&$tokens, $eolChar) if ($tokens[$x]['code'] === T_OPEN_CURLY_BRACKET) { $closer = $tokens[$x]['bracket_closer']; - $tokens[$label]['scope_opener'] = $x; - $tokens[$label]['scope_closer'] = $closer; - $tokens[$x]['scope_condition'] = $label; - $tokens[$x]['scope_closer'] = $closer; + $tokens[$label]['scope_opener'] = $x; + $tokens[$label]['scope_closer'] = $closer; + $tokens[$x]['scope_condition'] = $label; + $tokens[$x]['scope_closer'] = $closer; $tokens[$closer]['scope_condition'] = $label; $tokens[$closer]['scope_opener'] = $x; if (PHP_CODESNIFFER_VERBOSITY > 1) { diff --git a/CodeSniffer/Tokenizers/PHP.php b/CodeSniffer/Tokenizers/PHP.php index d3ac7203a2..83c2e2b40c 100644 --- a/CodeSniffer/Tokenizers/PHP.php +++ b/CodeSniffer/Tokenizers/PHP.php @@ -371,8 +371,8 @@ public function tokenizeString($string, $eolChar='\n') $newToken['content'] .= $eolChar; } - $newToken['code'] = T_DOUBLE_QUOTED_STRING; - $newToken['type'] = 'T_DOUBLE_QUOTED_STRING'; + $newToken['code'] = T_DOUBLE_QUOTED_STRING; + $newToken['type'] = 'T_DOUBLE_QUOTED_STRING'; $finalTokens[$newStackPtr] = $newToken; $newStackPtr++; } @@ -536,8 +536,8 @@ public function tokenizeString($string, $eolChar='\n') $newToken['content'] .= $eolChar; } - $newToken['type'] = $tokenName; - $newToken['code'] = $token[0]; + $newToken['type'] = $tokenName; + $newToken['code'] = $token[0]; $finalTokens[$newStackPtr] = $newToken; $newStackPtr++; } @@ -660,7 +660,7 @@ public function processAdditional(&$tokens, $eolChar) $tokens[$i]['code'] = T_OPEN_SHORT_ARRAY; $tokens[$i]['type'] = 'T_OPEN_SHORT_ARRAY'; - $closer = $tokens[$i]['bracket_closer']; + $closer = $tokens[$i]['bracket_closer']; $tokens[$closer]['code'] = T_CLOSE_SHORT_ARRAY; $tokens[$closer]['type'] = 'T_CLOSE_SHORT_ARRAY'; if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -752,9 +752,9 @@ public function processAdditional(&$tokens, $eolChar) // not whatever it already is. The opener needs to be the opening curly // brace so everything matches up. $newCloser = $tokens[$x]['bracket_closer']; - $tokens[$i]['scope_closer'] = $newCloser; - $tokens[$x]['scope_closer'] = $newCloser; - $tokens[$i]['scope_opener'] = $x; + $tokens[$i]['scope_closer'] = $newCloser; + $tokens[$x]['scope_closer'] = $newCloser; + $tokens[$i]['scope_opener'] = $x; $tokens[$x]['scope_condition'] = $i; $tokens[$newCloser]['scope_condition'] = $i; $tokens[$newCloser]['scope_opener'] = $x; diff --git a/scripts/phpcbf b/scripts/phpcbf index 7d911efbc9..2ff2968032 100755 --- a/scripts/phpcbf +++ b/scripts/phpcbf @@ -73,7 +73,6 @@ if ($suffix === '' && $allowPatch === true) { $numErrors = $phpcs->process($cliValues); - if ($suffix === '' && $allowPatch === true) { if (file_exists($diffFile) === false) { // Nothing to fix. @@ -101,7 +100,7 @@ if ($suffix === '' && $allowPatch === true) { echo "Returned: $retVal\n"; $exit = 3; } - } + }//end if } else { if ($numErrors === 0) { // No errors left unfixed. @@ -110,12 +109,10 @@ if ($suffix === '' && $allowPatch === true) { // Errors we can't fix. $exit = 2; } -} +}//end if if (class_exists('PHP_Timer', false) === true) { echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; } exit($exit); - -?>