@@ -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 |
@@ -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); |
@@ -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 | { |
@@ -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,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * Processes this test, 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 | * |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * Check if this use statement is part of the namespace block. |
130 | 130 | * |
131 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
131 | + * @param File $phpcsFile The file being scanned. |
|
132 | 132 | * @param int $stackPtr The position of the current token in |
133 | 133 | * the stack passed in $tokens. |
134 | 134 | * |
135 | - * @return void |
|
135 | + * @return boolean |
|
136 | 136 | */ |
137 | 137 | private function shouldIgnoreUse($phpcsFile, $stackPtr) |
138 | 138 | { |
@@ -89,8 +89,6 @@ |
||
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | -use Vendor\Test\FooBar; |
|
93 | - |
|
94 | 92 | function test() |
95 | 93 | { |
96 | 94 | switch ($val) { |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | switch ($foo) { |
37 | - case'Foo': { |
|
38 | - echo 'foo'; |
|
39 | - break; |
|
40 | - } |
|
37 | + case'Foo': { |
|
38 | + echo 'foo'; |
|
39 | + break; |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | while ($i < 10) { |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | switch (true) { |
55 | - case is_resource($value): |
|
56 | - throw new Exception('foo'); |
|
57 | - case is_object($value): |
|
58 | - return 'object'; |
|
55 | + case is_resource($value): |
|
56 | + throw new Exception('foo'); |
|
57 | + case is_object($value): |
|
58 | + return 'object'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | switch (0) { |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | switch ($foo) { |
108 | - case 1: $bar = 1; break; |
|
109 | - case 2: |
|
108 | + case 1: $bar = 1; break; |
|
109 | + case 2: |
|
110 | 110 | |
111 | - $bar = 2; break; |
|
112 | - case 21: |
|
113 | - case 3: return 3; |
|
114 | - default: $bar = 0; |
|
111 | + $bar = 2; break; |
|
112 | + case 21: |
|
113 | + case 3: return 3; |
|
114 | + default: $bar = 0; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | switch ($foo) { |
@@ -135,7 +135,7 @@ |
||
135 | 135 | break; |
136 | 136 | } |
137 | 137 | |
138 | -switch($foo) |
|
138 | +switch ($foo) |
|
139 | 139 | { |
140 | 140 | case ('foo'): |
141 | 141 | default: |
@@ -1,15 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace MyProject; |
3 | 3 | |
4 | -use BarClass as Bar; |
|
5 | -use My\Full\Classname as Another; |
|
6 | - |
|
7 | - |
|
8 | -use Something; |
|
9 | -use SomethingElse; |
|
10 | - |
|
11 | 4 | // Comment here. |
12 | -use LastThing; |
|
13 | 5 | |
14 | 6 | class Foo { |
15 | 7 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | $var = new MyClass( |
18 | - function () use ($foo, $bar) { |
|
18 | + function() use ($foo, $bar) { |
|
19 | 19 | return true; |
20 | 20 | } |
21 | 21 | ); |
@@ -1,14 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace MyProject; |
3 | 3 | |
4 | -use BarClass as Bar; |
|
5 | -use My\Full\Classname as Another, My\Full\NSname; |
|
6 | - |
|
7 | 4 | |
8 | 5 | namespace AnotherProject; |
9 | 6 | |
10 | -use ArrayObject; |
|
11 | - |
|
12 | 7 | |
13 | 8 | $foo = 'bar'; |
14 | 9 |
@@ -1,9 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace bug; |
3 | 3 | |
4 | -use |
|
5 | - someNS\A; |
|
6 | -use someNS\B; |
|
7 | 4 | class Bug |
8 | 5 | { |
9 | 6 | public function __construct() |
@@ -9,7 +9,7 @@ |
||
9 | 9 | public function __construct() |
10 | 10 | { |
11 | 11 | $b = 1; |
12 | - $a = function () use ($b) { |
|
12 | + $a = function() use ($b) { |
|
13 | 13 | echo $b; |
14 | 14 | }; |
15 | 15 | } |
@@ -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 string[] |
|
24 | 24 | */ |
25 | 25 | public function register() |
26 | 26 | { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * Processes this sniff, when one of its tokens is encountered. |
37 | 37 | * |
38 | - * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. |
|
38 | + * @param File $phpcsFile The current file being checked. |
|
39 | 39 | * @param int $stackPtr The position of the current token in the |
40 | 40 | * stack passed in $tokens. |
41 | 41 | * |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | return array( |
42 | 42 | T_OPEN_SQUARE_BRACKET, |
43 | 43 | T_CLOSE_SQUARE_BRACKET, |
44 | - ); |
|
44 | + ); |
|
45 | 45 | |
46 | 46 | }//end register() |
47 | 47 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | $found = $phpcsFile->getTokensAsString($nonSpace, ($stackPtr - $nonSpace)).$tokens[$stackPtr]['content']; |
86 | 86 | $error = 'Space found before square bracket; expected "%s" but found "%s"'; |
87 | 87 | $data = array( |
88 | - $expected, |
|
89 | - $found, |
|
88 | + $expected, |
|
89 | + $found, |
|
90 | 90 | ); |
91 | 91 | $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeBracket', $data); |
92 | 92 | if ($fix === true) { |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | $found = $phpcsFile->getTokensAsString($stackPtr, ($nonSpace - $stackPtr + 1)); |
104 | 104 | $error = 'Space found after square bracket; expected "%s" but found "%s"'; |
105 | 105 | $data = array( |
106 | - $expected, |
|
107 | - $found, |
|
106 | + $expected, |
|
107 | + $found, |
|
108 | 108 | ); |
109 | 109 | $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterBracket', $data); |
110 | 110 | if ($fix === true) { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $expected, |
89 | 89 | $found, |
90 | 90 | ); |
91 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeBracket', $data); |
|
91 | + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeBracket', $data); |
|
92 | 92 | if ($fix === true) { |
93 | 93 | $phpcsFile->fixer->replaceToken(($stackPtr - 1), ''); |
94 | 94 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $expected, |
107 | 107 | $found, |
108 | 108 | ); |
109 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterBracket', $data); |
|
109 | + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterBracket', $data); |
|
110 | 110 | if ($fix === true) { |
111 | 111 | $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); |
112 | 112 | } |