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

Merge branch '14-our-sniffs-badly-handle-short-array-syntax' into 'master'

Resolve "Our sniffs badly handle short array syntax"

Closes #14

See merge request fusiondirectory/dev-tools!15
parents ec44027a 3240795e
......@@ -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'];
......
......@@ -39,6 +39,9 @@
<rule ref="Generic.PHP.UpperCaseConstant">
<severity>7</severity>
</rule>
<rule ref="Generic.Arrays.DisallowLongArraySyntax">
<severity>6</severity>
</rule>
<rule ref="Generic.WhiteSpace.DisallowTabIndent">
<severity>7</severity>
</rule>
......
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