@@ -38,10 +38,10 @@ class ArrayDeclarationSniff implements Sniff
3838 */
3939 public function register ()
4040 {
41- return array (
41+ return [
4242 T_ARRAY ,
4343 T_OPEN_SHORT_ARRAY ,
44- ) ;
44+ ] ;
4545 }
4646
4747 /**
@@ -151,7 +151,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
151151 // Check if there are multiple values. If so, then it has to be multiple lines
152152 // unless it is contained inside a function call or condition.
153153 $ valueCount = 0 ;
154- $ commas = array () ;
154+ $ commas = [] ;
155155 for ($ i = ($ arrayStart + 1 ); $ i < $ arrayEnd ; $ i ++) {
156156 // Skip bracketed statements, like function calls.
157157 if (T_OPEN_PARENTHESIS === $ tokens [$ i ]['code ' ]) {
@@ -182,7 +182,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
182182 if (T_WHITESPACE !== $ tokens [($ nextArrow - 1 )]['code ' ]) {
183183 $ content = $ tokens [($ nextArrow - 1 )]['content ' ];
184184 $ error = 'Expected 1 space between "%s" and double arrow; 0 found ' ;
185- $ data = array ( $ content) ;
185+ $ data = [ $ content] ;
186186 $ fix = $ phpcsFile ->addFixableError ($ error , $ nextArrow , 'NoSpaceBeforeDoubleArrow ' , $ data );
187187 if (true === $ fix ) {
188188 $ phpcsFile ->fixer ->addContentBefore ($ nextArrow , ' ' );
@@ -192,7 +192,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
192192 if (1 !== $ spaceLength ) {
193193 $ content = $ tokens [($ nextArrow - 2 )]['content ' ];
194194 $ error = 'Expected 1 space between "%s" and double arrow; %s found ' ;
195- $ data = array ( $ content , $ spaceLength) ;
195+ $ data = [ $ content , $ spaceLength] ;
196196
197197 $ fix = $ phpcsFile ->addFixableError ($ error , $ nextArrow , 'SpaceBeforeDoubleArrow ' , $ data );
198198 if (true === $ fix ) {
@@ -204,7 +204,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
204204 if (T_WHITESPACE !== $ tokens [($ nextArrow + 1 )]['code ' ]) {
205205 $ content = $ tokens [($ nextArrow + 1 )]['content ' ];
206206 $ error = 'Expected 1 space between double arrow and "%s"; 0 found ' ;
207- $ data = array ( $ content) ;
207+ $ data = [ $ content] ;
208208
209209 $ fix = $ phpcsFile ->addFixableError ($ error , $ nextArrow , 'NoSpaceAfterDoubleArrow ' , $ data );
210210 if (true === $ fix ) {
@@ -215,7 +215,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
215215 if (1 !== $ spaceLength ) {
216216 $ content = $ tokens [($ nextArrow + 2 )]['content ' ];
217217 $ error = 'Expected 1 space between double arrow and "%s"; %s found ' ;
218- $ data = array ( $ content , $ spaceLength) ;
218+ $ data = [ $ content , $ spaceLength] ;
219219
220220 $ fix = $ phpcsFile ->addFixableError ($ error , $ nextArrow , 'SpaceAfterDoubleArrow ' , $ data );
221221 if (true === $ fix ) {
@@ -300,7 +300,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
300300 $ expected = ($ currentIndent );
301301 $ found = ($ tokens [$ arrayEnd ]['column ' ] - 1 );
302302 $ error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s ' ;
303- $ data = array ( $ expected , $ found) ;
303+ $ data = [ $ expected , $ found] ;
304304
305305 $ fix = $ phpcsFile ->addFixableError ($ error , $ arrayEnd , 'CloseBraceNotAligned ' , $ data );
306306 if (true === $ fix ) {
@@ -314,7 +314,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
314314
315315 $ keyUsed = false ;
316316 $ singleUsed = false ;
317- $ indices = array () ;
317+ $ indices = [] ;
318318 $ maxLength = 0 ;
319319
320320 if (T_ARRAY === $ tokens [$ stackPtr ]['code ' ]) {
@@ -340,7 +340,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
340340 ) {
341341 // Let subsequent calls of this test handle nested arrays.
342342 if (T_DOUBLE_ARROW !== $ tokens [$ lastToken ]['code ' ]) {
343- $ indices [] = array ( 'value ' => $ nextToken) ;
343+ $ indices [] = [ 'value ' => $ nextToken] ;
344344 $ lastToken = $ nextToken ;
345345 }
346346
@@ -369,7 +369,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
369369 continue ;
370370 }
371371
372- $ currentEntry = array () ;
372+ $ currentEntry = [] ;
373373
374374 if (T_COMMA === $ tokens [$ nextToken ]['code ' ]) {
375375 $ stackPtrCount = 0 ;
@@ -410,10 +410,10 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
410410 }
411411
412412 $ error = 'Expected 0 spaces between "%s" and comma; %s found ' ;
413- $ data = array (
413+ $ data = [
414414 $ content ,
415415 $ spaceLength ,
416- ) ;
416+ ] ;
417417
418418 $ fix = $ phpcsFile ->addFixableError ($ error , $ nextToken , 'SpaceBeforeComma ' , $ data );
419419 if (true === $ fix ) {
@@ -428,7 +428,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
428428 true
429429 );
430430
431- $ indices [] = array ( 'value ' => $ valueContent) ;
431+ $ indices [] = [ 'value ' => $ valueContent] ;
432432 $ singleUsed = true ;
433433 }
434434
@@ -540,7 +540,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
540540 $ found = ($ tokens [$ first ]['column ' ] - 1 );
541541 if ($ found !== $ expected ) {
542542 $ error = 'Array value not aligned correctly; expected %s spaces but found %s ' ;
543- $ data = array ( $ expected , $ found) ;
543+ $ data = [ $ expected , $ found] ;
544544
545545 $ fix = $ phpcsFile ->addFixableError ($ error , $ value ['value ' ], 'ValueNotAligned ' , $ data );
546546 if (true === $ fix ) {
@@ -636,7 +636,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
636636 $ expected = ($ indicesStart - 1 );
637637 $ found = ($ tokens [$ index ['index ' ]]['column ' ] - 1 );
638638 $ error = 'Array key not aligned correctly; expected %s spaces but found %s ' ;
639- $ data = array ( $ expected , $ found) ;
639+ $ data = [ $ expected , $ found] ;
640640
641641 $ fix = $ phpcsFile ->addFixableError ($ error , $ index ['index ' ], 'KeyNotAligned ' , $ data );
642642
@@ -661,7 +661,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
661661 }
662662
663663 $ error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s ' ;
664- $ data = array ( $ expected , $ found) ;
664+ $ data = [ $ expected , $ found] ;
665665
666666 if ('newline ' !== $ found || false === $ this ->ignoreNewLines ) {
667667 $ fix = $ phpcsFile ->addFixableError ($ error , $ index ['arrow ' ], 'DoubleArrowNotAligned ' , $ data );
@@ -786,7 +786,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
786786 $ content = $ tokens [($ nextComma - 2 )]['content ' ];
787787 $ spaceLength = $ tokens [($ nextComma - 1 )]['length ' ];
788788 $ error = 'Expected 0 spaces between "%s" and comma; %s found ' ;
789- $ data = array ( $ content , $ spaceLength) ;
789+ $ data = [ $ content , $ spaceLength] ;
790790
791791 $ fix = $ phpcsFile ->addFixableError ($ error , $ nextComma , 'SpaceBeforeComma ' , $ data );
792792 if (true === $ fix ) {
0 commit comments