@@ -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 | } |
@@ -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 |
| 40 | 40 | * the stack passed in $tokens. |
| 41 | 41 | * |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | /** |
| 128 | 128 | * Processes a single-line array definition. |
| 129 | 129 | * |
| 130 | - * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. |
|
| 130 | + * @param File $phpcsFile The current file being checked. |
|
| 131 | 131 | * @param int $stackPtr The position of the current token |
| 132 | 132 | * in the stack passed in $tokens. |
| 133 | 133 | * @param int $arrayStart The token that starts the array definition. |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | /** |
| 292 | 292 | * Processes a multi-line array definition. |
| 293 | 293 | * |
| 294 | - * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. |
|
| 294 | + * @param File $phpcsFile The current file being checked. |
|
| 295 | 295 | * @param int $stackPtr The position of the current token |
| 296 | 296 | * in the stack passed in $tokens. |
| 297 | 297 | * @param int $arrayStart The token that starts the array definition. |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | return array( |
| 40 | 40 | T_ARRAY, |
| 41 | 41 | T_OPEN_SHORT_ARRAY, |
| 42 | - ); |
|
| 42 | + ); |
|
| 43 | 43 | |
| 44 | 44 | }//end register() |
| 45 | 45 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $data = array( |
| 200 | 200 | $content, |
| 201 | 201 | $spaceLength, |
| 202 | - ); |
|
| 202 | + ); |
|
| 203 | 203 | |
| 204 | 204 | $fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceBeforeDoubleArrow', $data); |
| 205 | 205 | if ($fix === true) { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $data = array( |
| 225 | 225 | $content, |
| 226 | 226 | $spaceLength, |
| 227 | - ); |
|
| 227 | + ); |
|
| 228 | 228 | |
| 229 | 229 | $fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceAfterDoubleArrow', $data); |
| 230 | 230 | if ($fix === true) { |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $data = array( |
| 272 | 272 | $content, |
| 273 | 273 | $spaceLength, |
| 274 | - ); |
|
| 274 | + ); |
|
| 275 | 275 | |
| 276 | 276 | $fix = $phpcsFile->addFixableError($error, $comma, 'SpaceAfterComma', $data); |
| 277 | 277 | if ($fix === true) { |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $data = array( |
| 288 | 288 | $content, |
| 289 | 289 | $spaceLength, |
| 290 | - ); |
|
| 290 | + ); |
|
| 291 | 291 | |
| 292 | 292 | $fix = $phpcsFile->addFixableError($error, $comma, 'SpaceBeforeComma', $data); |
| 293 | 293 | if ($fix === true) { |
@@ -330,8 +330,8 @@ discard block |
||
| 330 | 330 | $found = ($tokens[$arrayEnd]['column'] - 1); |
| 331 | 331 | $error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s'; |
| 332 | 332 | $data = array( |
| 333 | - $expected, |
|
| 334 | - $found, |
|
| 333 | + $expected, |
|
| 334 | + $found, |
|
| 335 | 335 | ); |
| 336 | 336 | |
| 337 | 337 | $fix = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceNotAligned', $data); |
@@ -467,9 +467,9 @@ discard block |
||
| 467 | 467 | |
| 468 | 468 | $error = 'Expected 0 spaces between "%s" and comma; %s found'; |
| 469 | 469 | $data = array( |
| 470 | - $content, |
|
| 471 | - $spaceLength, |
|
| 472 | - ); |
|
| 470 | + $content, |
|
| 471 | + $spaceLength, |
|
| 472 | + ); |
|
| 473 | 473 | |
| 474 | 474 | $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data); |
| 475 | 475 | if ($fix === true) { |
@@ -638,9 +638,9 @@ discard block |
||
| 638 | 638 | if ($found !== $expected) { |
| 639 | 639 | $error = 'Array value not aligned correctly; expected %s spaces but found %s'; |
| 640 | 640 | $data = array( |
| 641 | - $expected, |
|
| 642 | - $found, |
|
| 643 | - ); |
|
| 641 | + $expected, |
|
| 642 | + $found, |
|
| 643 | + ); |
|
| 644 | 644 | |
| 645 | 645 | $fix = $phpcsFile->addFixableError($error, $value['value'], 'ValueNotAligned', $data); |
| 646 | 646 | if ($fix === true) { |
@@ -737,8 +737,8 @@ discard block |
||
| 737 | 737 | $found = ($tokens[$index['index']]['column'] - 1); |
| 738 | 738 | $error = 'Array key not aligned correctly; expected %s spaces but found %s'; |
| 739 | 739 | $data = array( |
| 740 | - $expected, |
|
| 741 | - $found, |
|
| 740 | + $expected, |
|
| 741 | + $found, |
|
| 742 | 742 | ); |
| 743 | 743 | |
| 744 | 744 | $fix = $phpcsFile->addFixableError($error, $index['index'], 'KeyNotAligned', $data); |
@@ -758,8 +758,8 @@ discard block |
||
| 758 | 758 | $found = ($tokens[$index['arrow']]['column'] - (strlen($index['index_content']) + $tokens[$index['index']]['column'])); |
| 759 | 759 | $error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s'; |
| 760 | 760 | $data = array( |
| 761 | - $expected, |
|
| 762 | - $found, |
|
| 761 | + $expected, |
|
| 762 | + $found, |
|
| 763 | 763 | ); |
| 764 | 764 | |
| 765 | 765 | $fix = $phpcsFile->addFixableError($error, $index['arrow'], 'DoubleArrowNotAligned', $data); |
@@ -783,9 +783,9 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | $error = 'Array value not aligned correctly; expected %s space(s) but found %s'; |
| 785 | 785 | $data = array( |
| 786 | - $expected, |
|
| 787 | - $found, |
|
| 788 | - ); |
|
| 786 | + $expected, |
|
| 787 | + $found, |
|
| 788 | + ); |
|
| 789 | 789 | |
| 790 | 790 | $fix = $phpcsFile->addFixableError($error, $index['arrow'], 'ValueNotAligned', $data); |
| 791 | 791 | if ($fix === true) { |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | $data = array( |
| 874 | 874 | $content, |
| 875 | 875 | $spaceLength, |
| 876 | - ); |
|
| 876 | + ); |
|
| 877 | 877 | |
| 878 | 878 | $fix = $phpcsFile->addFixableError($error, $nextComma, 'SpaceBeforeComma', $data); |
| 879 | 879 | if ($fix === true) { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * Processes this test, when one of its tokens is encountered. |
| 21 | 21 | * |
| 22 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
| 22 | + * @param File $phpcsFile The file being scanned. |
|
| 23 | 23 | * @param int $stackPtr The position of the current token |
| 24 | 24 | * in the stack passed in $tokens. |
| 25 | 25 | * |
@@ -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 | * |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * Processes the closing section of a class declaration. |
| 92 | 92 | * |
| 93 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
| 93 | + * @param File $phpcsFile The file being scanned. |
|
| 94 | 94 | * @param int $stackPtr The position of the current token |
| 95 | 95 | * in the stack passed in $tokens. |
| 96 | 96 | * |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | $type = strtolower($tokens[$stackPtr]['content']); |
| 92 | 92 | $error = 'Expected 0 spaces before %s keyword; %s found'; |
| 93 | 93 | $data = array( |
| 94 | - $type, |
|
| 95 | - $spaces, |
|
| 96 | - ); |
|
| 94 | + $type, |
|
| 95 | + $spaces, |
|
| 96 | + ); |
|
| 97 | 97 | |
| 98 | 98 | $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeKeyword', $data); |
| 99 | 99 | if ($fix === true) { |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | if ($difference !== -1 && $difference !== 1) { |
| 189 | 189 | $error = 'Closing brace of a %s must be followed by a single blank line; found %s'; |
| 190 | 190 | $data = array( |
| 191 | - $tokens[$stackPtr]['content'], |
|
| 192 | - $difference, |
|
| 193 | - ); |
|
| 191 | + $tokens[$stackPtr]['content'], |
|
| 192 | + $difference, |
|
| 193 | + ); |
|
| 194 | 194 | $fix = $phpcsFile->addFixableError($error, $closeBrace, 'NewlinesAfterCloseBrace', $data); |
| 195 | 195 | if ($fix === true) { |
| 196 | 196 | if ($difference === 0) { |
@@ -191,7 +191,7 @@ |
||
| 191 | 191 | $tokens[$stackPtr]['content'], |
| 192 | 192 | $difference, |
| 193 | 193 | ); |
| 194 | - $fix = $phpcsFile->addFixableError($error, $closeBrace, 'NewlinesAfterCloseBrace', $data); |
|
| 194 | + $fix = $phpcsFile->addFixableError($error, $closeBrace, 'NewlinesAfterCloseBrace', $data); |
|
| 195 | 195 | if ($fix === true) { |
| 196 | 196 | if ($difference === 0) { |
| 197 | 197 | $first = $phpcsFile->findFirstOnLine(array(), $nextContent, true); |
@@ -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 | * |
@@ -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 | { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * Processes this test, when one of its tokens is encountered. |
| 37 | 37 | * |
| 38 | - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. |
|
| 38 | + * @param File $phpcsFile The current file being processed. |
|
| 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_CLASS, |
| 43 | 43 | T_INTERFACE, |
| 44 | - ); |
|
| 44 | + ); |
|
| 45 | 45 | |
| 46 | 46 | }//end register() |
| 47 | 47 | |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | $type = ucfirst($tokens[$stackPtr]['content']); |
| 85 | 85 | $error = '%s name "%s" is not in camel caps format'; |
| 86 | 86 | $data = array( |
| 87 | - $type, |
|
| 88 | - $name, |
|
| 89 | - ); |
|
| 87 | + $type, |
|
| 88 | + $name, |
|
| 89 | + ); |
|
| 90 | 90 | $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); |
| 91 | 91 | $phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'no'); |
| 92 | 92 | } else { |