Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RequireSingleLineCallSniff.php

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

RequireSingleLineCallSniff

Namespace

SlevomatCodingStandard\Sniffs\Functions

Code

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;
}
RSS feed
Powered by Drupal