@@ -48,8 +48,7 @@ public function register()
48
48
* Processes this sniff, when one of its tokens is encountered.
49
49
*
50
50
* @param File $phpcsFile The current file being checked.
51
- * @param int $stackPtr The position of the current token in
52
- * the stack passed in $tokens.
51
+ * @param int $stackPtr The position of the current token in the stack passed in $tokens.
53
52
*
54
53
* @return void
55
54
*/
@@ -123,8 +122,8 @@ public function process(File $phpcsFile, $stackPtr)
123
122
}
124
123
}
125
124
126
- // We can return here because there is nothing else to check. All code
127
- // below can assume that the array is not empty.
125
+ // We can return here because there is nothing else to check.
126
+ // All code below can assume that the array is not empty.
128
127
return ;
129
128
}
130
129
@@ -139,8 +138,7 @@ public function process(File $phpcsFile, $stackPtr)
139
138
* Processes a single-line array definition.
140
139
*
141
140
* @param File $phpcsFile The current file being checked.
142
- * @param int $stackPtr The position of the current token
143
- * in the stack passed in $tokens.
141
+ * @param int $stackPtr The position of the current token in the stack passed in $tokens.
144
142
* @param int $arrayStart The token that starts the array definition.
145
143
* @param int $arrayEnd The token that ends the array definition.
146
144
*
@@ -162,8 +160,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
162
160
}
163
161
164
162
if (T_COMMA === $ tokens [$ i ]['code ' ]) {
165
- // Before counting this comma, make sure we are not
166
- // at the end of the array.
163
+ // Before counting this comma, make sure we are not at the end of the array.
167
164
$ next = $ phpcsFile ->findNext (T_WHITESPACE , ($ i + 1 ), $ arrayEnd , true );
168
165
if (false !== $ next ) {
169
166
$ valueCount ++;
@@ -195,10 +192,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
195
192
if (1 !== $ spaceLength ) {
196
193
$ content = $ tokens [($ nextArrow - 2 )]['content ' ];
197
194
$ error = 'Expected 1 space between "%s" and double arrow; %s found ' ;
198
- $ data = array (
199
- $ content ,
200
- $ spaceLength ,
201
- );
195
+ $ data = array ($ content , $ spaceLength );
202
196
203
197
$ fix = $ phpcsFile ->addFixableError ($ error , $ nextArrow , 'SpaceBeforeDoubleArrow ' , $ data );
204
198
if (true === $ fix ) {
@@ -221,10 +215,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
221
215
if (1 !== $ spaceLength ) {
222
216
$ content = $ tokens [($ nextArrow + 2 )]['content ' ];
223
217
$ error = 'Expected 1 space between double arrow and "%s"; %s found ' ;
224
- $ data = array (
225
- $ content ,
226
- $ spaceLength ,
227
- );
218
+ $ data = array ($ content , $ spaceLength );
228
219
229
220
$ fix = $ phpcsFile ->addFixableError ($ error , $ nextArrow , 'SpaceAfterDoubleArrow ' , $ data );
230
221
if (true === $ fix ) {
@@ -251,10 +242,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
251
242
if (1 !== $ spaceLength ) {
252
243
$ content = $ tokens [($ comma + 2 )]['content ' ];
253
244
$ error = 'Expected 1 space between comma and "%s"; %s found ' ;
254
- $ data = [
255
- $ content ,
256
- $ spaceLength ,
257
- ];
245
+ $ data = [$ content , $ spaceLength ];
258
246
259
247
$ fix = $ phpcsFile ->addFixableError ($ error , $ comma , 'SpaceAfterComma ' , $ data );
260
248
if (true === $ fix ) {
@@ -267,10 +255,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
267
255
$ content = $ tokens [($ comma - 2 )]['content ' ];
268
256
$ spaceLength = $ tokens [($ comma - 1 )]['length ' ];
269
257
$ error = 'Expected 0 spaces between "%s" and comma; %s found ' ;
270
- $ data = [
271
- $ content ,
272
- $ spaceLength ,
273
- ];
258
+ $ data = [$ content , $ spaceLength ];
274
259
275
260
$ fix = $ phpcsFile ->addFixableError ($ error , $ comma , 'SpaceBeforeComma ' , $ data );
276
261
if (true === $ fix ) {
@@ -285,16 +270,15 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
285
270
* Processes a multi-line array definition.
286
271
*
287
272
* @param File $phpcsFile The current file being checked.
288
- * @param int $stackPtr The position of the current token
289
- * in the stack passed in $tokens.
273
+ * @param int $stackPtr The position of the current token in the stack passed in $tokens.
290
274
* @param int $arrayStart The token that starts the array definition.
291
275
* @param int $arrayEnd The token that ends the array definition.
292
276
*
293
277
* @return void
294
278
*/
295
279
public function processMultiLineArray (File $ phpcsFile , $ stackPtr , $ arrayStart , $ arrayEnd )
296
280
{
297
- $ tokens = $ phpcsFile ->getTokens ();
281
+ $ tokens = $ phpcsFile ->getTokens ();
298
282
299
283
$ indent = $ phpcsFile ->findFirstOnLine (T_WHITESPACE , $ arrayStart );
300
284
if (false === $ indent ) {
@@ -316,10 +300,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
316
300
$ expected = ($ currentIndent );
317
301
$ found = ($ tokens [$ arrayEnd ]['column ' ] - 1 );
318
302
$ error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s ' ;
319
- $ data = array (
320
- $ expected ,
321
- $ found ,
322
- );
303
+ $ data = array ($ expected , $ found );
323
304
324
305
$ fix = $ phpcsFile ->addFixableError ($ error , $ arrayEnd , 'CloseBraceNotAligned ' , $ data );
325
306
if (true === $ fix ) {
@@ -559,10 +540,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
559
540
$ found = ($ tokens [$ first ]['column ' ] - 1 );
560
541
if ($ found !== $ expected ) {
561
542
$ error = 'Array value not aligned correctly; expected %s spaces but found %s ' ;
562
- $ data = array (
563
- $ expected ,
564
- $ found ,
565
- );
543
+ $ data = array ($ expected , $ found );
566
544
567
545
$ fix = $ phpcsFile ->addFixableError ($ error , $ value ['value ' ], 'ValueNotAligned ' , $ data );
568
546
if (true === $ fix ) {
@@ -658,10 +636,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
658
636
$ expected = ($ indicesStart - 1 );
659
637
$ found = ($ tokens [$ index ['index ' ]]['column ' ] - 1 );
660
638
$ error = 'Array key not aligned correctly; expected %s spaces but found %s ' ;
661
- $ data = array (
662
- $ expected ,
663
- $ found ,
664
- );
639
+ $ data = array ($ expected , $ found );
665
640
666
641
$ fix = $ phpcsFile ->addFixableError ($ error , $ index ['index ' ], 'KeyNotAligned ' , $ data );
667
642
@@ -686,10 +661,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
686
661
}
687
662
688
663
$ error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s ' ;
689
- $ data = array (
690
- $ expected ,
691
- $ found ,
692
- );
664
+ $ data = array ($ expected , $ found );
693
665
694
666
if ('newline ' !== $ found || false === $ this ->ignoreNewLines ) {
695
667
$ fix = $ phpcsFile ->addFixableError ($ error , $ index ['arrow ' ], 'DoubleArrowNotAligned ' , $ data );
@@ -814,10 +786,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
814
786
$ content = $ tokens [($ nextComma - 2 )]['content ' ];
815
787
$ spaceLength = $ tokens [($ nextComma - 1 )]['length ' ];
816
788
$ error = 'Expected 0 spaces between "%s" and comma; %s found ' ;
817
- $ data = array (
818
- $ content ,
819
- $ spaceLength ,
820
- );
789
+ $ data = array ($ content , $ spaceLength );
821
790
822
791
$ fix = $ phpcsFile ->addFixableError ($ error , $ nextComma , 'SpaceBeforeComma ' , $ data );
823
792
if (true === $ fix ) {
0 commit comments