Description
FunctionCallSignatureSniff assumes that the closing call parentheses is placed on its own line. If that's not the case, the CloseBracketLine
issue is emitted. This can clearly be disabled in a custom standard, if wanted; however, the sniff also makes the same assumption elsewhere:
if ($tokens[$nextCode]['line'] === $tokens[$closeBracket]['line']) {
// Closing brace needs to be indented to the same level
// as the function call.
$inArg = false;
$expectedIndent = ($foundFunctionIndent + $adjustment);
} else {
$expectedIndent = ($foundFunctionIndent + $this->indent + $adjustment);
}
This means that if you disable CloseBracketLine
and run PHPCS on the following code:
function foo() {
$this->doSomething(
$firstArg, $secondArg, $thirdArg );
}
it will still complain that the second call line is not indented correctly. In particular, since it contains the closing parentheses, PHPCS wants it to have the same indentation as the first call line, meaning it would consider this to be correct:
function foo() {
$this->doSomething(
$firstArg, $secondArg, $thirdArg );
}
Therefore, I'm asking if it would be possible to make the sniff work in a custom standard that does not require the closing parentheses to be on its own line. This could perhaps be a config option to the sniff; or maybe the if
branch in the conditional above could be updated to check that the closing parentheses is the only thing on that line. However, this would need to account for arrays:
function foo() {
$this->doSomething( [
$firstArg, $secondArg, $thirdArg
] ); // This is correct; even if the ) is not alone, this line should have the same indentation as the opener (
}
Thanks!