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

Merge branch '13-check-spaces-before-opening-parenthesis-for-functions' into 'master'

Resolve "Check spaces before opening parenthesis for functions"

Closes #13

See merge request fusiondirectory/dev-tools!14
parents cccbd92b cb2430f8
......@@ -72,6 +72,29 @@ class FDStandard_Sniffs_WhiteSpace_FunctionCallArgumentSpacingSniff implements P
return;
}
if ($whatisit == "function declaration") {
if ($tokens[($functionName + 1)]['code'] !== T_WHITESPACE) {
$error = 'No space found before opening parenthesis in '.$whatisit;
$phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeOpeningParenthesis');
} else {
// If there is a newline in the space, then the must be formatting
// each argument on a newline, which is valid, so ignore it.
if (strpos($tokens[($functionName + 1)]['content'], $phpcsFile->eolChar) === false) {
$space = strlen($tokens[($functionName + 1)]['content']);
if (($space > 1) && ($this->exact)) {
$error = 'Expected 1 space before opening parenthesis in '.$whatisit.'; %s found';
$data = array($space);
$phpcsFile->addError($error, $stackPtr, 'TooMuchSpaceBeforeOpeningParenthesis', $data);
}
}
}
} else {
if ($tokens[($functionName + 1)]['code'] === T_WHITESPACE) {
$error = 'Space found before opening parenthesis in '.$whatisit;
$phpcsFile->addError($error, $stackPtr, 'SpaceBeforeOpeningParenthesis');
}
}
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];
$nextSeperator = $openBracket;
......
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