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

Breadcrumb

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

function RequireNullSafeObjectOperatorSniff::findIdentificatorEnd

2 calls to RequireNullSafeObjectOperatorSniff::findIdentificatorEnd()
RequireNullSafeObjectOperatorSniff::getConditionData in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullSafeObjectOperatorSniff.php
*
RequireNullSafeObjectOperatorSniff::getNextIdentificator in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullSafeObjectOperatorSniff.php
*

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullSafeObjectOperatorSniff.php, line 399

Class

RequireNullSafeObjectOperatorSniff

Namespace

SlevomatCodingStandard\Sniffs\ControlStructures

Code

private function findIdentificatorEnd(File $phpcsFile, int $identificatorStartPointer) : ?int {
    $tokens = $phpcsFile->getTokens();
    $identificatorEndPointer = $tokens[$identificatorStartPointer]['code'] === T_STRING ? $identificatorStartPointer : IdentificatorHelper::findEndPointer($phpcsFile, $identificatorStartPointer);
    if ($identificatorEndPointer !== null) {
        $pointerAfterIdentificatorEnd = TokenHelper::findNextEffective($phpcsFile, $identificatorEndPointer + 1);
        if ($tokens[$pointerAfterIdentificatorEnd]['code'] === T_OPEN_PARENTHESIS) {
            $identificatorEndPointer = $tokens[$pointerAfterIdentificatorEnd]['parenthesis_closer'];
            $pointerAfterIdentificatorEnd = TokenHelper::findNextEffective($phpcsFile, $identificatorEndPointer + 1);
        }
        if (in_array($tokens[$pointerAfterIdentificatorEnd]['code'], [
            T_DOUBLE_COLON,
            T_OBJECT_OPERATOR,
            T_NULLSAFE_OBJECT_OPERATOR,
        ], true)) {
            $pointerAfterOperator = TokenHelper::findNextEffective($phpcsFile, $pointerAfterIdentificatorEnd + 1);
            return $this->findIdentificatorEnd($phpcsFile, $pointerAfterOperator);
        }
    }
    return $identificatorEndPointer;
}
RSS feed
Powered by Drupal