Skip to content

Commit e69f628

Browse files
committed
Cant act on the same token in the same run, so add newline and padding in one step. Don't skip arrays when checking either, because they need to be indented as well.
1 parent dff45c0 commit e69f628

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,26 @@ public function processMultiLineCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr,
190190
if ($tokens[($openBracket + 1)]['content'] !== $phpcsFile->eolChar) {
191191
$error = 'Opening parenthesis of a multi-line function call must be the last content on the line';
192192
$phpcsFile->addError($error, $stackPtr, 'ContentAfterOpenBracket');
193-
$phpcsFile->fixer->addNewline($openBracket);
194-
$phpcsFile->fixer->addContent($openBracket, str_repeat(' ', ($functionIndent + $this->indent)));
193+
$phpcsFile->fixer->addContent($openBracket, $phpcsFile->eolChar.str_repeat(' ', ($functionIndent + $this->indent)));
195194
}
196195

197196
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];
198197
$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBracket - 1), null, true);
199198
if ($tokens[$prev]['line'] === $tokens[$closeBracket]['line']) {
200199
$error = 'Closing parenthesis of a multi-line function call must be on a line by itself';
201200
$phpcsFile->addError($error, $closeBracket, 'CloseBracketLine');
202-
$phpcsFile->fixer->addNewlineBefore($closeBracket);
203-
$phpcsFile->fixer->addContentBefore($closeBracket, str_repeat(' ', ($functionIndent + $this->indent)));
201+
$phpcsFile->fixer->addContentBefore($closeBracket, $phpcsFile->eolChar.str_repeat(' ', ($functionIndent + $this->indent)));
204202
}
205203

206204
// Each line between the parenthesis should be indented n spaces.
207205
$lastLine = $tokens[$openBracket]['line'];
208206
for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
209207
// Skip nested function calls.
210-
if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
208+
if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS
209+
&& (isset($tokens[$i]['parenthesis_owner']) === false
210+
|| $tokens[$tokens[$i]['parenthesis_owner']]['code'] !== T_ARRAY)
211+
) {
212+
211213
$i = $tokens[$i]['parenthesis_closer'];
212214
$lastLine = $tokens[$i]['line'];
213215
continue;

0 commit comments

Comments
 (0)