function RequireSingleLineCallSniff::shouldBeSkipped
1 call to RequireSingleLineCallSniff::shouldBeSkipped()
- RequireSingleLineCallSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Functions/ RequireSingleLineCallSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Functions/ RequireSingleLineCallSniff.php, line 160
Class
Namespace
SlevomatCodingStandard\Sniffs\FunctionsCode
private function shouldBeSkipped(File $phpcsFile, int $stringPointer) : bool {
$tokens = $phpcsFile->getTokens();
foreach (array_reverse(TokenHelper::findNextAll($phpcsFile, [
T_OPEN_PARENTHESIS,
T_FUNCTION,
], 0, $stringPointer)) as $pointer) {
if ($tokens[$pointer]['code'] === T_FUNCTION) {
if (array_key_exists('scope_closer', $tokens[$pointer]) && $tokens[$pointer]['scope_closer'] > $stringPointer) {
return false;
}
continue;
}
if ($tokens[$pointer]['parenthesis_closer'] < $stringPointer) {
continue;
}
$pointerBeforeParenthesisOpener = TokenHelper::findPreviousEffective($phpcsFile, $pointer - 1);
if ($pointerBeforeParenthesisOpener === null || $tokens[$pointerBeforeParenthesisOpener]['code'] !== T_STRING) {
continue;
}
return true;
}
return false;
}