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

Breadcrumb

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

function IdentificatorHelper::findStartPointer

7 calls to IdentificatorHelper::findStartPointer()
NegationOperatorSpacingSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Operators/NegationOperatorSpacingSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
RequireCombinedAssignmentOperatorSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Operators/RequireCombinedAssignmentOperatorSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
RequireNullCoalesceEqualOperatorSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullCoalesceEqualOperatorSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
RequireNullCoalesceOperatorSniff::checkIdenticalOperator in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullCoalesceOperatorSniff.php
RequireNullSafeObjectOperatorSniff::findIdentificatorStart in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullSafeObjectOperatorSniff.php

... See full list

File

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

Class

IdentificatorHelper
@internal

Namespace

SlevomatCodingStandard\Helpers

Code

public static function findStartPointer(File $phpcsFile, int $endPointer) : ?int {
    $tokens = $phpcsFile->getTokens();
    if (in_array($tokens[$endPointer]['code'], TokenHelper::getNameTokenCodes(), true)) {
        
        /** @var int $previousPointer */
        $previousPointer = TokenHelper::findPreviousEffective($phpcsFile, $endPointer - 1);
        if (in_array($tokens[$previousPointer]['code'], [
            T_OBJECT_OPERATOR,
            T_NULLSAFE_OBJECT_OPERATOR,
            T_DOUBLE_COLON,
        ], true)) {
            $pointerBeforeOperator = TokenHelper::findPreviousEffective($phpcsFile, $previousPointer - 1);
            if ($tokens[$pointerBeforeOperator]['code'] !== T_CLOSE_PARENTHESIS) {
                return self::getStartPointerBeforeOperator($phpcsFile, $previousPointer);
            }
        }
        return $endPointer;
    }
    if (in_array($tokens[$endPointer]['code'], [
        T_CLOSE_CURLY_BRACKET,
        T_CLOSE_SQUARE_BRACKET,
    ], true)) {
        return self::getStartPointerBeforeVariablePart($phpcsFile, $tokens[$endPointer]['bracket_opener']);
    }
    if ($tokens[$endPointer]['code'] === T_VARIABLE) {
        return self::getStartPointerBeforeVariablePart($phpcsFile, $endPointer);
    }
    return null;
}

API Navigation

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