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

Breadcrumb

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

function DocCommentHelper::findDocCommentOwnerPointer

1 call to DocCommentHelper::findDocCommentOwnerPointer()
TypeHintHelper::isTemplate in vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/TypeHintHelper.php

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/DocCommentHelper.php, line 177

Class

DocCommentHelper
@internal

Namespace

SlevomatCodingStandard\Helpers

Code

public static function findDocCommentOwnerPointer(File $phpcsFile, int $docCommentOpenPointer) : ?int {
    $tokens = $phpcsFile->getTokens();
    $docCommentCloserPointer = $tokens[$docCommentOpenPointer]['comment_closer'];
    if (self::isInline($phpcsFile, $docCommentOpenPointer)) {
        return null;
    }
    $docCommentOwnerPointer = null;
    for ($i = $docCommentCloserPointer + 1; $i < count($tokens); $i++) {
        if ($tokens[$i]['code'] === T_ATTRIBUTE) {
            $i = $tokens[$i]['attribute_closer'];
            continue;
        }
        if (in_array($tokens[$i]['code'], [
            T_PUBLIC,
            T_PROTECTED,
            T_PRIVATE,
            T_VAR,
            T_READONLY,
            T_FINAL,
            T_STATIC,
            T_ABSTRACT,
            T_WHITESPACE,
        ], true)) {
            continue;
        }
        if (in_array($tokens[$i]['code'], array_merge([
            T_FUNCTION,
            T_VARIABLE,
            T_CONST,
        ], TokenHelper::$typeKeywordTokenCodes), true)) {
            $docCommentOwnerPointer = $i;
        }
        break;
    }
    return $docCommentOwnerPointer;
}

API Navigation

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