Commit e5da602f authored by Côme Chilliet's avatar Côme Chilliet

🚑 fix(sniffs) Fix short array syntax handling

issue #14
parent ec44027a
......@@ -58,8 +58,11 @@ class FDStandard_Sniffs_WhiteSpace_AssignmentSpacingSniff implements PHP_CodeSni
$nextAssignment = $stackPtr;
$lastLine = $tokens[$stackPtr]['line'];
$bracketTokens = array(T_OPEN_CURLY_BRACKET, T_CLOSE_CURLY_BRACKET,
T_OPEN_PARENTHESIS, T_CLOSE_PARENTHESIS);
$bracketTokens = array(
T_OPEN_CURLY_BRACKET, T_CLOSE_CURLY_BRACKET,
T_OPEN_PARENTHESIS, T_CLOSE_PARENTHESIS,
T_OPEN_SHORT_ARRAY, T_CLOSE_SHORT_ARRAY,
);
if ($nextBracket = $phpcsFile->findNext($bracketTokens,$stackPtr+1)) {
$nextBracketLine = $tokens[$nextBracket]['line'];
}
......
......@@ -98,7 +98,13 @@ class FDStandard_Sniffs_WhiteSpace_FunctionCallArgumentSpacingSniff implements P
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];
$nextSeperator = $openBracket;
while (($nextSeperator = $phpcsFile->findNext(array(T_COMMA, T_VARIABLE), ($nextSeperator + 1), $closeBracket)) !== false) {
while (($nextSeperator = $phpcsFile->findNext(array(T_COMMA, T_VARIABLE, T_OPEN_SHORT_ARRAY), ($nextSeperator + 1), $closeBracket)) !== false) {
if ($tokens[$nextSeperator]['code'] === T_OPEN_SHORT_ARRAY) {
// Skip short array by jumping to the closing bracket directly
$nextSeperator = $tokens[$nextSeperator]['bracket_closer'];
continue;
}
// Make sure the comma or variable belongs directly to this function call,
// and is not inside a nested function call or array.
$brackets = $tokens[$nextSeperator]['nested_parenthesis'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment