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

Breadcrumb

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

function TokenHelper::findFirstNonWhitespaceOnPreviousLine

*

Parameters

int $pointer Search starts at this token, inclusive:

2 calls to TokenHelper::findFirstNonWhitespaceOnPreviousLine()
InlineDocCommentDeclarationSniff::checkVariable in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/InlineDocCommentDeclarationSniff.php
*
RequireExplicitAssertionSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/PHP/RequireExplicitAssertionSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/TokenHelper.php, line 422

Class

TokenHelper
@internal

Namespace

SlevomatCodingStandard\Helpers

Code

public static function findFirstNonWhitespaceOnPreviousLine(File $phpcsFile, int $pointer) : ?int {
    $newLinePointerOnPreviousLine = self::findPreviousContent($phpcsFile, [
        T_WHITESPACE,
        T_DOC_COMMENT_WHITESPACE,
    ], $phpcsFile->eolChar, $pointer);
    if ($newLinePointerOnPreviousLine === null) {
        return null;
    }
    $newLinePointerBeforePreviousLine = self::findPreviousContent($phpcsFile, [
        T_WHITESPACE,
        T_DOC_COMMENT_WHITESPACE,
    ], $phpcsFile->eolChar, $newLinePointerOnPreviousLine - 1);
    if ($newLinePointerBeforePreviousLine === null) {
        return null;
    }
    $nextPointer = self::findNextExcluding($phpcsFile, [
        T_WHITESPACE,
        T_DOC_COMMENT_WHITESPACE,
    ], $newLinePointerBeforePreviousLine + 1);
    $tokens = $phpcsFile->getTokens();
    if ($nextPointer !== null && $tokens[$pointer]['line'] === $tokens[$nextPointer]['line'] + 1) {
        return $nextPointer;
    }
    return null;
}
RSS feed
Powered by Drupal