@@ -193,7 +193,7 @@ |
||
| 193 | 193 | /** |
| 194 | 194 | * Return the file path of the current file being processed. |
| 195 | 195 | * |
| 196 | - * @return void |
|
| 196 | + * @return string |
|
| 197 | 197 | */ |
| 198 | 198 | function key() |
| 199 | 199 | { |
@@ -106,7 +106,7 @@ |
||
| 106 | 106 | * |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | - public function addFile($path, $file=null) |
|
| 109 | + public function addFile($path, $file = null) |
|
| 110 | 110 | { |
| 111 | 111 | // No filtering is done for STDIN. |
| 112 | 112 | if ($path === 'STDIN' |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | namespace PHP_CodeSniffer\Reports; |
| 11 | 11 | |
| 12 | 12 | use PHP_CodeSniffer\Files\File; |
| 13 | -use PHP_CodeSniffer\Util; |
|
| 14 | 13 | |
| 15 | 14 | class Diff implements Report |
| 16 | 15 | { |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | /** |
| 357 | 357 | * Start recording actions for a changeset. |
| 358 | 358 | * |
| 359 | - * @return void |
|
| 359 | + * @return false|null |
|
| 360 | 360 | */ |
| 361 | 361 | public function beginChangeset() |
| 362 | 362 | { |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | /** |
| 384 | 384 | * Stop recording actions for a changeset, and apply logged changes. |
| 385 | 385 | * |
| 386 | - * @return boolean |
|
| 386 | + * @return false|null |
|
| 387 | 387 | */ |
| 388 | 388 | public function endChangeset() |
| 389 | 389 | { |
@@ -529,9 +529,9 @@ |
||
| 529 | 529 | |
| 530 | 530 | if (isset($this->_oldTokenValues[$stackPtr]) === false) { |
| 531 | 531 | $this->_oldTokenValues[$stackPtr] = array( |
| 532 | - 'curr' => $content, |
|
| 533 | - 'prev' => $this->_tokens[$stackPtr], |
|
| 534 | - 'loop' => $this->loops, |
|
| 532 | + 'curr' => $content, |
|
| 533 | + 'prev' => $this->_tokens[$stackPtr], |
|
| 534 | + 'loop' => $this->loops, |
|
| 535 | 535 | ); |
| 536 | 536 | } else { |
| 537 | 537 | if ($this->_oldTokenValues[$stackPtr]['prev'] === $content |
@@ -283,14 +283,14 @@ |
||
| 283 | 283 | foreach ($diffLines as $line) { |
| 284 | 284 | if (isset($line[0]) === true) { |
| 285 | 285 | switch ($line[0]) { |
| 286 | - case '-': |
|
| 287 | - $diff[] = "\033[31m$line\033[0m"; |
|
| 288 | - break; |
|
| 289 | - case '+': |
|
| 290 | - $diff[] = "\033[32m$line\033[0m"; |
|
| 291 | - break; |
|
| 292 | - default: |
|
| 293 | - $diff[] = $line; |
|
| 286 | + case '-': |
|
| 287 | + $diff[] = "\033[31m$line\033[0m"; |
|
| 288 | + break; |
|
| 289 | + case '+': |
|
| 290 | + $diff[] = "\033[32m$line\033[0m"; |
|
| 291 | + break; |
|
| 292 | + default: |
|
| 293 | + $diff[] = $line; |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return string |
| 239 | 239 | */ |
| 240 | - public function generateDiff($filePath=null, $colors=true) |
|
| 240 | + public function generateDiff($filePath = null, $colors = true) |
|
| 241 | 241 | { |
| 242 | 242 | if ($filePath === null) { |
| 243 | 243 | $filePath = $this->_currentFile->getFilename(); |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | * |
| 655 | 655 | * @return bool If the change was accepted. |
| 656 | 656 | */ |
| 657 | - public function substrToken($stackPtr, $start, $length=null) |
|
| 657 | + public function substrToken($stackPtr, $start, $length = null) |
|
| 658 | 658 | { |
| 659 | 659 | $current = $this->getTokenContent($stackPtr); |
| 660 | 660 | |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | |
| 15 | 15 | use PHP_CodeSniffer\Ruleset; |
| 16 | 16 | use PHP_CodeSniffer\Autoload; |
| 17 | -use PHP_CodeSniffer\Util\Common; |
|
| 18 | 17 | |
| 19 | 18 | abstract class Generator |
| 20 | 19 | { |
@@ -27,11 +27,11 @@ |
||
| 27 | 27 | * its data should be counted in the grand totals. |
| 28 | 28 | * |
| 29 | 29 | * @param array $report Prepared report data. |
| 30 | - * @param \PHP_CodeSniffer\File $phpcsFile The file being reported on. |
|
| 30 | + * @param File $phpcsFile The file being reported on. |
|
| 31 | 31 | * @param bool $showSources Show sources? |
| 32 | 32 | * @param int $width Maximum allowed line width. |
| 33 | 33 | * |
| 34 | - * @return bool |
|
| 34 | + * @return null|boolean |
|
| 35 | 35 | */ |
| 36 | 36 | public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
| 37 | 37 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
|
| 33 | + public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) |
|
| 34 | 34 | { |
| 35 | 35 | if ($report['errors'] === 0 && $report['warnings'] === 0) { |
| 36 | 36 | // Nothing to print. |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | $totalErrors, |
| 334 | 334 | $totalWarnings, |
| 335 | 335 | $totalFixable, |
| 336 | - $showSources=false, |
|
| 337 | - $width=80, |
|
| 338 | - $interactive=false, |
|
| 339 | - $toScreen=true |
|
| 336 | + $showSources = false, |
|
| 337 | + $width = 80, |
|
| 338 | + $interactive = false, |
|
| 339 | + $toScreen = true |
|
| 340 | 340 | ) { |
| 341 | 341 | if ($cachedData === '') { |
| 342 | 342 | return; |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | namespace PHP_CodeSniffer\Reports; |
| 11 | 11 | |
| 12 | 12 | use PHP_CodeSniffer\Files\File; |
| 13 | -use PHP_CodeSniffer\Util; |
|
| 14 | 13 | |
| 15 | 14 | class Diff implements Report |
| 16 | 15 | { |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * its data should be counted in the grand totals. |
| 25 | 25 | * |
| 26 | 26 | * @param array $report Prepared report data. |
| 27 | - * @param \PHP_CodeSniffer\File $phpcsFile The file being reported on. |
|
| 27 | + * @param File $phpcsFile The file being reported on. |
|
| 28 | 28 | * @param bool $showSources Show sources? |
| 29 | 29 | * @param int $width Maximum allowed line width. |
| 30 | 30 | * |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
|
| 33 | + public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) |
|
| 34 | 34 | { |
| 35 | 35 | if ($report['errors'] === 0 && $report['warnings'] === 0) { |
| 36 | 36 | // Nothing to print. |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | $totalErrors, |
| 334 | 334 | $totalWarnings, |
| 335 | 335 | $totalFixable, |
| 336 | - $showSources=false, |
|
| 337 | - $width=80, |
|
| 338 | - $interactive=false, |
|
| 339 | - $toScreen=true |
|
| 336 | + $showSources = false, |
|
| 337 | + $width = 80, |
|
| 338 | + $interactive = false, |
|
| 339 | + $toScreen = true |
|
| 340 | 340 | ) { |
| 341 | 341 | if ($cachedData === '') { |
| 342 | 342 | return; |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * its data should be counted in the grand totals. |
| 25 | 25 | * |
| 26 | 26 | * @param array $report Prepared report data. |
| 27 | - * @param \PHP_CodeSniffer\File $phpcsFile The file being reported on. |
|
| 27 | + * @param File $phpcsFile The file being reported on. |
|
| 28 | 28 | * @param bool $showSources Show sources? |
| 29 | 29 | * @param int $width Maximum allowed line width. |
| 30 | 30 | * |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) |
|
| 33 | + public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) |
|
| 34 | 34 | { |
| 35 | 35 | if ($report['errors'] === 0 && $report['warnings'] === 0) { |
| 36 | 36 | // Nothing to print. |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | $totalErrors, |
| 334 | 334 | $totalWarnings, |
| 335 | 335 | $totalFixable, |
| 336 | - $showSources=false, |
|
| 337 | - $width=80, |
|
| 338 | - $interactive=false, |
|
| 339 | - $toScreen=true |
|
| 336 | + $showSources = false, |
|
| 337 | + $width = 80, |
|
| 338 | + $interactive = false, |
|
| 339 | + $toScreen = true |
|
| 340 | 340 | ) { |
| 341 | 341 | if ($cachedData === '') { |
| 342 | 342 | return; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | /** |
| 178 | 178 | * Processes the test. |
| 179 | 179 | * |
| 180 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the |
|
| 180 | + * @param File $phpcsFile The PHP_CodeSniffer file where the |
|
| 181 | 181 | * token occurred. |
| 182 | 182 | * @param int $stackPtr The position in the tokens stack |
| 183 | 183 | * where the listening token type was |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * for checking, which includes are |
| 248 | 248 | * parsed token representation of the |
| 249 | 249 | * pattern. |
| 250 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the |
|
| 250 | + * @param File $phpcsFile The PHP_CodeSniffer file where the |
|
| 251 | 251 | * token occurred. |
| 252 | 252 | * @param int $stackPtr The position in the tokens stack where |
| 253 | 253 | * the listening token type was found. |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | /** |
| 747 | 747 | * Processes any tokens registered with registerSupplementary(). |
| 748 | 748 | * |
| 749 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where to |
|
| 749 | + * @param File $phpcsFile The PHP_CodeSniffer file where to |
|
| 750 | 750 | * process the skip. |
| 751 | 751 | * @param int $stackPtr The position in the tokens stack to |
| 752 | 752 | * process. |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | namespace PHP_CodeSniffer\Sniffs; |
| 11 | 11 | |
| 12 | 12 | use PHP_CodeSniffer\Files\File; |
| 13 | -use PHP_CodeSniffer\Config; |
|
| 14 | 13 | use PHP_CodeSniffer\Util\Tokens; |
| 15 | 14 | use PHP_CodeSniffer\Tokenizers\PHP; |
| 16 | 15 | use PHP_CodeSniffer\Exceptions\RuntimeException; |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | $listenTypes[] = $tokenType; |
| 115 | 115 | |
| 116 | 116 | $patternArray = array( |
| 117 | - 'listen_pos' => $pos, |
|
| 118 | - 'pattern' => $parsedPattern, |
|
| 119 | - 'pattern_code' => $pattern, |
|
| 117 | + 'listen_pos' => $pos, |
|
| 118 | + 'pattern' => $parsedPattern, |
|
| 119 | + 'pattern_code' => $pattern, |
|
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | 122 | if (isset($this->_parsedPatterns[$tokenType]) === false) { |
@@ -763,17 +763,17 @@ discard block |
||
| 763 | 763 | }//end registerSupplementary() |
| 764 | 764 | |
| 765 | 765 | |
| 766 | - /** |
|
| 767 | - * Processes any tokens registered with registerSupplementary(). |
|
| 768 | - * |
|
| 769 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where to |
|
| 770 | - * process the skip. |
|
| 771 | - * @param int $stackPtr The position in the tokens stack to |
|
| 772 | - * process. |
|
| 773 | - * |
|
| 774 | - * @return void |
|
| 775 | - * @see registerSupplementary() |
|
| 776 | - */ |
|
| 766 | + /** |
|
| 767 | + * Processes any tokens registered with registerSupplementary(). |
|
| 768 | + * |
|
| 769 | + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where to |
|
| 770 | + * process the skip. |
|
| 771 | + * @param int $stackPtr The position in the tokens stack to |
|
| 772 | + * process. |
|
| 773 | + * |
|
| 774 | + * @return void |
|
| 775 | + * @see registerSupplementary() |
|
| 776 | + */ |
|
| 777 | 777 | protected function processSupplementary( |
| 778 | 778 | PHP_CodeSniffer_File $phpcsFile, |
| 779 | 779 | $stackPtr |
@@ -948,10 +948,10 @@ discard block |
||
| 948 | 948 | $patterns = array(); |
| 949 | 949 | foreach ($tokens as $patternInfo) { |
| 950 | 950 | $patterns[] = array( |
| 951 | - 'type' => 'token', |
|
| 952 | - 'token' => $patternInfo['code'], |
|
| 953 | - 'value' => $patternInfo['content'], |
|
| 954 | - ); |
|
| 951 | + 'type' => 'token', |
|
| 952 | + 'token' => $patternInfo['code'], |
|
| 953 | + 'value' => $patternInfo['content'], |
|
| 954 | + ); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | return $patterns; |
@@ -890,26 +890,26 @@ |
||
| 890 | 890 | $nestedBraces = 0; |
| 891 | 891 | for ($start = $from; $start >= 0; $start--) { |
| 892 | 892 | switch ($pattern[$start]) { |
| 893 | - case '(': |
|
| 894 | - if ($nestedParenthesis === 0) { |
|
| 895 | - $skip['to'] = 'parenthesis_closer'; |
|
| 896 | - } |
|
| 893 | + case '(': |
|
| 894 | + if ($nestedParenthesis === 0) { |
|
| 895 | + $skip['to'] = 'parenthesis_closer'; |
|
| 896 | + } |
|
| 897 | 897 | |
| 898 | - $nestedParenthesis--; |
|
| 899 | - break; |
|
| 900 | - case '{': |
|
| 901 | - if ($nestedBraces === 0) { |
|
| 902 | - $skip['to'] = 'scope_closer'; |
|
| 903 | - } |
|
| 898 | + $nestedParenthesis--; |
|
| 899 | + break; |
|
| 900 | + case '{': |
|
| 901 | + if ($nestedBraces === 0) { |
|
| 902 | + $skip['to'] = 'scope_closer'; |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | - $nestedBraces--; |
|
| 906 | - break; |
|
| 907 | - case '}': |
|
| 908 | - $nestedBraces++; |
|
| 909 | - break; |
|
| 910 | - case ')': |
|
| 911 | - $nestedParenthesis++; |
|
| 912 | - break; |
|
| 905 | + $nestedBraces--; |
|
| 906 | + break; |
|
| 907 | + case '}': |
|
| 908 | + $nestedBraces++; |
|
| 909 | + break; |
|
| 910 | + case ')': |
|
| 911 | + $nestedParenthesis++; |
|
| 912 | + break; |
|
| 913 | 913 | }//end switch |
| 914 | 914 | |
| 915 | 915 | if (isset($skip['to']) === true) { |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | * |
| 79 | 79 | * @param boolean $ignoreComments If true, comments will be ignored. |
| 80 | 80 | */ |
| 81 | - public function __construct($ignoreComments=null) |
|
| 81 | + public function __construct($ignoreComments = null) |
|
| 82 | 82 | { |
| 83 | 83 | // This is here for backwards compatibility. |
| 84 | 84 | if ($ignoreComments !== null) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | /** |
| 70 | 70 | * Processes the token in the specified PHP_CodeSniffer_File. |
| 71 | 71 | * |
| 72 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this |
|
| 72 | + * @param File $phpcsFile The PHP_CodeSniffer file where this |
|
| 73 | 73 | * token was found. |
| 74 | 74 | * @param int $stackPtr The position where the token was found. |
| 75 | 75 | * @param array $currScope The current scope opener token. |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | /** |
| 144 | 144 | * Processes the token outside the scope in the file. |
| 145 | 145 | * |
| 146 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this |
|
| 146 | + * @param File $phpcsFile The PHP_CodeSniffer file where this |
|
| 147 | 147 | * token was found. |
| 148 | 148 | * @param int $stackPtr The position where the token was found. |
| 149 | 149 | * |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | /** |
| 172 | 172 | * Called to process class member vars. |
| 173 | 173 | * |
| 174 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this |
|
| 174 | + * @param File $phpcsFile The PHP_CodeSniffer file where this |
|
| 175 | 175 | * token was found. |
| 176 | 176 | * @param int $stackPtr The position where the token was found. |
| 177 | 177 | * |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | /** |
| 184 | 184 | * Called to process normal member vars. |
| 185 | 185 | * |
| 186 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this |
|
| 186 | + * @param File $phpcsFile The PHP_CodeSniffer file where this |
|
| 187 | 187 | * token was found. |
| 188 | 188 | * @param int $stackPtr The position where the token was found. |
| 189 | 189 | * |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * Note that there may be more than one variable in the string, which will |
| 199 | 199 | * result only in one call for the string or one call per line for heredocs. |
| 200 | 200 | * |
| 201 | - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this |
|
| 201 | + * @param File $phpcsFile The PHP_CodeSniffer file where this |
|
| 202 | 202 | * token was found. |
| 203 | 203 | * @param int $stackPtr The position where the double quoted |
| 204 | 204 | * string was found. |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | namespace PHP_CodeSniffer\Sniffs; |
| 17 | 17 | |
| 18 | 18 | use PHP_CodeSniffer\Files\File; |
| 19 | -use PHP_CodeSniffer\Exceptions\RuntimeException; |
|
| 20 | 19 | |
| 21 | 20 | abstract class AbstractVariableSniff extends AbstractScopeSniff |
| 22 | 21 | { |
@@ -67,17 +67,17 @@ |
||
| 67 | 67 | public function __construct() |
| 68 | 68 | { |
| 69 | 69 | $scopes = array( |
| 70 | - T_CLASS, |
|
| 71 | - T_TRAIT, |
|
| 72 | - T_INTERFACE, |
|
| 73 | - ); |
|
| 70 | + T_CLASS, |
|
| 71 | + T_TRAIT, |
|
| 72 | + T_INTERFACE, |
|
| 73 | + ); |
|
| 74 | 74 | |
| 75 | 75 | $listen = array( |
| 76 | - T_FUNCTION, |
|
| 77 | - T_VARIABLE, |
|
| 78 | - T_DOUBLE_QUOTED_STRING, |
|
| 79 | - T_HEREDOC, |
|
| 80 | - ); |
|
| 76 | + T_FUNCTION, |
|
| 77 | + T_VARIABLE, |
|
| 78 | + T_DOUBLE_QUOTED_STRING, |
|
| 79 | + T_HEREDOC, |
|
| 80 | + ); |
|
| 81 | 81 | |
| 82 | 82 | parent::__construct($scopes, $listen, true); |
| 83 | 83 | |
@@ -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); |