private function fixArray(Tokens $tokens, &$index)
 {
     $bracesLevel = 0;
     // Skip only when its an array, for short arrays we need the brace for correct
     // level counting
     if ($tokens[$index]->isGivenKind(T_ARRAY)) {
         ++$index;
     }
     $multiline = $tokens->isArrayMultiLine($index);
     for ($c = $tokens->count(); $index < $c; ++$index) {
         $token = $tokens[$index];
         if ('(' === $token->content || '[' === $token->content) {
             ++$bracesLevel;
             continue;
         }
         if ($token->isGivenKind(T_ARRAY) || $tokens->isShortArray($index)) {
             $this->fixArray($tokens, $index);
             continue;
         }
         if (')' === $token->content || ']' === $token->content) {
             --$bracesLevel;
             $foundIndex = null;
             if (!$multiline && 0 === $bracesLevel && ',' === $tokens->getPrevNonWhitespace($index, array(), $foundIndex)->content) {
                 $tokens->removeTrailingWhitespace($foundIndex);
                 $tokens[$foundIndex]->clear();
             }
             if (0 === $bracesLevel) {
                 break;
             }
         }
     }
 }
 private function fixArray(Tokens $tokens, $index)
 {
     $bracesLevel = 0;
     $startIndex = $index;
     if ($tokens[$index]->isGivenKind(T_ARRAY)) {
         $tokens->getNextTokenOfKind($index, array('(', '['), $startIndex);
     }
     if (!$tokens->isArrayMultiLine($index)) {
         return;
     }
     if ($tokens[$startIndex]->equals('(')) {
         $endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startIndex);
     } else {
         $endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_SQUARE_BRACE, $startIndex);
     }
     $beforeEndIndex = null;
     $beforeEndToken = $tokens->getTokenNotOfKindSibling($endIndex, -1, array(array(T_WHITESPACE), array(T_COMMENT), array(T_DOC_COMMENT)), $beforeEndIndex);
     // if there is some item between braces then add `,` after it
     if ($startIndex !== $beforeEndIndex && !$beforeEndToken->equals(',')) {
         $tokens->insertAt($beforeEndIndex + 1, new Token(','));
     }
 }