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

Breadcrumb

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

function RequireNullSafeObjectOperatorSniff::findIdentificatorStart

1 call to RequireNullSafeObjectOperatorSniff::findIdentificatorStart()
RequireNullSafeObjectOperatorSniff::getConditionData in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullSafeObjectOperatorSniff.php
*

File

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

Class

RequireNullSafeObjectOperatorSniff

Namespace

SlevomatCodingStandard\Sniffs\ControlStructures

Code

private function findIdentificatorStart(File $phpcsFile, int $identificatorEndPointer) : ?int {
    $tokens = $phpcsFile->getTokens();
    if ($tokens[$identificatorEndPointer]['code'] === T_CLOSE_PARENTHESIS) {
        $pointerBeforeParenthesisOpener = TokenHelper::findPreviousEffective($phpcsFile, $tokens[$identificatorEndPointer]['parenthesis_opener'] - 1);
        $identificatorStartPointer = IdentificatorHelper::findStartPointer($phpcsFile, $pointerBeforeParenthesisOpener);
    }
    else {
        $identificatorStartPointer = IdentificatorHelper::findStartPointer($phpcsFile, $identificatorEndPointer);
    }
    if ($identificatorStartPointer !== null) {
        $pointerBeforeIdentificatorStart = TokenHelper::findPreviousEffective($phpcsFile, $identificatorStartPointer - 1);
        if (in_array($tokens[$pointerBeforeIdentificatorStart]['code'], [
            T_DOUBLE_COLON,
            T_OBJECT_OPERATOR,
            T_NULLSAFE_OBJECT_OPERATOR,
        ], true)) {
            $pointerBeforeOperator = TokenHelper::findPreviousEffective($phpcsFile, $pointerBeforeIdentificatorStart - 1);
            return $this->findIdentificatorStart($phpcsFile, $pointerBeforeOperator);
        }
    }
    return $identificatorStartPointer;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal