@@ -37,7 +37,7 @@ |
||
| 37 | 37 | * |
| 38 | 38 | * @param string $testFile The name of the file being tested. |
| 39 | 39 | * |
| 40 | - * @return array |
|
| 40 | + * @return string[] |
|
| 41 | 41 | */ |
| 42 | 42 | public function getCliValues($testFile) |
| 43 | 43 | { |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | 48 => 1, |
| 58 | 58 | 70 => 1, |
| 59 | 59 | 71 => 1, |
| 60 | - ); |
|
| 60 | + ); |
|
| 61 | 61 | |
| 62 | 62 | }//end getErrorList() |
| 63 | 63 | |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | /** |
| 36 | 36 | * Should this test be skipped for some reason. |
| 37 | 37 | * |
| 38 | - * @return void |
|
| 38 | + * @return boolean |
|
| 39 | 39 | */ |
| 40 | 40 | protected function shouldSkipTest() |
| 41 | 41 | { |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | /** |
| 36 | 36 | * Should this test be skipped for some reason. |
| 37 | 37 | * |
| 38 | - * @return void |
|
| 38 | + * @return boolean |
|
| 39 | 39 | */ |
| 40 | 40 | protected function shouldSkipTest() |
| 41 | 41 | { |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | 48 => 1, |
| 58 | 58 | 70 => 1, |
| 59 | 59 | 71 => 1, |
| 60 | - ); |
|
| 60 | + ); |
|
| 61 | 61 | |
| 62 | 62 | }//end getErrorList() |
| 63 | 63 | |
@@ -16,9 +16,3 @@ |
||
| 16 | 16 | $arr = array( |
| 17 | 17 | 'a' => 'a' |
| 18 | 18 | <<<<<<< HEAD |
| 19 | - 'b' => 'b' |
|
| 20 | -======= |
|
| 21 | - 'c' => 'c' |
|
| 22 | ->>>>>>> master |
|
| 23 | - ); |
|
| 24 | - } |
|
@@ -16,9 +16,3 @@ |
||
| 16 | 16 | $arr = array( |
| 17 | 17 | 'a' => 'a' |
| 18 | 18 | <<<<<<< HEAD |
| 19 | - 'b' => 'b' |
|
| 20 | -======= |
|
| 21 | - 'c' => 'c' |
|
| 22 | ->>>>>>> master |
|
| 23 | - ); |
|
| 24 | - } |
|
@@ -16,9 +16,3 @@ |
||
| 16 | 16 | $arr = array( |
| 17 | 17 | 'a' => 'a' |
| 18 | 18 | <<<<<<< HEAD |
| 19 | - 'b' => 'b' |
|
| 20 | -======= |
|
| 21 | - 'c' => 'c' |
|
| 22 | ->>>>>>> master |
|
| 23 | - ); |
|
| 24 | - } |
|
@@ -16,9 +16,3 @@ |
||
| 16 | 16 | $arr = array( |
| 17 | 17 | 'a' => 'a' |
| 18 | 18 | <<<<<<< HEAD |
| 19 | - 'b' => 'b' |
|
| 20 | -======= |
|
| 21 | - 'c' => 'c' |
|
| 22 | ->>>>>>> master |
|
| 23 | - ); |
|
| 24 | - } |
|
@@ -16,9 +16,3 @@ |
||
| 16 | 16 | $arr = array( |
| 17 | 17 | 'a' => 'a' |
| 18 | 18 | <<<<<<< HEAD |
| 19 | - 'b' => 'b' |
|
| 20 | -======= |
|
| 21 | - 'c' => 'c' |
|
| 22 | ->>>>>>> master |
|
| 23 | - ); |
|
| 24 | - } |
|
@@ -16,9 +16,3 @@ |
||
| 16 | 16 | $arr = array( |
| 17 | 17 | 'a' => 'a' |
| 18 | 18 | <<<<<<< HEAD |
| 19 | - 'b' => 'b' |
|
| 20 | -======= |
|
| 21 | - 'c' => 'c' |
|
| 22 | ->>>>>>> master |
|
| 23 | - ); |
|
| 24 | - } |
|
@@ -16,9 +16,3 @@ |
||
| 16 | 16 | $arr = array( |
| 17 | 17 | 'a' => 'a' |
| 18 | 18 | <<<<<<< HEAD |
| 19 | - 'b' => 'b' |
|
| 20 | -======= |
|
| 21 | - 'c' => 'c' |
|
| 22 | ->>>>>>> master |
|
| 23 | - ); |
|
| 24 | - } |
|
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | /** |
| 36 | 36 | * Should this test be skipped for some reason. |
| 37 | 37 | * |
| 38 | - * @return void |
|
| 38 | + * @return boolean |
|
| 39 | 39 | */ |
| 40 | 40 | protected function shouldSkipTest() |
| 41 | 41 | { |
@@ -57,6 +57,7 @@ |
||
| 57 | 57 | * @param string $content The content to tokenize, |
| 58 | 58 | * @param \PHP_CodeSniffer\Config | null $config The config data for the run. |
| 59 | 59 | * @param string $eolChar The EOL char used in the content. |
| 60 | + * @param null|\PHP_CodeSniffer\Config $config |
|
| 60 | 61 | * |
| 61 | 62 | * @return void |
| 62 | 63 | * @throws TokenizerException If the file appears to be minified. |
@@ -160,16 +160,16 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $this->tokensWithTabs = array( |
| 163 | - T_WHITESPACE => true, |
|
| 164 | - T_COMMENT => true, |
|
| 165 | - T_DOC_COMMENT => true, |
|
| 166 | - T_DOC_COMMENT_WHITESPACE => true, |
|
| 167 | - T_DOC_COMMENT_STRING => true, |
|
| 168 | - T_CONSTANT_ENCAPSED_STRING => true, |
|
| 169 | - T_DOUBLE_QUOTED_STRING => true, |
|
| 170 | - T_HEREDOC => true, |
|
| 171 | - T_NOWDOC => true, |
|
| 172 | - T_INLINE_HTML => true, |
|
| 163 | + T_WHITESPACE => true, |
|
| 164 | + T_COMMENT => true, |
|
| 165 | + T_DOC_COMMENT => true, |
|
| 166 | + T_DOC_COMMENT_WHITESPACE => true, |
|
| 167 | + T_DOC_COMMENT_STRING => true, |
|
| 168 | + T_CONSTANT_ENCAPSED_STRING => true, |
|
| 169 | + T_DOUBLE_QUOTED_STRING => true, |
|
| 170 | + T_HEREDOC => true, |
|
| 171 | + T_NOWDOC => true, |
|
| 172 | + T_INLINE_HTML => true, |
|
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | 175 | $this->numTokens = count($this->tokens); |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $todo = array( |
| 674 | 674 | $stackPtr, |
| 675 | 675 | $opener, |
| 676 | - ); |
|
| 676 | + ); |
|
| 677 | 677 | |
| 678 | 678 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
| 679 | 679 | $type = $this->tokens[$stackPtr]['type']; |
@@ -406,60 +406,60 @@ |
||
| 406 | 406 | */ |
| 407 | 407 | |
| 408 | 408 | switch ($this->tokens[$i]['code']) { |
| 409 | - case T_OPEN_SQUARE_BRACKET: |
|
| 410 | - $squareOpeners[] = $i; |
|
| 411 | - |
|
| 412 | - if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
| 413 | - echo str_repeat("\t", count($squareOpeners)); |
|
| 414 | - echo str_repeat("\t", count($curlyOpeners)); |
|
| 415 | - echo "=> Found square bracket opener at $i".PHP_EOL; |
|
| 416 | - } |
|
| 417 | - break; |
|
| 418 | - case T_OPEN_CURLY_BRACKET: |
|
| 419 | - if (isset($this->tokens[$i]['scope_closer']) === false) { |
|
| 420 | - $curlyOpeners[] = $i; |
|
| 409 | + case T_OPEN_SQUARE_BRACKET: |
|
| 410 | + $squareOpeners[] = $i; |
|
| 421 | 411 | |
| 422 | 412 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
| 423 | 413 | echo str_repeat("\t", count($squareOpeners)); |
| 424 | 414 | echo str_repeat("\t", count($curlyOpeners)); |
| 425 | - echo "=> Found curly bracket opener at $i".PHP_EOL; |
|
| 415 | + echo "=> Found square bracket opener at $i".PHP_EOL; |
|
| 426 | 416 | } |
| 427 | - } |
|
| 428 | - break; |
|
| 429 | - case T_CLOSE_SQUARE_BRACKET: |
|
| 430 | - if (empty($squareOpeners) === false) { |
|
| 431 | - $opener = array_pop($squareOpeners); |
|
| 432 | - $this->tokens[$i]['bracket_opener'] = $opener; |
|
| 433 | - $this->tokens[$i]['bracket_closer'] = $i; |
|
| 434 | - $this->tokens[$opener]['bracket_opener'] = $opener; |
|
| 435 | - $this->tokens[$opener]['bracket_closer'] = $i; |
|
| 417 | + break; |
|
| 418 | + case T_OPEN_CURLY_BRACKET: |
|
| 419 | + if (isset($this->tokens[$i]['scope_closer']) === false) { |
|
| 420 | + $curlyOpeners[] = $i; |
|
| 436 | 421 | |
| 437 | - if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
| 438 | - echo str_repeat("\t", count($squareOpeners)); |
|
| 439 | - echo str_repeat("\t", count($curlyOpeners)); |
|
| 440 | - echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL; |
|
| 422 | + if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
| 423 | + echo str_repeat("\t", count($squareOpeners)); |
|
| 424 | + echo str_repeat("\t", count($curlyOpeners)); |
|
| 425 | + echo "=> Found curly bracket opener at $i".PHP_EOL; |
|
| 426 | + } |
|
| 441 | 427 | } |
| 442 | - } |
|
| 443 | - break; |
|
| 444 | - case T_CLOSE_CURLY_BRACKET: |
|
| 445 | - if (empty($curlyOpeners) === false |
|
| 446 | - && isset($this->tokens[$i]['scope_opener']) === false |
|
| 447 | - ) { |
|
| 448 | - $opener = array_pop($curlyOpeners); |
|
| 449 | - $this->tokens[$i]['bracket_opener'] = $opener; |
|
| 450 | - $this->tokens[$i]['bracket_closer'] = $i; |
|
| 451 | - $this->tokens[$opener]['bracket_opener'] = $opener; |
|
| 452 | - $this->tokens[$opener]['bracket_closer'] = $i; |
|
| 428 | + break; |
|
| 429 | + case T_CLOSE_SQUARE_BRACKET: |
|
| 430 | + if (empty($squareOpeners) === false) { |
|
| 431 | + $opener = array_pop($squareOpeners); |
|
| 432 | + $this->tokens[$i]['bracket_opener'] = $opener; |
|
| 433 | + $this->tokens[$i]['bracket_closer'] = $i; |
|
| 434 | + $this->tokens[$opener]['bracket_opener'] = $opener; |
|
| 435 | + $this->tokens[$opener]['bracket_closer'] = $i; |
|
| 453 | 436 | |
| 454 | - if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
| 455 | - echo str_repeat("\t", count($squareOpeners)); |
|
| 456 | - echo str_repeat("\t", count($curlyOpeners)); |
|
| 457 | - echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL; |
|
| 437 | + if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
| 438 | + echo str_repeat("\t", count($squareOpeners)); |
|
| 439 | + echo str_repeat("\t", count($curlyOpeners)); |
|
| 440 | + echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL; |
|
| 441 | + } |
|
| 458 | 442 | } |
| 459 | - } |
|
| 460 | - break; |
|
| 461 | - default: |
|
| 462 | - continue; |
|
| 443 | + break; |
|
| 444 | + case T_CLOSE_CURLY_BRACKET: |
|
| 445 | + if (empty($curlyOpeners) === false |
|
| 446 | + && isset($this->tokens[$i]['scope_opener']) === false |
|
| 447 | + ) { |
|
| 448 | + $opener = array_pop($curlyOpeners); |
|
| 449 | + $this->tokens[$i]['bracket_opener'] = $opener; |
|
| 450 | + $this->tokens[$i]['bracket_closer'] = $i; |
|
| 451 | + $this->tokens[$opener]['bracket_opener'] = $opener; |
|
| 452 | + $this->tokens[$opener]['bracket_closer'] = $i; |
|
| 453 | + |
|
| 454 | + if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
| 455 | + echo str_repeat("\t", count($squareOpeners)); |
|
| 456 | + echo str_repeat("\t", count($curlyOpeners)); |
|
| 457 | + echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL; |
|
| 458 | + } |
|
| 459 | + } |
|
| 460 | + break; |
|
| 461 | + default: |
|
| 462 | + continue; |
|
| 463 | 463 | }//end switch |
| 464 | 464 | }//end for |
| 465 | 465 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @return void |
| 62 | 62 | * @throws TokenizerException If the file appears to be minified. |
| 63 | 63 | */ |
| 64 | - public function __construct($content, $config, $eolChar='\n') |
|
| 64 | + public function __construct($content, $config, $eolChar = '\n') |
|
| 65 | 65 | { |
| 66 | 66 | $this->eolChar = $eolChar; |
| 67 | 67 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return boolean |
| 94 | 94 | */ |
| 95 | - protected function isMinifiedContent($content, $eolChar='\n') |
|
| 95 | + protected function isMinifiedContent($content, $eolChar = '\n') |
|
| 96 | 96 | { |
| 97 | 97 | // Minified files often have a very large number of characters per line |
| 98 | 98 | // and cause issues when tokenizing. |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return void |
| 265 | 265 | */ |
| 266 | - public function replaceTabsInToken(&$token, $prefix=' ', $padding=' ') |
|
| 266 | + public function replaceTabsInToken(&$token, $prefix = ' ', $padding = ' ') |
|
| 267 | 267 | { |
| 268 | 268 | $checkEncoding = false; |
| 269 | 269 | if ($this->config->encoding !== 'iso-8859-1' && function_exists('iconv_strlen') === true) { |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * |
| 565 | 565 | * @return int The position in the stack that closed the scope. |
| 566 | 566 | */ |
| 567 | - private function recurseScopeMap($stackPtr, $depth=1, &$ignore=0) |
|
| 567 | + private function recurseScopeMap($stackPtr, $depth = 1, &$ignore = 0) |
|
| 568 | 568 | { |
| 569 | 569 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
| 570 | 570 | echo str_repeat("\t", $depth); |
@@ -9,9 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | namespace PHP_CodeSniffer\Util; |
| 11 | 11 | |
| 12 | -use PHP_CodeSniffer\Config; |
|
| 13 | -use PHP_CodeSniffer\Exceptions\RuntimeException; |
|
| 14 | - |
|
| 15 | 12 | class Common |
| 16 | 13 | { |
| 17 | 14 | |
@@ -21,16 +21,16 @@ |
||
| 21 | 21 | * @var string[] |
| 22 | 22 | */ |
| 23 | 23 | public static $allowedTypes = array( |
| 24 | - 'array', |
|
| 25 | - 'boolean', |
|
| 26 | - 'float', |
|
| 27 | - 'integer', |
|
| 28 | - 'mixed', |
|
| 29 | - 'object', |
|
| 30 | - 'string', |
|
| 31 | - 'resource', |
|
| 32 | - 'callable', |
|
| 33 | - ); |
|
| 24 | + 'array', |
|
| 25 | + 'boolean', |
|
| 26 | + 'float', |
|
| 27 | + 'integer', |
|
| 28 | + 'mixed', |
|
| 29 | + 'object', |
|
| 30 | + 'string', |
|
| 31 | + 'resource', |
|
| 32 | + 'callable', |
|
| 33 | + ); |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -343,15 +343,15 @@ |
||
| 343 | 343 | } else { |
| 344 | 344 | $lowerVarType = strtolower($varType); |
| 345 | 345 | switch ($lowerVarType) { |
| 346 | - case 'bool': |
|
| 347 | - return 'boolean'; |
|
| 348 | - case 'double': |
|
| 349 | - case 'real': |
|
| 350 | - return 'float'; |
|
| 351 | - case 'int': |
|
| 352 | - return 'integer'; |
|
| 353 | - case 'array()': |
|
| 354 | - return 'array'; |
|
| 346 | + case 'bool': |
|
| 347 | + return 'boolean'; |
|
| 348 | + case 'double': |
|
| 349 | + case 'real': |
|
| 350 | + return 'float'; |
|
| 351 | + case 'int': |
|
| 352 | + return 'integer'; |
|
| 353 | + case 'array()': |
|
| 354 | + return 'array'; |
|
| 355 | 355 | }//end switch |
| 356 | 356 | |
| 357 | 357 | if (strpos($lowerVarType, 'array(') !== false) { |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string |
| 164 | 164 | */ |
| 165 | - public static function prepareForOutput($content, $exclude=array()) |
|
| 165 | + public static function prepareForOutput($content, $exclude = array()) |
|
| 166 | 166 | { |
| 167 | 167 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
| 168 | 168 | if (in_array("\r", $exclude) === false) { |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | public static function isCamelCaps( |
| 223 | 223 | $string, |
| 224 | - $classFormat=false, |
|
| 225 | - $public=true, |
|
| 226 | - $strict=true |
|
| 224 | + $classFormat = false, |
|
| 225 | + $public = true, |
|
| 226 | + $strict = true |
|
| 227 | 227 | ) { |
| 228 | 228 | // Check the first character first. |
| 229 | 229 | if ($classFormat === false) { |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | * |
| 41 | 41 | * @param string $path The path to use. |
| 42 | 42 | * |
| 43 | - * @return mixed |
|
| 43 | + * @return string |
|
| 44 | 44 | */ |
| 45 | 45 | public static function realpath($path) |
| 46 | 46 | { |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | public function __construct( |
| 87 | 87 | array $scopeTokens, |
| 88 | 88 | array $tokens, |
| 89 | - $listenOutside=false |
|
| 89 | + $listenOutside = false |
|
| 90 | 90 | ) { |
| 91 | 91 | if (empty($scopeTokens) === true) { |
| 92 | 92 | $error = 'The scope tokens list cannot be empty'; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * Processes the function tokens within the class. |
| 69 | 69 | * |
| 70 | - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. |
|
| 70 | + * @param File $phpcsFile The file where this token was found. |
|
| 71 | 71 | * @param int $stackPtr The position where the token was found. |
| 72 | 72 | * @param int $currScope The current scope opener token. |
| 73 | 73 | * |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * Processes a token that is found within the scope that this test is |
| 151 | 151 | * listening to. |
| 152 | 152 | * |
| 153 | - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. |
|
| 153 | + * @param File $phpcsFile The file where this token was found. |
|
| 154 | 154 | * @param int $stackPtr The position in the stack where this |
| 155 | 155 | * token was found. |
| 156 | 156 | * |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | /** |
| 191 | 191 | * Returns the namespace declaration of a file. |
| 192 | 192 | * |
| 193 | - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. |
|
| 193 | + * @param File $phpcsFile The file where this token was found. |
|
| 194 | 194 | * @param int $stackPtr The position where the search for the |
| 195 | 195 | * namespace declaration will start. |
| 196 | 196 | * |
@@ -128,15 +128,15 @@ |
||
| 128 | 128 | parent::process(); |
| 129 | 129 | |
| 130 | 130 | $cache = array( |
| 131 | - 'hash' => $hash, |
|
| 132 | - 'errors' => $this->errors, |
|
| 133 | - 'warnings' => $this->warnings, |
|
| 134 | - 'metrics' => $this->metrics, |
|
| 135 | - 'errorCount' => $this->errorCount, |
|
| 136 | - 'warningCount' => $this->warningCount, |
|
| 137 | - 'fixableCount' => $this->fixableCount, |
|
| 138 | - 'numTokens' => $this->numTokens, |
|
| 139 | - ); |
|
| 131 | + 'hash' => $hash, |
|
| 132 | + 'errors' => $this->errors, |
|
| 133 | + 'warnings' => $this->warnings, |
|
| 134 | + 'metrics' => $this->metrics, |
|
| 135 | + 'errorCount' => $this->errorCount, |
|
| 136 | + 'warningCount' => $this->warningCount, |
|
| 137 | + 'fixableCount' => $this->fixableCount, |
|
| 138 | + 'numTokens' => $this->numTokens, |
|
| 139 | + ); |
|
| 140 | 140 | |
| 141 | 141 | Cache::set($this->path, $cache); |
| 142 | 142 | |