class FunctionCallSignatureSniff
Same name in this branch
- 11.1.x vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionCallSignatureSniff
Hierarchy
- class \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionCallSignatureSniff implements \PHP_CodeSniffer\Sniffs\Sniff
- class \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff extends \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionCallSignatureSniff
Expanded class hierarchy of FunctionCallSignatureSniff
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PSR2/ Sniffs/ Methods/ FunctionCallSignatureSniff.php, line 16
Namespace
PHP_CodeSniffer\Standards\PSR2\Sniffs\MethodsView source
class FunctionCallSignatureSniff extends PEARFunctionCallSignatureSniff {
/**
* If TRUE, multiple arguments can be defined per line in a multi-line call.
*
* @var boolean
*/
public $allowMultipleArguments = false;
/**
* Processes single-line calls.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token
* in the stack passed in $tokens.
* @param int $openBracket The position of the opening bracket
* in the stack passed in $tokens.
* @param array $tokens The stack of tokens that make up
* the file.
*
* @return bool
*/
public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) {
// If the first argument is on a new line, this is a multi-line
// function call, even if there is only one argument.
$next = $phpcsFile->findNext(Tokens::$emptyTokens, $openBracket + 1, null, true);
if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) {
return true;
}
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];
$end = $phpcsFile->findEndOfStatement($openBracket + 1, [
T_COLON,
]);
while ($tokens[$end]['code'] === T_COMMA) {
// If the next bit of code is not on the same line, this is a
// multi-line function call.
$next = $phpcsFile->findNext(Tokens::$emptyTokens, $end + 1, $closeBracket, true);
if ($next === false) {
return false;
}
if ($tokens[$next]['line'] !== $tokens[$end]['line']) {
return true;
}
$end = $phpcsFile->findEndOfStatement($next, [
T_COLON,
]);
}
// We've reached the last argument, so see if the next content
// (should be the close bracket) is also on the same line.
$next = $phpcsFile->findNext(Tokens::$emptyTokens, $end + 1, $closeBracket, true);
if ($next !== false && $tokens[$next]['line'] !== $tokens[$end]['line']) {
return true;
}
return false;
}
//end isMultiLineCall()
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
FunctionCallSignatureSniff::$allowMultipleArguments | public | property | If TRUE, multiple arguments can be defined per line in a multi-line call. | Overrides FunctionCallSignatureSniff::$allowMultipleArguments |
FunctionCallSignatureSniff::$indent | public | property | The number of spaces code should be indented. | |
FunctionCallSignatureSniff::$requiredSpacesAfterOpen | public | property | How many spaces should follow the opening bracket. | |
FunctionCallSignatureSniff::$requiredSpacesBeforeClose | public | property | How many spaces should precede the closing bracket. | |
FunctionCallSignatureSniff::$supportedTokenizers | public | property | A list of tokenizers this sniff supports. | |
FunctionCallSignatureSniff::isMultiLineCall | public | function | Processes single-line calls. | Overrides FunctionCallSignatureSniff::isMultiLineCall |
FunctionCallSignatureSniff::process | public | function | Processes this test, when one of its tokens is encountered. | Overrides Sniff::process |
FunctionCallSignatureSniff::processMultiLineCall | public | function | Processes multi-line calls. | |
FunctionCallSignatureSniff::processSingleLineCall | public | function | Processes single-line calls. | |
FunctionCallSignatureSniff::register | public | function | Returns an array of tokens this test wants to listen for. | Overrides Sniff::register |