@@ -301,6 +301,8 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra
301301 * @param int $stackPtr The position of the current token
302302 * in the stack passed in $tokens.
303303 *
304+ * @todo This is 'brute force' at the moment and ought to be refactored.
305+ *
304306 * @return int|false
305307 */
306308 public function arrayDeclaredAt ($ phpcsFile , $ stackPtr )
@@ -319,6 +321,7 @@ public function arrayDeclaredAt($phpcsFile, $stackPtr)
319321 T_ARRAY_CAST => true ,
320322 T_UNSET_CAST => true ,
321323 T_OBJECT_CAST => true ,
324+ T_STATIC => true ,
322325 );
323326
324327 $ before1 = $ phpcsFile ->findPrevious (T_WHITESPACE , ($ stackPtr - 1 ), null , true );
@@ -332,19 +335,29 @@ public function arrayDeclaredAt($phpcsFile, $stackPtr)
332335 // Does it have visibility scope or a type hint?
333336 // - 'private $arr = [];'
334337 // - '(array) $arr = [];'.
338+ // - 'private static $arr = [];'.
335339 $ before2 = $ phpcsFile ->findPrevious (T_WHITESPACE , ($ before1 - 1 ), null , true );
336340 if ($ before2 !== false && isset ($ preTokens [$ tokens [$ before2 ]['code ' ]]) === true ) {
337341 // It is preceded with scope or type.
338342 $ indentStart = $ before2 ;
343+
344+ // Could still need to go back one level if it's static.
345+ // - 'private static $arr = [];'.
346+ $ before3 = $ phpcsFile ->findPrevious (T_WHITESPACE , ($ before2 - 1 ), null , true );
347+ if ($ before3 !== false && isset ($ preTokens [$ tokens [$ before3 ]['code ' ]]) === true ) {
348+ // It is preceded with scope or type.
349+ $ indentStart = $ before3 ;
350+ }
339351 }
340- }
352+ }//end if
341353
342354 // Is it a string?, if so expect object or constant.
343355 // - '$obj->arr = [];'.
344356 // - 'MY_CONST = [];'
345357 // - 'const MY_CONST = [];.
346358 if ($ tokens [$ before1 ]['code ' ] === T_STRING ) {
347359 $ before2 = $ phpcsFile ->findPrevious (T_WHITESPACE , ($ before1 - 1 ), null , true );
360+
348361 // Is it a constant?
349362 if ($ tokens [$ before2 ]['code ' ] === T_CONST ) {
350363 $ indentStart = $ before2 ;
0 commit comments