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

Breadcrumb

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

function AnnotationNameSniff::getNormalizedAnnotationNames

*

Return value

array<string, string>

1 call to AnnotationNameSniff::getNormalizedAnnotationNames()
AnnotationNameSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/AnnotationNameSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/AnnotationNameSniff.php, line 264

Class

AnnotationNameSniff

Namespace

SlevomatCodingStandard\Sniffs\Commenting

Code

private function getNormalizedAnnotationNames() : array {
    if ($this->normalizedAnnotations !== null) {
        return $this->normalizedAnnotations;
    }
    if ($this->annotations !== null) {
        $annotationNames = array_map(static function (string $annotationName) : string {
            return ltrim($annotationName, '@');
        }, SniffSettingsHelper::normalizeArray($this->annotations));
    }
    else {
        $annotationNames = array_merge(self::STANDARD_ANNOTATIONS, self::PHPUNIT_ANNOTATIONS, self::STATIC_ANALYSIS_ANNOTATIONS);
        foreach (self::STATIC_ANALYSIS_ANNOTATIONS as $annotationName) {
            if (strpos($annotationName, 'psalm') === 0) {
                continue;
            }
            foreach (AnnotationHelper::STATIC_ANALYSIS_PREFIXES as $prefix) {
                $annotationNames[] = sprintf('%s-%s', $prefix, $annotationName);
            }
        }
    }
    $annotationNames = array_map(static function (string $annotationName) : string {
        return '@' . $annotationName;
    }, array_unique($annotationNames));
    $this->normalizedAnnotations = array_combine(array_map(static function (string $annotationName) : string {
        return strtolower($annotationName);
    }, $annotationNames), $annotationNames);
    return $this->normalizedAnnotations;
}
RSS feed
Powered by Drupal