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

Breadcrumb

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

function IdentificatorHelper::getEndPointerAfterVariablePart

2 calls to IdentificatorHelper::getEndPointerAfterVariablePart()
IdentificatorHelper::findEndPointer in vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/IdentificatorHelper.php
IdentificatorHelper::getEndPointerAfterOperator in vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/IdentificatorHelper.php

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/IdentificatorHelper.php, line 198

Class

IdentificatorHelper
@internal

Namespace

SlevomatCodingStandard\Helpers

Code

private static function getEndPointerAfterVariablePart(File $phpcsFile, int $variablePartPointer) : int {
    $tokens = $phpcsFile->getTokens();
    
    /** @var int $nextPointer */
    $nextPointer = TokenHelper::findNextEffective($phpcsFile, $variablePartPointer + 1);
    if (in_array($tokens[$nextPointer]['code'], [
        T_OBJECT_OPERATOR,
        T_NULLSAFE_OBJECT_OPERATOR,
        T_DOUBLE_COLON,
    ], true)) {
        return self::getEndPointerAfterOperator($phpcsFile, $nextPointer);
    }
    if ($tokens[$nextPointer]['code'] === T_OPEN_SQUARE_BRACKET) {
        return self::getEndPointerAfterVariablePart($phpcsFile, $tokens[$nextPointer]['bracket_closer']);
    }
    return $variablePartPointer;
}
RSS feed
Powered by Drupal