GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 699b70...879176 )
by Chris
13:23
created
vendor/fig-r/psr2r-sniffer/PSR2R/Sniffs/PHP/PreferCastOverFunctionSniff.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -26,45 +26,45 @@  discard block
 block discarded – undo
26 26
 	 * @inheritDoc
27 27
 	 */
28 28
 	public function register() {
29
-		return [T_STRING];
29
+		return [ T_STRING ];
30 30
 	}
31 31
 
32 32
 	/**
33 33
 	 * @inheritDoc
34 34
 	 */
35
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
36
-		$wrongTokens = [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW, T_DOUBLE_COLON];
35
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
36
+		$wrongTokens = [ T_FUNCTION, T_OBJECT_OPERATOR, T_NEW, T_DOUBLE_COLON ];
37 37
 
38 38
 		$tokens = $phpcsFile->getTokens();
39 39
 
40
-		$tokenContent = $tokens[$stackPtr]['content'];
41
-		$key = strtolower($tokenContent);
42
-		if (!isset(self::$matching[$key])) {
40
+		$tokenContent = $tokens[ $stackPtr ][ 'content' ];
41
+		$key = strtolower( $tokenContent );
42
+		if ( ! isset( self::$matching[ $key ] ) ) {
43 43
 			return;
44 44
 		}
45 45
 
46
-		$previous = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
47
-		if (!$previous || in_array($tokens[$previous]['code'], $wrongTokens)) {
46
+		$previous = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
47
+		if ( ! $previous || in_array( $tokens[ $previous ][ 'code' ], $wrongTokens ) ) {
48 48
 			return;
49 49
 		}
50 50
 
51
-		$openingBraceIndex = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
52
-		if (!$openingBraceIndex || $tokens[$openingBraceIndex]['type'] !== 'T_OPEN_PARENTHESIS') {
51
+		$openingBraceIndex = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
52
+		if ( ! $openingBraceIndex || $tokens[ $openingBraceIndex ][ 'type' ] !== 'T_OPEN_PARENTHESIS' ) {
53 53
 			return;
54 54
 		}
55 55
 
56
-		$closingBraceIndex = $tokens[$openingBraceIndex]['parenthesis_closer'];
56
+		$closingBraceIndex = $tokens[ $openingBraceIndex ][ 'parenthesis_closer' ];
57 57
 
58 58
 		// We must ignore when commas are encountered
59
-		if ($this->contains($phpcsFile, 'T_COMMA', $openingBraceIndex + 1, $closingBraceIndex - 1)) {
59
+		if ( $this->contains( $phpcsFile, 'T_COMMA', $openingBraceIndex + 1, $closingBraceIndex - 1 ) ) {
60 60
 			return;
61 61
 		}
62 62
 
63
-		$error = $tokenContent . '() found, should be ' . self::$matching[$key] . ' cast.';
63
+		$error = $tokenContent . '() found, should be ' . self::$matching[ $key ] . ' cast.';
64 64
 
65
-		$fix = $phpcsFile->addFixableError($error, $stackPtr);
66
-		if ($fix) {
67
-			$this->fixContent($phpcsFile, $stackPtr, $key, $openingBraceIndex, $closingBraceIndex);
65
+		$fix = $phpcsFile->addFixableError( $error, $stackPtr );
66
+		if ( $fix ) {
67
+			$this->fixContent( $phpcsFile, $stackPtr, $key, $openingBraceIndex, $closingBraceIndex );
68 68
 		}
69 69
 	}
70 70
 
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
 	 * @param int $closingBraceIndex
77 77
 	 * @return void
78 78
 	 */
79
-	protected function fixContent(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $key, $openingBraceIndex, $closingBraceIndex) {
80
-		$needsBrackets = $this->needsBrackets($phpcsFile, $openingBraceIndex, $closingBraceIndex);
79
+	protected function fixContent( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $key, $openingBraceIndex, $closingBraceIndex ) {
80
+		$needsBrackets = $this->needsBrackets( $phpcsFile, $openingBraceIndex, $closingBraceIndex );
81 81
 
82 82
 		$tokens = $phpcsFile->getTokens();
83 83
 
84
-		$cast = '(' . self::$matching[$key] . ')';
84
+		$cast = '(' . self::$matching[ $key ] . ')';
85 85
 
86
-		$phpcsFile->fixer->replaceToken($stackPtr, $cast);
87
-		if (!$needsBrackets) {
88
-			$phpcsFile->fixer->replaceToken($openingBraceIndex, '');
89
-			$phpcsFile->fixer->replaceToken($closingBraceIndex, '');
86
+		$phpcsFile->fixer->replaceToken( $stackPtr, $cast );
87
+		if ( ! $needsBrackets ) {
88
+			$phpcsFile->fixer->replaceToken( $openingBraceIndex, '' );
89
+			$phpcsFile->fixer->replaceToken( $closingBraceIndex, '' );
90 90
 		}
91 91
 	}
92 92
 
Please login to merge, or discard this patch.
PSR2R/Sniffs/Namespaces/NoInlineFullyQualifiedClassNameSniff.php 1 patch
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * @var array
27 27
 	 */
28
-	protected $newStatements = [];
28
+	protected $newStatements = [ ];
29 29
 
30 30
 	/**
31 31
 	 * @var array
@@ -36,32 +36,32 @@  discard block
 block discarded – undo
36 36
 	 * @inheritDoc
37 37
 	 */
38 38
 	public function register() {
39
-		return [T_NEW, T_FUNCTION, T_DOUBLE_COLON, T_CLASS];
39
+		return [ T_NEW, T_FUNCTION, T_DOUBLE_COLON, T_CLASS ];
40 40
 	}
41 41
 
42 42
 	/**
43 43
 	 * @inheritDoc
44 44
 	 */
45
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
45
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
46 46
 		$tokens = $phpcsFile->getTokens();
47 47
 
48 48
 		// Skip non-namespaces files for now
49
-		if (!$this->hasNamespace($phpcsFile)) {
49
+		if ( ! $this->hasNamespace( $phpcsFile ) ) {
50 50
 			return;
51 51
 		}
52 52
 
53 53
 		//$namespaceStatement = $this->getNamespaceInfo($phpcsFile);
54 54
 
55
-		$this->loadStatements($phpcsFile);
55
+		$this->loadStatements( $phpcsFile );
56 56
 
57
-		if ($tokens[$stackPtr]['code'] === T_CLASS) {
58
-			$this->checkUseForClass($phpcsFile, $stackPtr);
59
-		} elseif ($tokens[$stackPtr]['code'] === T_NEW) {
60
-			$this->checkUseForNew($phpcsFile, $stackPtr);
61
-		} elseif ($tokens[$stackPtr]['code'] === T_DOUBLE_COLON) {
62
-			$this->checkUseForStatic($phpcsFile, $stackPtr);
57
+		if ( $tokens[ $stackPtr ][ 'code' ] === T_CLASS ) {
58
+			$this->checkUseForClass( $phpcsFile, $stackPtr );
59
+		} elseif ( $tokens[ $stackPtr ][ 'code' ] === T_NEW ) {
60
+			$this->checkUseForNew( $phpcsFile, $stackPtr );
61
+		} elseif ( $tokens[ $stackPtr ][ 'code' ] === T_DOUBLE_COLON ) {
62
+			$this->checkUseForStatic( $phpcsFile, $stackPtr );
63 63
 		} else {
64
-			$this->checkUseForSignature($phpcsFile, $stackPtr);
64
+			$this->checkUseForSignature( $phpcsFile, $stackPtr );
65 65
 		}
66 66
 	}
67 67
 
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	 * @param int $stackPtr
73 73
 	 * @return void
74 74
 	 */
75
-	protected function checkUseForClass(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
75
+	protected function checkUseForClass( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
76 76
 		$tokens = $phpcsFile->getTokens();
77 77
 
78
-		$nextIndex = $phpcsFile->findNext(T_EXTENDS, $stackPtr + 1);
79
-		if ($nextIndex) {
80
-			$this->checkUseForExtends($phpcsFile, $nextIndex);
78
+		$nextIndex = $phpcsFile->findNext( T_EXTENDS, $stackPtr + 1 );
79
+		if ( $nextIndex ) {
80
+			$this->checkUseForExtends( $phpcsFile, $nextIndex );
81 81
 		}
82 82
 
83
-		$nextIndex = $phpcsFile->findNext(T_IMPLEMENTS, $stackPtr + 1);
84
-		if ($nextIndex) {
85
-			$this->checkUseForImplements($phpcsFile, $nextIndex);
83
+		$nextIndex = $phpcsFile->findNext( T_IMPLEMENTS, $stackPtr + 1 );
84
+		if ( $nextIndex ) {
85
+			$this->checkUseForImplements( $phpcsFile, $nextIndex );
86 86
 		}
87 87
 	}
88 88
 
@@ -91,61 +91,61 @@  discard block
 block discarded – undo
91 91
 	 * @param int $stackPtr
92 92
 	 * @return void
93 93
 	 */
94
-	protected function checkUseForNew(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
94
+	protected function checkUseForNew( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
95 95
 		$tokens = $phpcsFile->getTokens();
96 96
 
97
-		$nextIndex = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true);
97
+		$nextIndex = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true );
98 98
 		$lastIndex = null;
99 99
 		$i = $nextIndex;
100 100
 		$extractedUseStatement = '';
101 101
 		$lastSeparatorIndex = null;
102
-		while (true) {
103
-			if (!$this->isGivenKind([T_NS_SEPARATOR, T_STRING], $tokens[$i])) {
102
+		while ( true ) {
103
+			if ( ! $this->isGivenKind( [ T_NS_SEPARATOR, T_STRING ], $tokens[ $i ] ) ) {
104 104
 				break;
105 105
 			}
106 106
 			$lastIndex = $i;
107
-			$extractedUseStatement .= $tokens[$i]['content'];
107
+			$extractedUseStatement .= $tokens[ $i ][ 'content' ];
108 108
 
109
-			if ($this->isGivenKind([T_NS_SEPARATOR], $tokens[$i])) {
109
+			if ( $this->isGivenKind( [ T_NS_SEPARATOR ], $tokens[ $i ] ) ) {
110 110
 				$lastSeparatorIndex = $i;
111 111
 			}
112 112
 			++$i;
113 113
 		}
114 114
 
115
-		if ($lastIndex === null || $lastSeparatorIndex === null) {
115
+		if ( $lastIndex === null || $lastSeparatorIndex === null ) {
116 116
 			return;
117 117
 		}
118 118
 
119
-		$extractedUseStatement = ltrim($extractedUseStatement, '\\');
119
+		$extractedUseStatement = ltrim( $extractedUseStatement, '\\' );
120 120
 
121 121
 		$className = '';
122
-		for ($i = $lastSeparatorIndex + 1; $i <= $lastIndex; ++$i) {
123
-			$className .= $tokens[$i]['content'];
122
+		for ( $i = $lastSeparatorIndex + 1; $i <= $lastIndex; ++$i ) {
123
+			$className .= $tokens[ $i ][ 'content' ];
124 124
 		}
125 125
 
126 126
 		$error = 'Use statement ' . $extractedUseStatement . ' for ' . $className . ' should be in use block.';
127
-		$fix = $phpcsFile->addFixableError($error, $stackPtr, 'New');
128
-		if (!$fix) {
127
+		$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'New' );
128
+		if ( ! $fix ) {
129 129
 			return;
130 130
 		}
131 131
 
132 132
 		$phpcsFile->fixer->beginChangeset();
133 133
 
134
-		$addedUseStatement = $this->addUseStatement($phpcsFile, $className, $extractedUseStatement);
134
+		$addedUseStatement = $this->addUseStatement( $phpcsFile, $className, $extractedUseStatement );
135 135
 
136
-		for ($i = $nextIndex; $i <= $lastSeparatorIndex; ++$i) {
137
-			$phpcsFile->fixer->replaceToken($i, '');
136
+		for ( $i = $nextIndex; $i <= $lastSeparatorIndex; ++$i ) {
137
+			$phpcsFile->fixer->replaceToken( $i, '' );
138 138
 		}
139 139
 
140
-		if ($addedUseStatement['alias'] !== null) {
141
-			$phpcsFile->fixer->replaceToken($lastSeparatorIndex + 1, $addedUseStatement['alias']);
142
-			for ($i = $lastSeparatorIndex + 2; $i <= $lastIndex; ++$i) {
143
-				$phpcsFile->fixer->replaceToken($i, '');
140
+		if ( $addedUseStatement[ 'alias' ] !== null ) {
141
+			$phpcsFile->fixer->replaceToken( $lastSeparatorIndex + 1, $addedUseStatement[ 'alias' ] );
142
+			for ( $i = $lastSeparatorIndex + 2; $i <= $lastIndex; ++$i ) {
143
+				$phpcsFile->fixer->replaceToken( $i, '' );
144 144
 			}
145 145
 		}
146 146
 
147
-		if ($nextIndex === $stackPtr + 1) {
148
-			$phpcsFile->fixer->replaceToken($stackPtr, $tokens[$stackPtr]['content'] . ' ');
147
+		if ( $nextIndex === $stackPtr + 1 ) {
148
+			$phpcsFile->fixer->replaceToken( $stackPtr, $tokens[ $stackPtr ][ 'content' ] . ' ' );
149 149
 		}
150 150
 
151 151
 		$phpcsFile->fixer->endChangeset();
@@ -156,56 +156,56 @@  discard block
 block discarded – undo
156 156
 	 * @param int $stackPtr
157 157
 	 * @return void
158 158
 	 */
159
-	protected function checkUseForStatic(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
159
+	protected function checkUseForStatic( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
160 160
 		$tokens = $phpcsFile->getTokens();
161 161
 
162
-		$prevIndex = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr - 1, null, true);
162
+		$prevIndex = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr - 1, null, true );
163 163
 
164 164
 		$lastIndex = null;
165 165
 		$i = $prevIndex;
166 166
 		$extractedUseStatement = '';
167 167
 		$firstSeparatorIndex = null;
168
-		while (true) {
169
-			if (!$this->isGivenKind([T_NS_SEPARATOR, T_STRING], $tokens[$i])) {
168
+		while ( true ) {
169
+			if ( ! $this->isGivenKind( [ T_NS_SEPARATOR, T_STRING ], $tokens[ $i ] ) ) {
170 170
 				break;
171 171
 			}
172 172
 			$lastIndex = $i;
173
-			$extractedUseStatement = $tokens[$i]['content'] . $extractedUseStatement;
173
+			$extractedUseStatement = $tokens[ $i ][ 'content' ] . $extractedUseStatement;
174 174
 
175
-			if ($firstSeparatorIndex === null && $this->isGivenKind([T_NS_SEPARATOR], $tokens[$i])) {
175
+			if ( $firstSeparatorIndex === null && $this->isGivenKind( [ T_NS_SEPARATOR ], $tokens[ $i ] ) ) {
176 176
 				$firstSeparatorIndex = $i;
177 177
 			}
178 178
 			--$i;
179 179
 		}
180 180
 
181
-		if ($lastIndex === null || $firstSeparatorIndex === null) {
181
+		if ( $lastIndex === null || $firstSeparatorIndex === null ) {
182 182
 			return;
183 183
 		}
184 184
 
185
-		$extractedUseStatement = ltrim($extractedUseStatement, '\\');
185
+		$extractedUseStatement = ltrim( $extractedUseStatement, '\\' );
186 186
 
187 187
 		$className = '';
188
-		for ($i = $firstSeparatorIndex + 1; $i <= $prevIndex; ++$i) {
189
-			$className .= $tokens[$i]['content'];
188
+		for ( $i = $firstSeparatorIndex + 1; $i <= $prevIndex; ++$i ) {
189
+			$className .= $tokens[ $i ][ 'content' ];
190 190
 		}
191 191
 
192 192
 		$error = 'Use statement ' . $extractedUseStatement . ' for ' . $className . ' should be in use block.';
193
-		$fix = $phpcsFile->addFixableError($error, $stackPtr, 'Static');
194
-		if (!$fix) {
193
+		$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'Static' );
194
+		if ( ! $fix ) {
195 195
 			return;
196 196
 		}
197 197
 
198 198
 		$phpcsFile->fixer->beginChangeset();
199
-		$addedUseStatement = $this->addUseStatement($phpcsFile, $className, $extractedUseStatement);
199
+		$addedUseStatement = $this->addUseStatement( $phpcsFile, $className, $extractedUseStatement );
200 200
 
201
-		for ($i = $lastIndex; $i <= $firstSeparatorIndex; ++$i) {
202
-			$phpcsFile->fixer->replaceToken($i, '');
201
+		for ( $i = $lastIndex; $i <= $firstSeparatorIndex; ++$i ) {
202
+			$phpcsFile->fixer->replaceToken( $i, '' );
203 203
 		}
204 204
 
205
-		if ($addedUseStatement['alias'] !== null) {
206
-			$phpcsFile->fixer->replaceToken($firstSeparatorIndex + 1, $addedUseStatement['alias']);
207
-			for ($i = $firstSeparatorIndex + 2; $i <= $lastIndex; ++$i) {
208
-				$phpcsFile->fixer->replaceToken($i, '');
205
+		if ( $addedUseStatement[ 'alias' ] !== null ) {
206
+			$phpcsFile->fixer->replaceToken( $firstSeparatorIndex + 1, $addedUseStatement[ 'alias' ] );
207
+			for ( $i = $firstSeparatorIndex + 2; $i <= $lastIndex; ++$i ) {
208
+				$phpcsFile->fixer->replaceToken( $i, '' );
209 209
 			}
210 210
 		}
211 211
 
@@ -217,58 +217,58 @@  discard block
 block discarded – undo
217 217
 	 * @param int $stackPtr
218 218
 	 * @return void
219 219
 	 */
220
-	protected function checkUseForSignature(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
220
+	protected function checkUseForSignature( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
221 221
 		$tokens = $phpcsFile->getTokens();
222 222
 
223
-		$openParenthesisIndex = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr + 1);
224
-		$closeParenthesisIndex = $tokens[$openParenthesisIndex]['parenthesis_closer'];
223
+		$openParenthesisIndex = $phpcsFile->findNext( T_OPEN_PARENTHESIS, $stackPtr + 1 );
224
+		$closeParenthesisIndex = $tokens[ $openParenthesisIndex ][ 'parenthesis_closer' ];
225 225
 
226
-		for ($i = $openParenthesisIndex + 1; $i < $closeParenthesisIndex; $i++) {
226
+		for ( $i = $openParenthesisIndex + 1; $i < $closeParenthesisIndex; $i++ ) {
227 227
 			$lastIndex = null;
228 228
 			$j = $i;
229 229
 			$extractedUseStatement = '';
230 230
 			$lastSeparatorIndex = null;
231
-			while (true) {
232
-				if (!$this->isGivenKind([T_NS_SEPARATOR, T_STRING], $tokens[$j])) {
231
+			while ( true ) {
232
+				if ( ! $this->isGivenKind( [ T_NS_SEPARATOR, T_STRING ], $tokens[ $j ] ) ) {
233 233
 					break;
234 234
 				}
235 235
 
236 236
 				$lastIndex = $j;
237
-				$extractedUseStatement .= $tokens[$j]['content'];
238
-				if ($this->isGivenKind([T_NS_SEPARATOR], $tokens[$j])) {
237
+				$extractedUseStatement .= $tokens[ $j ][ 'content' ];
238
+				if ( $this->isGivenKind( [ T_NS_SEPARATOR ], $tokens[ $j ] ) ) {
239 239
 					$lastSeparatorIndex = $j;
240 240
 				}
241 241
 				++$j;
242 242
 			}
243 243
 			$i = $j;
244 244
 
245
-			if ($lastIndex === null || $lastSeparatorIndex === null) {
245
+			if ( $lastIndex === null || $lastSeparatorIndex === null ) {
246 246
 				continue;
247 247
 			}
248 248
 
249
-			$extractedUseStatement = ltrim($extractedUseStatement, '\\');
249
+			$extractedUseStatement = ltrim( $extractedUseStatement, '\\' );
250 250
 			$className = '';
251
-			for ($k = $lastSeparatorIndex + 1; $k <= $lastIndex; ++$k) {
252
-				$className .= $tokens[$k]['content'];
251
+			for ( $k = $lastSeparatorIndex + 1; $k <= $lastIndex; ++$k ) {
252
+				$className .= $tokens[ $k ][ 'content' ];
253 253
 			}
254 254
 
255 255
 			$error = 'Use statement ' . $extractedUseStatement . ' for ' . $className . ' should be in use block.';
256
-			$fix = $phpcsFile->addFixableError($error, $stackPtr, 'Signature');
257
-			if (!$fix) {
256
+			$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'Signature' );
257
+			if ( ! $fix ) {
258 258
 				return;
259 259
 			}
260 260
 
261 261
 			$phpcsFile->fixer->beginChangeset();
262
-			$addedUseStatement = $this->addUseStatement($phpcsFile, $className, $extractedUseStatement);
262
+			$addedUseStatement = $this->addUseStatement( $phpcsFile, $className, $extractedUseStatement );
263 263
 
264
-			for ($k = $lastSeparatorIndex; $k < $lastIndex; ++$k) {
265
-				$phpcsFile->fixer->replaceToken($k, '');
264
+			for ( $k = $lastSeparatorIndex; $k < $lastIndex; ++$k ) {
265
+				$phpcsFile->fixer->replaceToken( $k, '' );
266 266
 			}
267 267
 
268
-			if ($addedUseStatement['alias'] !== null) {
269
-				$phpcsFile->fixer->replaceToken($lastIndex + 1, $addedUseStatement['alias']);
270
-				for ($k = $lastSeparatorIndex + 2; $k <= $lastIndex; ++$k) {
271
-					$phpcsFile->fixer->replaceToken($k, '');
268
+			if ( $addedUseStatement[ 'alias' ] !== null ) {
269
+				$phpcsFile->fixer->replaceToken( $lastIndex + 1, $addedUseStatement[ 'alias' ] );
270
+				for ( $k = $lastSeparatorIndex + 2; $k <= $lastIndex; ++$k ) {
271
+					$phpcsFile->fixer->replaceToken( $k, '' );
272 272
 				}
273 273
 			}
274 274
 
@@ -281,15 +281,15 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return void
283 283
 	 */
284
-	protected function loadStatements(PHP_CodeSniffer_File $phpcsFile) {
285
-		if ($this->existingStatements !== null) {
284
+	protected function loadStatements( PHP_CodeSniffer_File $phpcsFile ) {
285
+		if ( $this->existingStatements !== null ) {
286 286
 			return;
287 287
 		}
288 288
 
289
-		$existingStatements = $this->getUseStatements($phpcsFile);
289
+		$existingStatements = $this->getUseStatements( $phpcsFile );
290 290
 		$this->existingStatements = $existingStatements;
291 291
 		$this->allStatements = $existingStatements;
292
-		$this->newStatements = [];
292
+		$this->newStatements = [ ];
293 293
 	}
294 294
 
295 295
 	/**
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return bool
299 299
 	 */
300
-	protected function isBlacklistedFile(PHP_CodeSniffer_File $phpcsFile) {
300
+	protected function isBlacklistedFile( PHP_CodeSniffer_File $phpcsFile ) {
301 301
 		$file = $phpcsFile->getFilename();
302
-		if (strpos($file, DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR) !== false) {
302
+		if ( strpos( $file, DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR ) !== false ) {
303 303
 			return true;
304 304
 		}
305 305
 
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @return bool
315 315
 	 */
316
-	protected function isMultipleUseStatement($statementContent) {
317
-		if (strpos($statementContent, ',') !== false) {
316
+	protected function isMultipleUseStatement( $statementContent ) {
317
+		if ( strpos( $statementContent, ',' ) !== false ) {
318 318
 			return true;
319 319
 		}
320 320
 
@@ -327,26 +327,26 @@  discard block
 block discarded – undo
327 327
 	 *
328 328
 	 * @return string|null
329 329
 	 */
330
-	protected function generateUniqueAlias($shortName, $fullName) {
330
+	protected function generateUniqueAlias( $shortName, $fullName ) {
331 331
 		$alias = $shortName;
332 332
 		$count = 0;
333
-		$pieces = explode('\\', $fullName);
334
-		$pieces = array_reverse($pieces);
335
-		array_shift($pieces);
333
+		$pieces = explode( '\\', $fullName );
334
+		$pieces = array_reverse( $pieces );
335
+		array_shift( $pieces );
336 336
 
337
-		while (isset($this->allStatements[$alias])) {
337
+		while ( isset( $this->allStatements[ $alias ] ) ) {
338 338
 			$alias = $shortName;
339 339
 
340
-			if (count($pieces) - 1 < $count && !in_array($pieces, 'Php')) {
341
-				$pieces[] = 'Php';
340
+			if ( count( $pieces ) - 1 < $count && ! in_array( $pieces, 'Php' ) ) {
341
+				$pieces[ ] = 'Php';
342 342
 			}
343
-			if (count($pieces) - 1 < $count) {
343
+			if ( count( $pieces ) - 1 < $count ) {
344 344
 				return null;
345 345
 			}
346 346
 
347 347
 			$prefix = '';
348
-			for ($i = 0; $i <= $count; ++$i) {
349
-				$prefix .= $pieces[$i];
348
+			for ( $i = 0; $i <= $count; ++$i ) {
349
+				$prefix .= $pieces[ $i ];
350 350
 			}
351 351
 
352 352
 			$alias = $prefix . $alias;
@@ -361,59 +361,59 @@  discard block
 block discarded – undo
361 361
 	 * @param \PHP_CodeSniffer_File $phpcsFile
362 362
 	 * @return array
363 363
 	 */
364
-	protected function getUseStatements(PHP_CodeSniffer_File $phpcsFile) {
364
+	protected function getUseStatements( PHP_CodeSniffer_File $phpcsFile ) {
365 365
 		$tokens = $phpcsFile->getTokens();
366 366
 
367
-		$statements = [];
368
-		foreach ($tokens as $index => $token) {
369
-			if ($token['code'] !== T_USE) {
367
+		$statements = [ ];
368
+		foreach ( $tokens as $index => $token ) {
369
+			if ( $token[ 'code' ] !== T_USE ) {
370 370
 				continue;
371 371
 			}
372
-			if ($this->shouldIgnoreUse($phpcsFile, $index)) {
372
+			if ( $this->shouldIgnoreUse( $phpcsFile, $index ) ) {
373 373
 				continue;
374 374
 			}
375 375
 
376
-			$useStatementStartIndex = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $index + 1, null, true);
376
+			$useStatementStartIndex = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, $index + 1, null, true );
377 377
 
378 378
 			// Ignore function () use ($foo) {}
379
-			if ($tokens[$useStatementStartIndex]['content'] === '(') {
379
+			if ( $tokens[ $useStatementStartIndex ][ 'content' ] === '(' ) {
380 380
 				continue;
381 381
 			}
382 382
 
383
-			$semicolonIndex = $phpcsFile->findNext(T_SEMICOLON, $useStatementStartIndex + 1);
384
-			$useStatementEndIndex = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $semicolonIndex - 1, null, true);
383
+			$semicolonIndex = $phpcsFile->findNext( T_SEMICOLON, $useStatementStartIndex + 1 );
384
+			$useStatementEndIndex = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, $semicolonIndex - 1, null, true );
385 385
 
386 386
 			$statement = '';
387
-			for ($i = $useStatementStartIndex; $i <= $useStatementEndIndex; $i++) {
388
-				$statement .= $tokens[$i]['content'];
387
+			for ( $i = $useStatementStartIndex; $i <= $useStatementEndIndex; $i++ ) {
388
+				$statement .= $tokens[ $i ][ 'content' ];
389 389
 			}
390 390
 
391
-			if ($this->isMultipleUseStatement($statement)) {
391
+			if ( $this->isMultipleUseStatement( $statement ) ) {
392 392
 				continue;
393 393
 			}
394 394
 
395
-			$statementParts = preg_split('/\s+as\s+/i', $statement);
395
+			$statementParts = preg_split( '/\s+as\s+/i', $statement );
396 396
 
397
-			if (count($statementParts) === 1) {
397
+			if ( count( $statementParts ) === 1 ) {
398 398
 				$fullName = $statement;
399
-				$statementParts = explode('\\', $fullName);
400
-				$shortName = end($statementParts);
399
+				$statementParts = explode( '\\', $fullName );
400
+				$shortName = end( $statementParts );
401 401
 				$alias = null;
402 402
 			} else {
403
-				$fullName = $statementParts[0];
404
-				$alias = $statementParts[1];
405
-				$statementParts = explode('\\', $fullName);
406
-				$shortName = end($statementParts);
403
+				$fullName = $statementParts[ 0 ];
404
+				$alias = $statementParts[ 1 ];
405
+				$statementParts = explode( '\\', $fullName );
406
+				$shortName = end( $statementParts );
407 407
 			}
408 408
 
409
-			$shortName = trim($shortName);
410
-			$fullName = trim($fullName);
411
-			$key = $alias ?: $shortName;
409
+			$shortName = trim( $shortName );
410
+			$fullName = trim( $fullName );
411
+			$key = $alias ? : $shortName;
412 412
 
413
-			$statements[$key] = [
413
+			$statements[ $key ] = [
414 414
 				'alias' => $alias,
415 415
 				'end' => $semicolonIndex,
416
-				'fullName' => ltrim($fullName, '\\'),
416
+				'fullName' => ltrim( $fullName, '\\' ),
417 417
 				'shortName' => $shortName,
418 418
 				'start' => $index,
419 419
 			];
@@ -429,16 +429,16 @@  discard block
 block discarded – undo
429 429
 	 *
430 430
 	 * @return array
431 431
 	 */
432
-	protected function addUseStatement(PHP_CodeSniffer_File $phpcsFile, $shortName, $fullName) {
433
-		foreach ($this->allStatements as $useStatement) {
434
-			if ($useStatement['fullName'] === $fullName) {
432
+	protected function addUseStatement( PHP_CodeSniffer_File $phpcsFile, $shortName, $fullName ) {
433
+		foreach ( $this->allStatements as $useStatement ) {
434
+			if ( $useStatement[ 'fullName' ] === $fullName ) {
435 435
 				return $useStatement;
436 436
 			}
437 437
 		}
438 438
 
439
-		$alias = $this->generateUniqueAlias($shortName, $fullName);
440
-		if (!$alias) {
441
-			throw new RuntimeException('Could not generate unique alias for `' . $shortName . ' (' . $fullName . ')`.');
439
+		$alias = $this->generateUniqueAlias( $shortName, $fullName );
440
+		if ( ! $alias ) {
441
+			throw new RuntimeException( 'Could not generate unique alias for `' . $shortName . ' (' . $fullName . ')`.' );
442 442
 		}
443 443
 
444 444
 		$result = [
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
 			'fullName' => $fullName,
447 447
 			'shortName' => $shortName,
448 448
 		];
449
-		$this->insertUseStatement($phpcsFile, $result);
449
+		$this->insertUseStatement( $phpcsFile, $result );
450 450
 
451
-		$this->allStatements[$alias] = $result;
452
-		$this->newStatements[$alias] = $result;
451
+		$this->allStatements[ $alias ] = $result;
452
+		$this->newStatements[ $alias ] = $result;
453 453
 
454 454
 		return $result;
455 455
 	}
@@ -459,22 +459,22 @@  discard block
 block discarded – undo
459 459
 	 * @param array $useStatement
460 460
 	 * @return void
461 461
 	 */
462
-	protected function insertUseStatement(PHP_CodeSniffer_File $phpcsFile, array $useStatement) {
462
+	protected function insertUseStatement( PHP_CodeSniffer_File $phpcsFile, array $useStatement ) {
463 463
 		$tokens = $phpcsFile->getTokens();
464 464
 
465 465
 		$existingStatements = $this->existingStatements;
466
-		if ($existingStatements) {
467
-			$lastOne = array_pop($existingStatements);
466
+		if ( $existingStatements ) {
467
+			$lastOne = array_pop( $existingStatements );
468 468
 
469
-			$lastUseStatementIndex = $lastOne['end'];
469
+			$lastUseStatementIndex = $lastOne[ 'end' ];
470 470
 		} else {
471
-			$namespaceStatement = $this->getNamespaceInfo($phpcsFile);
471
+			$namespaceStatement = $this->getNamespaceInfo( $phpcsFile );
472 472
 
473
-			$lastUseStatementIndex = $namespaceStatement['end'];
473
+			$lastUseStatementIndex = $namespaceStatement[ 'end' ];
474 474
 		}
475 475
 
476
-		$phpcsFile->fixer->addNewline($lastUseStatementIndex);
477
-		$phpcsFile->fixer->addContent($lastUseStatementIndex, $this->generateUseStatement($useStatement));
476
+		$phpcsFile->fixer->addNewline( $lastUseStatementIndex );
477
+		$phpcsFile->fixer->addContent( $lastUseStatementIndex, $this->generateUseStatement( $useStatement ) );
478 478
 	}
479 479
 
480 480
 	/**
@@ -482,13 +482,13 @@  discard block
 block discarded – undo
482 482
 	 *
483 483
 	 * @return string
484 484
 	 */
485
-	protected function generateUseStatement(array $useStatement) {
485
+	protected function generateUseStatement( array $useStatement ) {
486 486
 		$alias = '';
487
-		if (!empty($useStatement['alias'])) {
488
-			$alias = ' as ' . $useStatement['alias'];
487
+		if ( ! empty( $useStatement[ 'alias' ] ) ) {
488
+			$alias = ' as ' . $useStatement[ 'alias' ];
489 489
 		}
490 490
 
491
-		$content = 'use ' . $useStatement['fullName'] . $alias . ';';
491
+		$content = 'use ' . $useStatement[ 'fullName' ] . $alias . ';';
492 492
 
493 493
 		return $content;
494 494
 	}
@@ -498,41 +498,41 @@  discard block
 block discarded – undo
498 498
 	 * @param int $nextIndex
499 499
 	 * @return void
500 500
 	 */
501
-	protected function checkUseForExtends(PHP_CodeSniffer_File $phpcsFile, $nextIndex) {
501
+	protected function checkUseForExtends( PHP_CodeSniffer_File $phpcsFile, $nextIndex ) {
502 502
 		$tokens = $phpcsFile->getTokens();
503 503
 
504
-		$endIndex = $phpcsFile->findNext([T_IMPLEMENTS, T_CURLY_OPEN], $nextIndex + 1);
504
+		$endIndex = $phpcsFile->findNext( [ T_IMPLEMENTS, T_CURLY_OPEN ], $nextIndex + 1 );
505 505
 
506
-		$startIndex = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextIndex + 1, null, true);
507
-		$endIndex = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $endIndex - 1, null, true);
506
+		$startIndex = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, $nextIndex + 1, null, true );
507
+		$endIndex = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, $endIndex - 1, null, true );
508 508
 
509
-		if (!$this->contains($phpcsFile, T_NS_SEPARATOR, $startIndex, $endIndex)) {
509
+		if ( ! $this->contains( $phpcsFile, T_NS_SEPARATOR, $startIndex, $endIndex ) ) {
510 510
 			return;
511 511
 		}
512 512
 
513
-		$extractedUseStatements = $this->extractUseStatements($phpcsFile, $startIndex, $endIndex);
514
-		foreach ($extractedUseStatements as $extractedUseStatement) {
515
-			if (strpos($extractedUseStatement['statement'], '\\') === false) {
513
+		$extractedUseStatements = $this->extractUseStatements( $phpcsFile, $startIndex, $endIndex );
514
+		foreach ( $extractedUseStatements as $extractedUseStatement ) {
515
+			if ( strpos( $extractedUseStatement[ 'statement' ], '\\' ) === false ) {
516 516
 				continue;
517 517
 			}
518 518
 
519
-			$className = $this->extractClassNameFromUseStatementAsString($extractedUseStatement['statement']);
520
-			$error = 'Use statement ' . $extractedUseStatement['statement'] . ' for ' . $className . ' should be in use block.';
521
-			$fix = $phpcsFile->addFixableError($error, $extractedUseStatement['start'], 'Extends');
522
-			if (!$fix) {
519
+			$className = $this->extractClassNameFromUseStatementAsString( $extractedUseStatement[ 'statement' ] );
520
+			$error = 'Use statement ' . $extractedUseStatement[ 'statement' ] . ' for ' . $className . ' should be in use block.';
521
+			$fix = $phpcsFile->addFixableError( $error, $extractedUseStatement[ 'start' ], 'Extends' );
522
+			if ( ! $fix ) {
523 523
 				return;
524 524
 			}
525 525
 
526 526
 			$phpcsFile->fixer->beginChangeset();
527
-			$addedUseStatement = $this->addUseStatement($phpcsFile, $className, $extractedUseStatement['statement']);
527
+			$addedUseStatement = $this->addUseStatement( $phpcsFile, $className, $extractedUseStatement[ 'statement' ] );
528 528
 			//$lastSeparatorIndex = $phpcsFile->findPrevious(T_NS_SEPARATOR, $extractedUseStatement['end'] - 1, $extractedUseStatement['start']);
529 529
 
530
-			for ($k = $extractedUseStatement['start']; $k < $extractedUseStatement['end']; ++$k) {
531
-				$phpcsFile->fixer->replaceToken($k, '');
530
+			for ( $k = $extractedUseStatement[ 'start' ]; $k < $extractedUseStatement[ 'end' ]; ++$k ) {
531
+				$phpcsFile->fixer->replaceToken( $k, '' );
532 532
 			}
533 533
 
534
-			if ($addedUseStatement['alias'] !== null) {
535
-				$phpcsFile->fixer->replaceToken($extractedUseStatement['end'], $addedUseStatement['alias']);
534
+			if ( $addedUseStatement[ 'alias' ] !== null ) {
535
+				$phpcsFile->fixer->replaceToken( $extractedUseStatement[ 'end' ], $addedUseStatement[ 'alias' ] );
536 536
 			}
537 537
 
538 538
 			$phpcsFile->fixer->endChangeset();
@@ -544,37 +544,37 @@  discard block
 block discarded – undo
544 544
 	 * @param int $nextIndex
545 545
 	 * @return void
546 546
 	 */
547
-	protected function checkUseForImplements(PHP_CodeSniffer_File $phpcsFile, $nextIndex) {
547
+	protected function checkUseForImplements( PHP_CodeSniffer_File $phpcsFile, $nextIndex ) {
548 548
 		$tokens = $phpcsFile->getTokens();
549 549
 
550
-		$endIndex = $phpcsFile->findNext([T_OPEN_CURLY_BRACKET], $nextIndex + 1);
550
+		$endIndex = $phpcsFile->findNext( [ T_OPEN_CURLY_BRACKET ], $nextIndex + 1 );
551 551
 
552
-		$startIndex = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextIndex + 1, null, true);
553
-		$endIndex = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $endIndex - 1, null, true);
552
+		$startIndex = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, $nextIndex + 1, null, true );
553
+		$endIndex = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, $endIndex - 1, null, true );
554 554
 
555
-		$extractedUseStatements = $this->extractUseStatements($phpcsFile, $startIndex, $endIndex);
556
-		foreach ($extractedUseStatements as $extractedUseStatement) {
557
-			if (strpos($extractedUseStatement['statement'], '\\') === false) {
555
+		$extractedUseStatements = $this->extractUseStatements( $phpcsFile, $startIndex, $endIndex );
556
+		foreach ( $extractedUseStatements as $extractedUseStatement ) {
557
+			if ( strpos( $extractedUseStatement[ 'statement' ], '\\' ) === false ) {
558 558
 				continue;
559 559
 			}
560 560
 
561
-			$className = $this->extractClassNameFromUseStatementAsString($extractedUseStatement['statement']);
562
-			$error = 'Use statement ' . $extractedUseStatement['statement'] . ' for ' . $className . ' should be in use block.';
563
-			$fix = $phpcsFile->addFixableError($error, $extractedUseStatement['start'], 'Implements');
564
-			if (!$fix) {
561
+			$className = $this->extractClassNameFromUseStatementAsString( $extractedUseStatement[ 'statement' ] );
562
+			$error = 'Use statement ' . $extractedUseStatement[ 'statement' ] . ' for ' . $className . ' should be in use block.';
563
+			$fix = $phpcsFile->addFixableError( $error, $extractedUseStatement[ 'start' ], 'Implements' );
564
+			if ( ! $fix ) {
565 565
 				continue;
566 566
 			}
567 567
 
568 568
 			$phpcsFile->fixer->beginChangeset();
569
-			$addedUseStatement = $this->addUseStatement($phpcsFile, $className, $extractedUseStatement['statement']);
569
+			$addedUseStatement = $this->addUseStatement( $phpcsFile, $className, $extractedUseStatement[ 'statement' ] );
570 570
 			//$lastSeparatorIndex = $phpcsFile->findPrevious(T_NS_SEPARATOR, $extractedUseStatement['end'] - 1, $extractedUseStatement['start']);
571 571
 
572
-			for ($k = $extractedUseStatement['start']; $k < $extractedUseStatement['end']; ++$k) {
573
-				$phpcsFile->fixer->replaceToken($k, '');
572
+			for ( $k = $extractedUseStatement[ 'start' ]; $k < $extractedUseStatement[ 'end' ]; ++$k ) {
573
+				$phpcsFile->fixer->replaceToken( $k, '' );
574 574
 			}
575 575
 
576
-			if ($addedUseStatement['alias'] !== null) {
577
-				$phpcsFile->fixer->replaceToken($extractedUseStatement['end'], $addedUseStatement['alias']);
576
+			if ( $addedUseStatement[ 'alias' ] !== null ) {
577
+				$phpcsFile->fixer->replaceToken( $extractedUseStatement[ 'end' ], $addedUseStatement[ 'alias' ] );
578 578
 			}
579 579
 
580 580
 			$phpcsFile->fixer->endChangeset();
@@ -587,35 +587,35 @@  discard block
 block discarded – undo
587 587
 	 * @param int $endIndex
588 588
 	 * @return array
589 589
 	 */
590
-	protected function extractUseStatements(PHP_CodeSniffer_File $phpcsFile, $startIndex, $endIndex) {
590
+	protected function extractUseStatements( PHP_CodeSniffer_File $phpcsFile, $startIndex, $endIndex ) {
591 591
 		$tokens = $phpcsFile->getTokens();
592 592
 
593
-		$result = [];
593
+		$result = [ ];
594 594
 		$start = null;
595
-		for ($i = $startIndex; $i <= $endIndex; ++$i) {
596
-			if ($start === null && $this->isGivenKind(T_WHITESPACE, $tokens[$i])) {
595
+		for ( $i = $startIndex; $i <= $endIndex; ++$i ) {
596
+			if ( $start === null && $this->isGivenKind( T_WHITESPACE, $tokens[ $i ] ) ) {
597 597
 				continue;
598 598
 			}
599 599
 
600
-			if ($this->isGivenKind(T_COMMA, $tokens[$i])) {
601
-				$result[] = [
600
+			if ( $this->isGivenKind( T_COMMA, $tokens[ $i ] ) ) {
601
+				$result[ ] = [
602 602
 					'start' => $start,
603
-					'end' => $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $i - 1, null, true),
604
-					'statement' => $this->extractUseStatementsAsString($tokens, $start, $i - 1)
603
+					'end' => $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, $i - 1, null, true ),
604
+					'statement' => $this->extractUseStatementsAsString( $tokens, $start, $i - 1 )
605 605
 				];
606 606
 				$start = null;
607 607
 				continue;
608 608
 			}
609 609
 
610
-			if ($start === null) {
610
+			if ( $start === null ) {
611 611
 				$start = $i;
612 612
 			}
613 613
 		}
614 614
 
615
-		$result[] = [
615
+		$result[ ] = [
616 616
 			'start' => $start,
617
-			'end' => $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $i, null, true),
618
-			'statement' => $this->extractUseStatementsAsString($tokens, $start, $i),
617
+			'end' => $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, $i, null, true ),
618
+			'statement' => $this->extractUseStatementsAsString( $tokens, $start, $i ),
619 619
 		];
620 620
 
621 621
 		return $result;
@@ -627,28 +627,28 @@  discard block
 block discarded – undo
627 627
 	 * @param int $end
628 628
 	 * @return string
629 629
 	 */
630
-	protected function extractUseStatementsAsString(array $tokens, $start, $end) {
630
+	protected function extractUseStatementsAsString( array $tokens, $start, $end ) {
631 631
 		$string = '';
632
-		for ($i = $start; $i <= $end; ++$i) {
633
-			$string .= $tokens[$i]['content'];
632
+		for ( $i = $start; $i <= $end; ++$i ) {
633
+			$string .= $tokens[ $i ][ 'content' ];
634 634
 		}
635 635
 
636
-		$string = trim($string);
636
+		$string = trim( $string );
637 637
 
638
-		return ltrim($string, '\\');
638
+		return ltrim( $string, '\\' );
639 639
 	}
640 640
 
641 641
 	/**
642 642
 	 * @param string $useStatement
643 643
 	 * @return string
644 644
 	 */
645
-	protected function extractClassNameFromUseStatementAsString($useStatement) {
646
-		$lastSeparator = strrpos($useStatement, '\\');
647
-		if ($lastSeparator === false) {
645
+	protected function extractClassNameFromUseStatementAsString( $useStatement ) {
646
+		$lastSeparator = strrpos( $useStatement, '\\' );
647
+		if ( $lastSeparator === false ) {
648 648
 			return $useStatement;
649 649
 		}
650 650
 
651
-		return substr($useStatement, $lastSeparator + 1);
651
+		return substr( $useStatement, $lastSeparator + 1 );
652 652
 	}
653 653
 
654 654
 }
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/Namespaces/UseInAlphabeticalOrderSniff.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -33,75 +33,75 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @var array
35 35
 	 */
36
-	protected $_processed = [];
36
+	protected $_processed = [ ];
37 37
 
38 38
 	/**
39 39
 	 * The list of use statements, their content and scope.
40 40
 	 *
41 41
 	 * @var array
42 42
 	 */
43
-	protected $_uses = [];
43
+	protected $_uses = [ ];
44 44
 
45 45
 	/**
46 46
 	 * @inheritDoc
47 47
 	 */
48 48
 	public function register() {
49
-		return [T_USE];
49
+		return [ T_USE ];
50 50
 	}
51 51
 
52 52
 	/**
53 53
 	 * @inheritDoc
54 54
 	 */
55
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
56
-		if (isset($this->_processed[$phpcsFile->getFilename()])) {
55
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
56
+		if ( isset( $this->_processed[ $phpcsFile->getFilename() ] ) ) {
57 57
 			return;
58 58
 		}
59 59
 
60
-		$this->_uses = [];
60
+		$this->_uses = [ ];
61 61
 		$next = $stackPtr;
62 62
 
63
-		while ($next !== false) {
64
-			$this->checkUseToken($phpcsFile, $next);
65
-			$next = $phpcsFile->findNext(T_USE, $next + 1);
63
+		while ( $next !== false ) {
64
+			$this->checkUseToken( $phpcsFile, $next );
65
+			$next = $phpcsFile->findNext( T_USE, $next + 1 );
66 66
 		}
67 67
 
68 68
 		// Prevent multiple uses in the same file from entering
69
-		$this->_processed[$phpcsFile->getFilename()] = true;
69
+		$this->_processed[ $phpcsFile->getFilename() ] = true;
70 70
 
71
-		foreach ($this->_uses as $scope => $used) {
72
-			$defined = $sorted = array_keys($used);
71
+		foreach ( $this->_uses as $scope => $used ) {
72
+			$defined = $sorted = array_keys( $used );
73 73
 
74
-			natcasesort($sorted);
75
-			$sorted = array_values($sorted);
76
-			if ($sorted === $defined) {
74
+			natcasesort( $sorted );
75
+			$sorted = array_values( $sorted );
76
+			if ( $sorted === $defined ) {
77 77
 				continue;
78 78
 			}
79 79
 
80 80
 			$wrongName = null;
81
-			foreach ($defined as $i => $name) {
82
-				if ($name !== $sorted[$i]) {
81
+			foreach ( $defined as $i => $name ) {
82
+				if ( $name !== $sorted[ $i ] ) {
83 83
 					$wrongName = $name;
84 84
 					break;
85 85
 				}
86 86
 			}
87 87
 
88 88
 			$error = 'Use classes must be in alphabetical order.';
89
-			$fix = $phpcsFile->addFixableError($error, $used[$wrongName], 'Order', []);
90
-			if ($fix) {
91
-				$map = [];
92
-				foreach ($sorted as $name) {
93
-					$tokenIndex = array_shift($used);
94
-					$tokenIndex = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $tokenIndex + 1, null, true);
95
-					$map[$tokenIndex] = $name;
89
+			$fix = $phpcsFile->addFixableError( $error, $used[ $wrongName ], 'Order', [ ] );
90
+			if ( $fix ) {
91
+				$map = [ ];
92
+				foreach ( $sorted as $name ) {
93
+					$tokenIndex = array_shift( $used );
94
+					$tokenIndex = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, $tokenIndex + 1, null, true );
95
+					$map[ $tokenIndex ] = $name;
96 96
 				}
97 97
 
98 98
 				$phpcsFile->fixer->beginChangeset();
99 99
 
100
-				foreach ($map as $index => $name) {
101
-					$phpcsFile->fixer->replaceToken($index, $name);
102
-					$endIndex = $phpcsFile->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $index + 1);
103
-					for ($i = $index + 1; $i < $endIndex; $i++) {
104
-						$phpcsFile->fixer->replaceToken($i, '');
100
+				foreach ( $map as $index => $name ) {
101
+					$phpcsFile->fixer->replaceToken( $index, $name );
102
+					$endIndex = $phpcsFile->findNext( [ T_SEMICOLON, T_OPEN_CURLY_BRACKET ], $index + 1 );
103
+					for ( $i = $index + 1; $i < $endIndex; $i++ ) {
104
+						$phpcsFile->fixer->replaceToken( $i, '' );
105 105
 					}
106 106
 				}
107 107
 
@@ -117,30 +117,30 @@  discard block
 block discarded – undo
117 117
 	 * @param int $stackPtr The index of the first use token.
118 118
 	 * @return void
119 119
 	 */
120
-	protected function checkUseToken(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
120
+	protected function checkUseToken( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
121 121
 		// If the use token is for a closure we want to ignore it.
122
-		$isClosure = $this->isClosure($phpcsFile, $stackPtr);
123
-		if ($isClosure) {
122
+		$isClosure = $this->isClosure( $phpcsFile, $stackPtr );
123
+		if ( $isClosure ) {
124 124
 			return;
125 125
 		}
126 126
 
127 127
 		$tokens = $phpcsFile->getTokens();
128 128
 
129 129
 		$content = '';
130
-		$startIndex = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true);
131
-		$endIndex = $phpcsFile->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $startIndex + 1);
130
+		$startIndex = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true );
131
+		$endIndex = $phpcsFile->findNext( [ T_SEMICOLON, T_OPEN_CURLY_BRACKET ], $startIndex + 1 );
132 132
 
133
-		for ($i = $startIndex; $i < $endIndex; $i++) {
134
-			$content .= $tokens[$i]['content'];
133
+		for ( $i = $startIndex; $i < $endIndex; $i++ ) {
134
+			$content .= $tokens[ $i ][ 'content' ];
135 135
 		}
136 136
 
137 137
 		// Check for class scoping on use. Traits should be
138 138
 		// ordered independently.
139 139
 		$scope = 0;
140
-		if (!empty($tokens[$i]['conditions'])) {
141
-			$scope = key($tokens[$i]['conditions']);
140
+		if ( ! empty( $tokens[ $i ][ 'conditions' ] ) ) {
141
+			$scope = key( $tokens[ $i ][ 'conditions' ] );
142 142
 		}
143
-		$this->_uses[$scope][$content] = $stackPtr;
143
+		$this->_uses[ $scope ][ $content ] = $stackPtr;
144 144
 	}
145 145
 
146 146
 	/**
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 	 * @param int $stackPtr
151 151
 	 * @return bool
152 152
 	 */
153
-	protected function isClosure(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
153
+	protected function isClosure( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
154 154
 		return $phpcsFile->findPrevious(
155
-			[T_CLOSURE],
156
-			($stackPtr - 1),
155
+			[ T_CLOSURE ],
156
+			( $stackPtr - 1 ),
157 157
 			null,
158 158
 			false,
159 159
 			null,
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/Namespaces/NamespaceDeclarationSniff.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
 	 * @inheritDoc
35 35
 	 */
36 36
 	public function register() {
37
-		return [T_NAMESPACE];
37
+		return [ T_NAMESPACE ];
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * @inheritDoc
42 42
 	 */
43
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
43
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
44 44
 		$tokens = $phpcsFile->getTokens();
45 45
 
46
-		for ($i = ($stackPtr + 1); $i < ($phpcsFile->numTokens - 1); $i++) {
47
-			if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
46
+		for ( $i = ( $stackPtr + 1 ); $i < ( $phpcsFile->numTokens - 1 ); $i++ ) {
47
+			if ( $tokens[ $i ][ 'line' ] === $tokens[ $stackPtr ][ 'line' ] ) {
48 48
 				continue;
49 49
 			}
50 50
 
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
 
54 54
 		// The $i var now points to the first token on the line after the
55 55
 		// namespace declaration, which must be a blank line.
56
-		$next = $phpcsFile->findNext(T_WHITESPACE, $i, $phpcsFile->numTokens, true);
57
-		if ($next === false) {
56
+		$next = $phpcsFile->findNext( T_WHITESPACE, $i, $phpcsFile->numTokens, true );
57
+		if ( $next === false ) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		$diff = ($tokens[$next]['line'] - $tokens[$i]['line']);
62
-		if ($diff === 1) {
61
+		$diff = ( $tokens[ $next ][ 'line' ] - $tokens[ $i ][ 'line' ] );
62
+		if ( $diff === 1 ) {
63 63
 			return;
64 64
 		}
65 65
 
66
-		if ($diff < 0) {
66
+		if ( $diff < 0 ) {
67 67
 			$diff = 0;
68 68
 		}
69 69
 
70 70
 		$error = 'There must be one blank line after the namespace declaration';
71
-		$fix = $phpcsFile->addFixableError($error, $stackPtr, 'BlankLineAfter');
71
+		$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'BlankLineAfter' );
72 72
 
73
-		if (!$fix) {
73
+		if ( ! $fix ) {
74 74
 			return;
75 75
 		}
76 76
 
77
-		if ($diff === 0) {
78
-			$phpcsFile->fixer->addNewlineBefore($i);
77
+		if ( $diff === 0 ) {
78
+			$phpcsFile->fixer->addNewlineBefore( $i );
79 79
 		} else {
80 80
 			$phpcsFile->fixer->beginChangeset();
81
-			for ($x = $i; $x < $next; $x++) {
82
-				if ($tokens[$x]['line'] === $tokens[$next]['line']) {
81
+			for ( $x = $i; $x < $next; $x++ ) {
82
+				if ( $tokens[ $x ][ 'line' ] === $tokens[ $next ][ 'line' ] ) {
83 83
 					break;
84 84
 				}
85 85
 
86
-				$phpcsFile->fixer->replaceToken($x, '');
86
+				$phpcsFile->fixer->replaceToken( $x, '' );
87 87
 			}
88 88
 
89
-			$phpcsFile->fixer->addNewline($i);
89
+			$phpcsFile->fixer->addNewline( $i );
90 90
 			$phpcsFile->fixer->endChangeset();
91 91
 		}
92 92
 	}
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/Namespaces/UnusedUseStatementSniff.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -18,81 +18,81 @@
 block discarded – undo
18 18
 	 * @inheritDoc
19 19
 	 */
20 20
 	public function register() {
21
-		return [T_USE];
21
+		return [ T_USE ];
22 22
 
23 23
 	}
24 24
 
25 25
 	/**
26 26
 	 * @inheritDoc
27 27
 	 */
28
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
28
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
29 29
 		$tokens = $phpcsFile->getTokens();
30 30
 
31
-		if ($this->shouldIgnoreUse($phpcsFile, $stackPtr)) {
31
+		if ( $this->shouldIgnoreUse( $phpcsFile, $stackPtr ) ) {
32 32
 			return;
33 33
 		}
34 34
 
35
-		$semicolonIndex = $phpcsFile->findEndOfStatement($stackPtr);
36
-		if ($tokens[$semicolonIndex]['code'] !== T_SEMICOLON) {
35
+		$semicolonIndex = $phpcsFile->findEndOfStatement( $stackPtr );
36
+		if ( $tokens[ $semicolonIndex ][ 'code' ] !== T_SEMICOLON ) {
37 37
 			return;
38 38
 		}
39 39
 
40 40
 		$classNameIndex = $phpcsFile->findPrevious(
41 41
 			PHP_CodeSniffer_Tokens::$emptyTokens,
42
-			($semicolonIndex - 1),
42
+			( $semicolonIndex - 1 ),
43 43
 			null,
44 44
 			true
45 45
 		);
46 46
 
47 47
 		// Seek along the statement to get the last part, which is the class/interface name.
48
-		while (isset($tokens[($classNameIndex + 1)]) === true
49
-			&& in_array($tokens[($classNameIndex + 1)]['code'], [T_STRING, T_NS_SEPARATOR])
48
+		while ( isset( $tokens[ ( $classNameIndex + 1 ) ] ) === true
49
+			&& in_array( $tokens[ ( $classNameIndex + 1 ) ][ 'code' ], [ T_STRING, T_NS_SEPARATOR ] )
50 50
 		) {
51 51
 			$classNameIndex++;
52 52
 		}
53 53
 
54
-		if ($tokens[$classNameIndex]['code'] !== T_STRING) {
54
+		if ( $tokens[ $classNameIndex ][ 'code' ] !== T_STRING ) {
55 55
 			return;
56 56
 		}
57 57
 
58
-		$classUsed = $phpcsFile->findNext(T_STRING, ($classNameIndex + 1), null, false, $tokens[$classNameIndex]['content']);
58
+		$classUsed = $phpcsFile->findNext( T_STRING, ( $classNameIndex + 1 ), null, false, $tokens[ $classNameIndex ][ 'content' ] );
59 59
 
60
-		while ($classUsed !== false) {
60
+		while ( $classUsed !== false ) {
61 61
 			$beforeUsage = $phpcsFile->findPrevious(
62 62
 				PHP_CodeSniffer_Tokens::$emptyTokens,
63
-				($classUsed - 1),
63
+				( $classUsed - 1 ),
64 64
 				null,
65 65
 				true
66 66
 			);
67 67
 			// If a backslash is used before the class name then this is some other
68 68
 			// use statement.
69
-			if ($tokens[$beforeUsage]['code'] !== T_USE && $tokens[$beforeUsage]['code'] !== T_NS_SEPARATOR) {
69
+			if ( $tokens[ $beforeUsage ][ 'code' ] !== T_USE && $tokens[ $beforeUsage ][ 'code' ] !== T_NS_SEPARATOR ) {
70 70
 				return;
71 71
 			}
72 72
 
73 73
 			// Trait use statement within a class.
74
-			if ($tokens[$beforeUsage]['code'] === T_USE && !empty($tokens[$beforeUsage]['conditions'])) {
74
+			if ( $tokens[ $beforeUsage ][ 'code' ] === T_USE && ! empty( $tokens[ $beforeUsage ][ 'conditions' ] ) ) {
75 75
 				return;
76 76
 			}
77 77
 
78
-			$classUsed = $phpcsFile->findNext(T_STRING, ($classUsed + 1), null, false, $tokens[$classNameIndex]['content']);
78
+			$classUsed = $phpcsFile->findNext( T_STRING, ( $classUsed + 1 ), null, false, $tokens[ $classNameIndex ][ 'content' ] );
79 79
 		}
80 80
 
81 81
 		$warning = 'Unused use statement';
82
-		$fix = $phpcsFile->addFixableWarning($warning, $stackPtr, 'UnusedUse');
83
-		if (!$fix) {
82
+		$fix = $phpcsFile->addFixableWarning( $warning, $stackPtr, 'UnusedUse' );
83
+		if ( ! $fix ) {
84 84
 			return;
85 85
 		}
86 86
 
87 87
 		$phpcsFile->fixer->beginChangeset();
88
-		for ($i = $stackPtr; $i <= $semicolonIndex; $i++) {
89
-			$phpcsFile->fixer->replaceToken($i, '');
88
+		for ( $i = $stackPtr; $i <= $semicolonIndex; $i++ ) {
89
+			$phpcsFile->fixer->replaceToken( $i, '' );
90 90
 		}
91 91
 
92 92
 		// Also remove whitespace after the semicolon (new lines).
93
-		while (!empty($tokens[$i]) && $tokens[$i]['code'] === T_WHITESPACE) {
94
-			$phpcsFile->fixer->replaceToken($i, '');
95
-			if (strpos($tokens[$i]['content'], $phpcsFile->eolChar) !== false) {
93
+		while ( ! empty( $tokens[ $i ] ) && $tokens[ $i ][ 'code' ] === T_WHITESPACE ) {
94
+			$phpcsFile->fixer->replaceToken( $i, '' );
95
+			if ( strpos( $tokens[ $i ][ 'content' ], $phpcsFile->eolChar ) !== false ) {
96 96
 				break;
97 97
 			}
98 98
 
Please login to merge, or discard this patch.
vendor/fig-r/psr2r-sniffer/PSR2R/Sniffs/Namespaces/UseDeclarationSniff.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -40,107 +40,107 @@
 block discarded – undo
40 40
 	 * @inheritDoc
41 41
 	 */
42 42
 	public function register() {
43
-		return [T_USE];
43
+		return [ T_USE ];
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @inheritDoc
48 48
 	 */
49
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
50
-		if ($this->shouldIgnoreUse($phpcsFile, $stackPtr) === true) {
49
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
50
+		if ( $this->shouldIgnoreUse( $phpcsFile, $stackPtr ) === true ) {
51 51
 			return;
52 52
 		}
53 53
 
54 54
 		$tokens = $phpcsFile->getTokens();
55 55
 
56 56
 		// One space after the use keyword.
57
-		if ($tokens[($stackPtr + 1)]['content'] !== ' ') {
57
+		if ( $tokens[ ( $stackPtr + 1 ) ][ 'content' ] !== ' ' ) {
58 58
 			$error = 'There must be a single space after the USE keyword';
59
-			$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterUse');
60
-			if ($fix === true) {
61
-				$phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
59
+			$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpaceAfterUse' );
60
+			if ( $fix === true ) {
61
+				$phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), ' ' );
62 62
 			}
63 63
 		}
64 64
 
65 65
 		// Namespaces in use statements must not have a leading separator
66
-		$next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
67
-		if ($tokens[$next]['code'] === T_NS_SEPARATOR) {
66
+		$next = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
67
+		if ( $tokens[ $next ][ 'code' ] === T_NS_SEPARATOR ) {
68 68
 			$error = 'Namespaces in use statements should not start with a namespace separator';
69
-			$fix = $phpcsFile->addFixableError($error, $next, 'NamespaceStart');
70
-			if ($fix) {
71
-				$phpcsFile->fixer->replaceToken($next, '');
69
+			$fix = $phpcsFile->addFixableError( $error, $next, 'NamespaceStart' );
70
+			if ( $fix ) {
71
+				$phpcsFile->fixer->replaceToken( $next, '' );
72 72
 			}
73 73
 		}
74 74
 
75 75
 		// Only one USE declaration allowed per statement.
76
-		$next = $phpcsFile->findNext([T_COMMA, T_SEMICOLON], ($stackPtr + 1));
77
-		if ($tokens[$next]['code'] === T_COMMA) {
76
+		$next = $phpcsFile->findNext( [ T_COMMA, T_SEMICOLON ], ( $stackPtr + 1 ) );
77
+		if ( $tokens[ $next ][ 'code' ] === T_COMMA ) {
78 78
 			$error = 'There must be one USE keyword per declaration';
79
-			$fix = $phpcsFile->addFixableError($error, $stackPtr, 'MultipleDeclarations');
80
-			if ($fix === true) {
81
-				$phpcsFile->fixer->replaceToken($next, ';' . $phpcsFile->eolChar . 'use ');
79
+			$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'MultipleDeclarations' );
80
+			if ( $fix === true ) {
81
+				$phpcsFile->fixer->replaceToken( $next, ';' . $phpcsFile->eolChar . 'use ' );
82 82
 			}
83 83
 		} else {
84
-			$nextUse = $phpcsFile->findNext(T_USE, $next + 1);
85
-			if ($nextUse && !$this->shouldIgnoreUse($phpcsFile, $nextUse)) {
86
-				if ($tokens[$nextUse]['line'] > $tokens[$next]['line'] + 1) {
84
+			$nextUse = $phpcsFile->findNext( T_USE, $next + 1 );
85
+			if ( $nextUse && ! $this->shouldIgnoreUse( $phpcsFile, $nextUse ) ) {
86
+				if ( $tokens[ $nextUse ][ 'line' ] > $tokens[ $next ][ 'line' ] + 1 ) {
87 87
 					$error = 'There should not be newlines between use statements';
88
-					$fix = $phpcsFile->addFixableError($error, $nextUse, 'NewlineBetweenUse');
89
-					if ($fix) {
90
-						$phpcsFile->fixer->replaceToken($nextUse - 1, '');
88
+					$fix = $phpcsFile->addFixableError( $error, $nextUse, 'NewlineBetweenUse' );
89
+					if ( $fix ) {
90
+						$phpcsFile->fixer->replaceToken( $nextUse - 1, '' );
91 91
 					}
92 92
 				}
93 93
 			}
94 94
 		}
95 95
 
96 96
 		// Make sure this USE comes after the first namespace declaration.
97
-		$prev = $phpcsFile->findPrevious(T_NAMESPACE, ($stackPtr - 1));
98
-		if ($prev !== false) {
99
-			$first = $phpcsFile->findNext(T_NAMESPACE, 1);
100
-			if ($prev !== $first) {
97
+		$prev = $phpcsFile->findPrevious( T_NAMESPACE, ( $stackPtr - 1 ) );
98
+		if ( $prev !== false ) {
99
+			$first = $phpcsFile->findNext( T_NAMESPACE, 1 );
100
+			if ( $prev !== $first ) {
101 101
 				$error = 'USE declarations must go after the first namespace declaration';
102
-				$phpcsFile->addError($error, $stackPtr, 'UseAfterNamespace');
102
+				$phpcsFile->addError( $error, $stackPtr, 'UseAfterNamespace' );
103 103
 			}
104 104
 		}
105 105
 
106 106
 		// Only interested in the last USE statement from here onwards.
107
-		$nextUse = $phpcsFile->findNext(T_USE, ($stackPtr + 1));
108
-		while ($this->shouldIgnoreUse($phpcsFile, $nextUse)) {
109
-			$nextUse = $phpcsFile->findNext(T_USE, ($nextUse + 1));
110
-			if ($nextUse === false) {
107
+		$nextUse = $phpcsFile->findNext( T_USE, ( $stackPtr + 1 ) );
108
+		while ( $this->shouldIgnoreUse( $phpcsFile, $nextUse ) ) {
109
+			$nextUse = $phpcsFile->findNext( T_USE, ( $nextUse + 1 ) );
110
+			if ( $nextUse === false ) {
111 111
 				break;
112 112
 			}
113 113
 		}
114 114
 
115
-		if ($nextUse !== false) {
115
+		if ( $nextUse !== false ) {
116 116
 			return;
117 117
 		}
118 118
 
119
-		$end = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1));
120
-		$next = $phpcsFile->findNext(T_WHITESPACE, ($end + 1), null, true);
121
-		$diff = ($tokens[$next]['line'] - $tokens[$end]['line'] - 1);
122
-		if ($diff !== 1) {
123
-			if ($diff < 0) {
119
+		$end = $phpcsFile->findNext( T_SEMICOLON, ( $stackPtr + 1 ) );
120
+		$next = $phpcsFile->findNext( T_WHITESPACE, ( $end + 1 ), null, true );
121
+		$diff = ( $tokens[ $next ][ 'line' ] - $tokens[ $end ][ 'line' ] - 1 );
122
+		if ( $diff !== 1 ) {
123
+			if ( $diff < 0 ) {
124 124
 				$diff = 0;
125 125
 			}
126 126
 
127 127
 			$error = 'There must be one blank line after the last USE statement; %s found;';
128
-			$data = [$diff];
129
-			$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterLastUse', $data);
130
-			if ($fix === true) {
131
-				if ($diff === 0) {
132
-					$phpcsFile->fixer->addNewline($end);
128
+			$data = [ $diff ];
129
+			$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpaceAfterLastUse', $data );
130
+			if ( $fix === true ) {
131
+				if ( $diff === 0 ) {
132
+					$phpcsFile->fixer->addNewline( $end );
133 133
 				} else {
134 134
 					$phpcsFile->fixer->beginChangeset();
135
-					for ($i = ($end + 1); $i < $next; $i++) {
136
-						if ($tokens[$i]['line'] === $tokens[$next]['line']) {
135
+					for ( $i = ( $end + 1 ); $i < $next; $i++ ) {
136
+						if ( $tokens[ $i ][ 'line' ] === $tokens[ $next ][ 'line' ] ) {
137 137
 							break;
138 138
 						}
139 139
 
140
-						$phpcsFile->fixer->replaceToken($i, '');
140
+						$phpcsFile->fixer->replaceToken( $i, '' );
141 141
 					}
142 142
 
143
-					$phpcsFile->fixer->addNewline($end);
143
+					$phpcsFile->fixer->addNewline( $end );
144 144
 					$phpcsFile->fixer->endChangeset();
145 145
 				}
146 146
 			}
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/WhiteSpace/ConcatenationSpacingSniff.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -30,47 +30,47 @@  discard block
 block discarded – undo
30 30
 	 * @inheritDoc
31 31
 	 */
32 32
 	public function register() {
33
-		return [T_STRING_CONCAT];
33
+		return [ T_STRING_CONCAT ];
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * @inheritDoc
38 38
 	 */
39
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
39
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
40 40
 		$tokens = $phpcsFile->getTokens();
41 41
 
42
-		$prevIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
42
+		$prevIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
43 43
 
44
-		if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
44
+		if ( $tokens[ ( $stackPtr - 1 ) ][ 'code' ] !== T_WHITESPACE ) {
45 45
 			$message = 'Expected 1 space before ., but 0 found';
46
-			$phpcsFile->addFixableError($message, $stackPtr, 'MissingBefore');
47
-			$this->addSpace($phpcsFile, $stackPtr - 1);
46
+			$phpcsFile->addFixableError( $message, $stackPtr, 'MissingBefore' );
47
+			$this->addSpace( $phpcsFile, $stackPtr - 1 );
48 48
 		} else {
49
-			$content = $tokens[$stackPtr - 1]['content'];
50
-			if ($tokens[$prevIndex]['line'] === $tokens[$stackPtr]['line'] && $content !== ' ') {
49
+			$content = $tokens[ $stackPtr - 1 ][ 'content' ];
50
+			if ( $tokens[ $prevIndex ][ 'line' ] === $tokens[ $stackPtr ][ 'line' ] && $content !== ' ' ) {
51 51
 				$message = 'Expected 1 space before `.`, but %d found';
52
-				$data = [strlen($content)];
53
-				$fix = $phpcsFile->addFixableError($message, $stackPtr, 'TooManyBefore', $data);
54
-				if ($fix) {
55
-					$phpcsFile->fixer->replaceToken($stackPtr - 1, ' ');
52
+				$data = [ strlen( $content ) ];
53
+				$fix = $phpcsFile->addFixableError( $message, $stackPtr, 'TooManyBefore', $data );
54
+				if ( $fix ) {
55
+					$phpcsFile->fixer->replaceToken( $stackPtr - 1, ' ' );
56 56
 				}
57 57
 			}
58 58
 		}
59 59
 
60
-		$nextIndex = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
60
+		$nextIndex = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
61 61
 
62
-		if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
62
+		if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
63 63
 			$message = 'Expected 1 space after ., but 0 found';
64
-			$phpcsFile->addFixableError($message, $stackPtr, 'MissingAfter');
65
-			$this->addSpace($phpcsFile, $stackPtr);
64
+			$phpcsFile->addFixableError( $message, $stackPtr, 'MissingAfter' );
65
+			$this->addSpace( $phpcsFile, $stackPtr );
66 66
 		} else {
67
-			$content = $tokens[($stackPtr + 1)]['content'];
68
-			if ($tokens[$nextIndex]['line'] === $tokens[$stackPtr]['line'] && $content !== ' ') {
67
+			$content = $tokens[ ( $stackPtr + 1 ) ][ 'content' ];
68
+			if ( $tokens[ $nextIndex ][ 'line' ] === $tokens[ $stackPtr ][ 'line' ] && $content !== ' ' ) {
69 69
 				$message = 'Expected 1 space after `.`, but %d found';
70
-				$data = [strlen($content)];
71
-				$fix = $phpcsFile->addFixableError($message, $stackPtr, 'TooManyAfter', $data);
72
-				if ($fix) {
73
-					$phpcsFile->fixer->replaceToken($stackPtr + 1, ' ');
70
+				$data = [ strlen( $content ) ];
71
+				$fix = $phpcsFile->addFixableError( $message, $stackPtr, 'TooManyAfter', $data );
72
+				if ( $fix ) {
73
+					$phpcsFile->fixer->replaceToken( $stackPtr + 1, ' ' );
74 74
 				}
75 75
 			}
76 76
 		}
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return void
86 86
 	 */
87
-	protected function addSpace(PHP_CodeSniffer_File $phpcsFile, $index) {
88
-		if ($phpcsFile->fixer->enabled !== true) {
87
+	protected function addSpace( PHP_CodeSniffer_File $phpcsFile, $index ) {
88
+		if ( $phpcsFile->fixer->enabled !== true ) {
89 89
 			return;
90 90
 		}
91
-		$phpcsFile->fixer->addContent($index, ' ');
91
+		$phpcsFile->fixer->addContent( $index, ' ' );
92 92
 	}
93 93
 
94 94
 }
Please login to merge, or discard this patch.
vendor/fig-r/psr2r-sniffer/PSR2R/Sniffs/WhiteSpace/EmptyLinesSniff.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,26 +21,26 @@
 block discarded – undo
21 21
 	 * @inheritDoc
22 22
 	 */
23 23
 	public function register() {
24
-		return [T_WHITESPACE];
24
+		return [ T_WHITESPACE ];
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * @inheritDoc
29 29
 	 */
30
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
30
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
31 31
 		$tokens = $phpcsFile->getTokens();
32
-		if ($tokens[$stackPtr]['content'] === $phpcsFile->eolChar
33
-			&& isset($tokens[($stackPtr + 1)]) === true
34
-			&& $tokens[($stackPtr + 1)]['content'] === $phpcsFile->eolChar
35
-			&& isset($tokens[($stackPtr + 2)]) === true
36
-			&& $tokens[($stackPtr + 2)]['content'] === $phpcsFile->eolChar
37
-			&& isset($tokens[($stackPtr + 3)]) === true
38
-			&& $tokens[($stackPtr + 3)]['content'] === $phpcsFile->eolChar
32
+		if ( $tokens[ $stackPtr ][ 'content' ] === $phpcsFile->eolChar
33
+			&& isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
34
+			&& $tokens[ ( $stackPtr + 1 ) ][ 'content' ] === $phpcsFile->eolChar
35
+			&& isset( $tokens[ ( $stackPtr + 2 ) ] ) === true
36
+			&& $tokens[ ( $stackPtr + 2 ) ][ 'content' ] === $phpcsFile->eolChar
37
+			&& isset( $tokens[ ( $stackPtr + 3 ) ] ) === true
38
+			&& $tokens[ ( $stackPtr + 3 ) ][ 'content' ] === $phpcsFile->eolChar
39 39
 		) {
40 40
 			$error = '2 empty lines and more are not allowed';
41
-			$fix = $phpcsFile->addFixableError($error, ($stackPtr + 3), 'EmptyLines');
42
-			if ($fix) {
43
-				$phpcsFile->fixer->replaceToken($stackPtr + 3, '');
41
+			$fix = $phpcsFile->addFixableError( $error, ( $stackPtr + 3 ), 'EmptyLines' );
42
+			if ( $fix ) {
43
+				$phpcsFile->fixer->replaceToken( $stackPtr + 3, '' );
44 44
 			}
45 45
 		}
46 46
 	}
Please login to merge, or discard this patch.
vendor/fig-r/psr2r-sniffer/PSR2R/Sniffs/WhiteSpace/TabAndSpaceSniff.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -40,39 +40,39 @@
 block discarded – undo
40 40
 	 * @inheritDoc
41 41
 	 */
42 42
 	public function register() {
43
-		return [T_WHITESPACE];
43
+		return [ T_WHITESPACE ];
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @inheritDoc
48 48
 	 */
49
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
49
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
50 50
 		$tokens = $phpcsFile->getTokens();
51 51
 
52
-		$line = $tokens[$stackPtr]['line'];
53
-		if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] !== $line) {
52
+		$line = $tokens[ $stackPtr ][ 'line' ];
53
+		if ( $stackPtr > 0 && $tokens[ ( $stackPtr - 1 ) ][ 'line' ] !== $line ) {
54 54
 			return;
55 55
 		}
56 56
 
57
-		if (strpos($tokens[$stackPtr]['content'], '  ') !== false) {
57
+		if ( strpos( $tokens[ $stackPtr ][ 'content' ], '  ' ) !== false ) {
58 58
 			$error = 'Double space found';
59
-			$fix = $phpcsFile->addFixableError($error, $stackPtr);
60
-			if ($fix) {
61
-				$phpcsFile->fixer->replaceToken($stackPtr, ' ');
59
+			$fix = $phpcsFile->addFixableError( $error, $stackPtr );
60
+			if ( $fix ) {
61
+				$phpcsFile->fixer->replaceToken( $stackPtr, ' ' );
62 62
 			}
63 63
 		}
64
-		if (strpos($tokens[$stackPtr]['content'], " \t") !== false) {
64
+		if ( strpos( $tokens[ $stackPtr ][ 'content' ], " \t" ) !== false ) {
65 65
 			$error = 'Space and tab found';
66
-			$fix = $phpcsFile->addFixableError($error, $stackPtr);
67
-			if ($fix) {
68
-				$phpcsFile->fixer->replaceToken($stackPtr, ' ');
66
+			$fix = $phpcsFile->addFixableError( $error, $stackPtr );
67
+			if ( $fix ) {
68
+				$phpcsFile->fixer->replaceToken( $stackPtr, ' ' );
69 69
 			}
70 70
 		}
71
-		if (strpos($tokens[$stackPtr]['content'], "\t ") !== false) {
71
+		if ( strpos( $tokens[ $stackPtr ][ 'content' ], "\t " ) !== false ) {
72 72
 			$error = 'Tab and space found';
73
-			$fix = $phpcsFile->addFixableError($error, $stackPtr);
74
-			if ($fix) {
75
-				$phpcsFile->fixer->replaceToken($stackPtr, ' ');
73
+			$fix = $phpcsFile->addFixableError( $error, $stackPtr );
74
+			if ( $fix ) {
75
+				$phpcsFile->fixer->replaceToken( $stackPtr, ' ' );
76 76
 			}
77 77
 		}
78 78
 	}
Please login to merge, or discard this patch.