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

Breadcrumb

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

function AnnotationHelper::getAnnotations

*

Return value

list<Annotation>

28 calls to AnnotationHelper::getAnnotations()
AnnotationNameSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/AnnotationNameSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
DeprecatedAnnotationDeclarationSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/DeprecatedAnnotationDeclarationSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
DisallowArrayTypeHintSyntaxSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/TypeHints/DisallowArrayTypeHintSyntaxSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
DisallowMixedTypeHintSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/TypeHints/DisallowMixedTypeHintSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
DocCommentSpacingSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/DocCommentSpacingSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

... See full list

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php, line 43

Class

AnnotationHelper
@internal

Namespace

SlevomatCodingStandard\Helpers

Code

public static function getAnnotations(File $phpcsFile, int $pointer, ?string $name = null) : array {
    $docCommentOpenPointer = DocCommentHelper::findDocCommentOpenPointer($phpcsFile, $pointer);
    if ($docCommentOpenPointer === null) {
        return [];
    }
    return SniffLocalCache::getAndSetIfNotCached($phpcsFile, sprintf('annotations-%d-%s', $docCommentOpenPointer, $name ?? 'all'), static function () use ($phpcsFile, $docCommentOpenPointer, $name) : array {
        $annotations = [];
        if ($name !== null) {
            foreach (self::getAnnotations($phpcsFile, $docCommentOpenPointer) as $annotation) {
                if ($annotation->getName() === $name) {
                    $annotations[] = $annotation;
                }
            }
        }
        else {
            $parsedDocComment = DocCommentHelper::parseDocComment($phpcsFile, $docCommentOpenPointer);
            if ($parsedDocComment !== null) {
                foreach ($parsedDocComment->getNode()
                    ->getTags() as $node) {
                    $annotationStartPointer = $parsedDocComment->getNodeStartPointer($phpcsFile, $node);
                    $annotations[] = new Annotation($node, $annotationStartPointer, $parsedDocComment->getNodeEndPointer($phpcsFile, $node, $annotationStartPointer));
                }
            }
        }
        return $annotations;
    });
}
RSS feed
Powered by Drupal