Skip to content

Commit b2805c3

Browse files
committed
Sniffs that override this one can now decide if something is a multi-line function calls by writing their own isMultiLineCall() method.
1 parent 3d240ac commit b2805c3

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,40 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
107107
}
108108

109109
// Check if this is a single line or multi-line function call.
110-
if ($tokens[$openBracket]['line'] === $tokens[$closeBracket]['line']) {
111-
$this->processSingleLineCall($phpcsFile, $stackPtr, $openBracket, $tokens);
112-
} else {
110+
if ($this->isMultiLineCall($phpcsFile, $stackPtr, $openBracket, $tokens) === true) {
113111
$this->processMultiLineCall($phpcsFile, $stackPtr, $openBracket, $tokens);
112+
} else {
113+
$this->processSingleLineCall($phpcsFile, $stackPtr, $openBracket, $tokens);
114114
}
115115

116116
}//end process()
117117

118118

119+
/**
120+
* Processes single-line calls.
121+
*
122+
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
123+
* @param int $stackPtr The position of the current token
124+
* in the stack passed in $tokens.
125+
* @param int $openBracket The position of the opening bracket
126+
* in the stack passed in $tokens.
127+
* @param array $tokens The stack of tokens that make up
128+
* the file.
129+
*
130+
* @return void
131+
*/
132+
public function isMultiLineCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $openBracket, $tokens)
133+
{
134+
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];
135+
if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) {
136+
return true;
137+
}
138+
139+
return false;
140+
141+
}//end isMultiLineCall();
142+
143+
119144
/**
120145
* Processes single-line calls.
121146
*

0 commit comments

Comments
 (0)