@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Returns an array of tokens this test wants to listen for. |
22 | 22 | * |
23 | - * @return int[] |
|
23 | + * @return integer[] |
|
24 | 24 | */ |
25 | 25 | public function register() |
26 | 26 | { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Processes this test, when one of its tokens is encountered. |
34 | 34 | * |
35 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
35 | + * @param File $phpcsFile The file being scanned. |
|
36 | 36 | * @param int $stackPtr The position of the current token in the |
37 | 37 | * stack passed in $tokens. |
38 | 38 | * |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * Returns true if the passed argument has a default value. |
75 | 75 | * |
76 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
76 | + * @param File $phpcsFile The file being scanned. |
|
77 | 77 | * @param int $argPtr The position of the argument |
78 | 78 | * in the stack. |
79 | 79 | * |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * Returns an array of tokens this test wants to listen for. |
21 | 21 | * |
22 | - * @return array |
|
22 | + * @return integer[] |
|
23 | 23 | */ |
24 | 24 | public function register() |
25 | 25 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * Processes this test, when one of its tokens is encountered. |
36 | 36 | * |
37 | - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. |
|
37 | + * @param File $phpcsFile The current file being processed. |
|
38 | 38 | * @param int $stackPtr The position of the current token |
39 | 39 | * in the stack passed in $tokens. |
40 | 40 | * |
@@ -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 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * Processes the tokens within the scope. |
62 | 62 | * |
63 | - * @param PHP_CodeSniffer_File $phpcsFile The file being processed. |
|
63 | + * @param File $phpcsFile The file being processed. |
|
64 | 64 | * @param int $stackPtr The position where this token was |
65 | 65 | * found. |
66 | 66 | * @param int $currScope The position of the current scope. |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | /** |
165 | 165 | * Processes the tokens outside the scope. |
166 | 166 | * |
167 | - * @param PHP_CodeSniffer_File $phpcsFile The file being processed. |
|
167 | + * @param File $phpcsFile The file being processed. |
|
168 | 168 | * @param int $stackPtr The position where this token was |
169 | 169 | * found. |
170 | 170 | * |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | * @var array |
42 | 42 | */ |
43 | 43 | protected $magicMethods = array( |
44 | - 'construct' => true, |
|
45 | - 'destruct' => true, |
|
46 | - 'call' => true, |
|
47 | - 'callstatic' => true, |
|
48 | - 'get' => true, |
|
49 | - 'set' => true, |
|
50 | - 'isset' => true, |
|
51 | - 'unset' => true, |
|
52 | - 'sleep' => true, |
|
53 | - 'wakeup' => true, |
|
54 | - 'tostring' => true, |
|
55 | - 'set_state' => true, |
|
56 | - 'clone' => true, |
|
57 | - 'invoke' => true, |
|
58 | - 'debuginfo' => true, |
|
59 | - ); |
|
44 | + 'construct' => true, |
|
45 | + 'destruct' => true, |
|
46 | + 'call' => true, |
|
47 | + 'callstatic' => true, |
|
48 | + 'get' => true, |
|
49 | + 'set' => true, |
|
50 | + 'isset' => true, |
|
51 | + 'unset' => true, |
|
52 | + 'sleep' => true, |
|
53 | + 'wakeup' => true, |
|
54 | + 'tostring' => true, |
|
55 | + 'set_state' => true, |
|
56 | + 'clone' => true, |
|
57 | + 'invoke' => true, |
|
58 | + 'debuginfo' => true, |
|
59 | + ); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * A list of all PHP magic functions. |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | if (preg_match('|^__|', $methodName) !== 0) { |
102 | 102 | $magicPart = strtolower(substr($methodName, 2)); |
103 | 103 | if (isset($this->magicMethods[$magicPart]) === false) { |
104 | - $error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; |
|
105 | - $phpcsFile->addError($error, $stackPtr, 'MethodDoubleUnderscore', $errorData); |
|
104 | + $error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; |
|
105 | + $phpcsFile->addError($error, $stackPtr, 'MethodDoubleUnderscore', $errorData); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return; |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | if ($isPublic === true && $scopeSpecified === true && $methodName{0} === '_') { |
145 | 145 | $error = '%s method name "%s" must not be prefixed with an underscore'; |
146 | 146 | $data = array( |
147 | - ucfirst($scope), |
|
148 | - $errorData[0], |
|
149 | - ); |
|
147 | + ucfirst($scope), |
|
148 | + $errorData[0], |
|
149 | + ); |
|
150 | 150 | $phpcsFile->addError($error, $stackPtr, 'PublicUnderscore', $data); |
151 | 151 | return; |
152 | 152 | } |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | if ($scopeSpecified === true) { |
166 | 166 | $error = '%s method name "%s" is not in camel caps format'; |
167 | 167 | $data = array( |
168 | - ucfirst($scope), |
|
169 | - $errorData[0], |
|
170 | - ); |
|
168 | + ucfirst($scope), |
|
169 | + $errorData[0], |
|
170 | + ); |
|
171 | 171 | $phpcsFile->addError($error, $stackPtr, 'ScopeNotCamelCaps', $data); |
172 | 172 | } else { |
173 | 173 | $error = 'Method name "%s" is not in camel caps format'; |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | if (preg_match('|^__|', $functionName) !== 0) { |
209 | 209 | $magicPart = strtolower(substr($functionName, 2)); |
210 | 210 | if (isset($this->magicFunctions[$magicPart]) === false) { |
211 | - $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; |
|
212 | - $phpcsFile->addError($error, $stackPtr, 'FunctionDoubleUnderscore', $errorData); |
|
211 | + $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; |
|
212 | + $phpcsFile->addError($error, $stackPtr, 'FunctionDoubleUnderscore', $errorData); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | return; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Returns an array of tokens this test wants to listen for. |
22 | 22 | * |
23 | - * @return array |
|
23 | + * @return integer[] |
|
24 | 24 | */ |
25 | 25 | public function register() |
26 | 26 | { |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Processes this sniff, when one of its tokens is encountered. |
34 | 34 | * |
35 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
35 | + * @param File $phpcsFile The file being scanned. |
|
36 | 36 | * @param int $stackPtr The position of the current token in |
37 | 37 | * the token stack. |
38 | 38 | * |
39 | - * @return void |
|
39 | + * @return integer |
|
40 | 40 | */ |
41 | 41 | public function process(File $phpcsFile, $stackPtr) |
42 | 42 | { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * side effect in the file. A NULL value for either indicates nothing was |
69 | 69 | * found. |
70 | 70 | * |
71 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
71 | + * @param File $phpcsFile The file being scanned. |
|
72 | 72 | * @param int $start The token to start searching from. |
73 | 73 | * @param int $end The token to search to. |
74 | 74 | * @param array $tokens The stack of tokens that make up |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | if ($result['symbol'] !== null && $result['effect'] !== null) { |
60 | 60 | $error = 'A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line %s and the first side effect is on line %s.'; |
61 | 61 | $data = array( |
62 | - $tokens[$result['symbol']]['line'], |
|
63 | - $tokens[$result['effect']]['line'], |
|
64 | - ); |
|
62 | + $tokens[$result['symbol']]['line'], |
|
63 | + $tokens[$result['effect']]['line'], |
|
64 | + ); |
|
65 | 65 | $phpcsFile->addWarning($error, 0, 'FoundWithSymbols', $data); |
66 | 66 | $phpcsFile->recordMetric($stackPtr, 'Declarations and side effects mixed', 'yes'); |
67 | 67 | } else { |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | T_INTERFACE => T_INTERFACE, |
97 | 97 | T_TRAIT => T_TRAIT, |
98 | 98 | T_FUNCTION => T_FUNCTION, |
99 | - ); |
|
99 | + ); |
|
100 | 100 | |
101 | 101 | $conditions = array( |
102 | - T_IF => T_IF, |
|
103 | - T_ELSE => T_ELSE, |
|
104 | - T_ELSEIF => T_ELSEIF, |
|
105 | - ); |
|
102 | + T_IF => T_IF, |
|
103 | + T_ELSE => T_ELSE, |
|
104 | + T_ELSEIF => T_ELSEIF, |
|
105 | + ); |
|
106 | 106 | |
107 | 107 | $firstSymbol = null; |
108 | 108 | $firstEffect = null; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | return array( |
231 | 231 | 'symbol' => $firstSymbol, |
232 | 232 | 'effect' => $firstEffect, |
233 | - ); |
|
233 | + ); |
|
234 | 234 | |
235 | 235 | }//end _searchForConflict() |
236 | 236 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Processes this test, when one of its tokens is encountered. |
22 | 22 | * |
23 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
23 | + * @param File $phpcsFile The file being scanned. |
|
24 | 24 | * @param int $stackPtr The position of the current token |
25 | 25 | * in the stack passed in $tokens. |
26 | 26 | * |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Processes the opening section of a class declaration. |
48 | 48 | * |
49 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
49 | + * @param File $phpcsFile The file being scanned. |
|
50 | 50 | * @param int $stackPtr The position of the current token |
51 | 51 | * in the stack passed in $tokens. |
52 | 52 | * |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | /** |
387 | 387 | * Processes the closing section of a class declaration. |
388 | 388 | * |
389 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
389 | + * @param File $phpcsFile The file being scanned. |
|
390 | 390 | * @param int $stackPtr The position of the current token |
391 | 391 | * in the stack passed in $tokens. |
392 | 392 | * |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $prevContent, |
91 | 91 | $stackPtrType, |
92 | 92 | $spaces, |
93 | - ); |
|
93 | + ); |
|
94 | 94 | |
95 | 95 | $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeKeyword', $data); |
96 | 96 | if ($fix === true) { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $data = array( |
106 | 106 | $prevContent, |
107 | 107 | $stackPtrType, |
108 | - ); |
|
108 | + ); |
|
109 | 109 | |
110 | 110 | $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NewlineBeforeKeyword', $data); |
111 | 111 | if ($fix === true) { |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | $found = strlen($gap); |
138 | 138 | $error = 'Expected 1 space between %s keyword and %s name; %s found'; |
139 | 139 | $data = array( |
140 | - $stackPtrType, |
|
141 | - $stackPtrType, |
|
142 | - $found, |
|
143 | - ); |
|
140 | + $stackPtrType, |
|
141 | + $stackPtrType, |
|
142 | + $found, |
|
143 | + ); |
|
144 | 144 | |
145 | 145 | $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterKeyword', $data); |
146 | 146 | if ($fix === true) { |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | $found = strlen($gap); |
156 | 156 | $error = 'Expected 1 space after %s name; %s found'; |
157 | 157 | $data = array( |
158 | - $stackPtrType, |
|
159 | - $found, |
|
160 | - ); |
|
158 | + $stackPtrType, |
|
159 | + $found, |
|
160 | + ); |
|
161 | 161 | |
162 | 162 | $fix = $phpcsFile->addFixableError($error, $className, 'SpaceAfterName', $data); |
163 | 163 | if ($fix === true) { |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | $find = array( |
230 | - T_STRING, |
|
231 | - $keywordTokenType, |
|
230 | + T_STRING, |
|
231 | + $keywordTokenType, |
|
232 | 232 | ); |
233 | 233 | |
234 | 234 | $classNames = array(); |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | ) { |
256 | 256 | $prev = $phpcsFile->findPrevious( |
257 | 257 | array( |
258 | - T_NS_SEPARATOR, |
|
259 | - T_WHITESPACE, |
|
258 | + T_NS_SEPARATOR, |
|
259 | + T_WHITESPACE, |
|
260 | 260 | ), |
261 | 261 | ($className - 1), |
262 | 262 | $implements, |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | if ($found !== $expected) { |
320 | 320 | $error = 'Expected %s spaces before interface name; %s found'; |
321 | 321 | $data = array( |
322 | - $expected, |
|
323 | - $found, |
|
324 | - ); |
|
322 | + $expected, |
|
323 | + $found, |
|
324 | + ); |
|
325 | 325 | $fix = $phpcsFile->addFixableError($error, $className, 'InterfaceWrongIndent', $data); |
326 | 326 | if ($fix === true) { |
327 | 327 | $padding = str_repeat(' ', $expected); |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | if ($spaceBefore !== 1) { |
359 | 359 | $error = 'Expected 1 space before "%s"; %s found'; |
360 | 360 | $data = array( |
361 | - $tokens[$className]['content'], |
|
362 | - $spaceBefore, |
|
363 | - ); |
|
361 | + $tokens[$className]['content'], |
|
362 | + $spaceBefore, |
|
363 | + ); |
|
364 | 364 | |
365 | 365 | $fix = $phpcsFile->addFixableError($error, $className, 'SpaceBeforeName', $data); |
366 | 366 | if ($fix === true) { |
@@ -380,9 +380,9 @@ discard block |
||
380 | 380 | if ($tokens[($className + 2)]['code'] !== $keywordTokenType) { |
381 | 381 | $error = 'Expected 0 spaces between "%s" and comma; %s found'; |
382 | 382 | $data = array( |
383 | - $tokens[$className]['content'], |
|
384 | - strlen($tokens[($className + 1)]['content']), |
|
385 | - ); |
|
383 | + $tokens[$className]['content'], |
|
384 | + strlen($tokens[($className + 1)]['content']), |
|
385 | + ); |
|
386 | 386 | |
387 | 387 | $fix = $phpcsFile->addFixableError($error, $className, 'SpaceBeforeComma', $data); |
388 | 388 | if ($fix === true) { |
@@ -322,7 +322,7 @@ |
||
322 | 322 | $expected, |
323 | 323 | $found, |
324 | 324 | ); |
325 | - $fix = $phpcsFile->addFixableError($error, $className, 'InterfaceWrongIndent', $data); |
|
325 | + $fix = $phpcsFile->addFixableError($error, $className, 'InterfaceWrongIndent', $data); |
|
326 | 326 | if ($fix === true) { |
327 | 327 | $padding = str_repeat(' ', $expected); |
328 | 328 | if ($found === 0) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * Returns an array of tokens this test wants to listen for. |
29 | 29 | * |
30 | - * @return array |
|
30 | + * @return integer[] |
|
31 | 31 | */ |
32 | 32 | public function register() |
33 | 33 | { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * Processes this test, when one of its tokens is encountered. |
41 | 41 | * |
42 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
42 | + * @param File $phpcsFile The file being scanned. |
|
43 | 43 | * @param int $stackPtr The position of the current token in the |
44 | 44 | * stack passed in $tokens. |
45 | 45 | * |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * |
210 | 210 | * Note that nested switches are ignored. |
211 | 211 | * |
212 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
212 | + * @param File $phpcsFile The file being scanned. |
|
213 | 213 | * @param int $stackPtr The position to start looking at. |
214 | 214 | * @param int $end The position to stop looking at. |
215 | 215 | * |
@@ -11,7 +11,6 @@ |
||
11 | 11 | |
12 | 12 | use PHP_CodeSniffer\Sniffs\Sniff; |
13 | 13 | use PHP_CodeSniffer\Files\File; |
14 | -use PHP_CodeSniffer\Util\Tokens; |
|
15 | 14 | |
16 | 15 | class SwitchDeclarationSniff implements Sniff |
17 | 16 | { |
@@ -87,8 +87,8 @@ |
||
87 | 87 | $expected = strtolower($tokens[$nextCase]['content']); |
88 | 88 | $error = strtoupper($type).' keyword must be lowercase; expected "%s" but found "%s"'; |
89 | 89 | $data = array( |
90 | - $expected, |
|
91 | - $tokens[$nextCase]['content'], |
|
90 | + $expected, |
|
91 | + $tokens[$nextCase]['content'], |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | $fix = $phpcsFile->addFixableError($error, $nextCase, $type.'NotLower', $data); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Returns an array of tokens this test wants to listen for. |
22 | 22 | * |
23 | - * @return array |
|
23 | + * @return integer[] |
|
24 | 24 | */ |
25 | 25 | public function register() |
26 | 26 | { |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Processes this sniff, when one of its tokens is encountered. |
34 | 34 | * |
35 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
35 | + * @param File $phpcsFile The file being scanned. |
|
36 | 36 | * @param int $stackPtr The position of the current token in |
37 | 37 | * the stack passed in $tokens. |
38 | 38 | * |
39 | - * @return void |
|
39 | + * @return integer |
|
40 | 40 | */ |
41 | 41 | public function process(File $phpcsFile, $stackPtr) |
42 | 42 | { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * Returns an array of tokens this test wants to listen for. |
21 | 21 | * |
22 | - * @return array |
|
22 | + * @return integer[] |
|
23 | 23 | */ |
24 | 24 | public function register() |
25 | 25 | { |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * Processes this sniff, when one of its tokens is encountered. |
33 | 33 | * |
34 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
34 | + * @param File $phpcsFile The file being scanned. |
|
35 | 35 | * @param int $stackPtr The position of the current token in |
36 | 36 | * the stack passed in $tokens. |
37 | 37 | * |
38 | - * @return void |
|
38 | + * @return integer |
|
39 | 39 | */ |
40 | 40 | public function process(File $phpcsFile, $stackPtr) |
41 | 41 | { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Processes the function tokens within the class. |
32 | 32 | * |
33 | - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. |
|
33 | + * @param File $phpcsFile The file where this token was found. |
|
34 | 34 | * @param int $stackPtr The position where the token was found. |
35 | 35 | * @param int $currScope The current scope opener token. |
36 | 36 | * |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * Processes a token that is found within the scope that this test is |
141 | 141 | * listening to. |
142 | 142 | * |
143 | - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. |
|
143 | + * @param File $phpcsFile The file where this token was found. |
|
144 | 144 | * @param int $stackPtr The position in the stack where this |
145 | 145 | * token was found. |
146 | 146 | * |
@@ -80,18 +80,18 @@ |
||
80 | 80 | $prefix = $stackPtr; |
81 | 81 | while (($prefix = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$methodPrefixes, ($prefix - 1), $prev)) !== false) { |
82 | 82 | switch ($tokens[$prefix]['code']) { |
83 | - case T_STATIC: |
|
84 | - $static = $prefix; |
|
85 | - break; |
|
86 | - case T_ABSTRACT: |
|
87 | - $abstract = $prefix; |
|
88 | - break; |
|
89 | - case T_FINAL: |
|
90 | - $final = $prefix; |
|
91 | - break; |
|
92 | - default: |
|
93 | - $visibility = $prefix; |
|
94 | - break; |
|
83 | + case T_STATIC: |
|
84 | + $static = $prefix; |
|
85 | + break; |
|
86 | + case T_ABSTRACT: |
|
87 | + $abstract = $prefix; |
|
88 | + break; |
|
89 | + case T_FINAL: |
|
90 | + $final = $prefix; |
|
91 | + break; |
|
92 | + default: |
|
93 | + $visibility = $prefix; |
|
94 | + break; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 |