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

Breadcrumb

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

function FunctionHelper::getValidPrefixedParametersAnnotations

*

Return value

array<string, Annotation<VarTagValueNode>|Annotation<ParamTagValueNode>>

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

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/FunctionHelper.php, line 372

Class

FunctionHelper
@internal

Namespace

SlevomatCodingStandard\Helpers

Code

public static function getValidPrefixedParametersAnnotations(File $phpcsFile, int $functionPointer) : array {
    $tokens = $phpcsFile->getTokens();
    $parametersAnnotations = [];
    foreach (AnnotationHelper::STATIC_ANALYSIS_PREFIXES as $prefix) {
        if (self::getName($phpcsFile, $functionPointer) === '__construct') {
            for ($i = $tokens[$functionPointer]['parenthesis_opener'] + 1; $i < $tokens[$functionPointer]['parenthesis_closer']; $i++) {
                if ($tokens[$i]['code'] !== T_VARIABLE) {
                    continue;
                }
                
                /** @var list<Annotation<VarTagValueNode>> $varAnnotations */
                $varAnnotations = AnnotationHelper::getAnnotations($phpcsFile, $i, sprintf('@%s-var', $prefix));
                if ($varAnnotations === []) {
                    continue;
                }
                $parametersAnnotations[$tokens[$i]['content']] = $varAnnotations[0];
            }
        }
        
        /** @var list<Annotation<ParamTagValueNode>> $annotations */
        $annotations = AnnotationHelper::getAnnotations($phpcsFile, $functionPointer, sprintf('@%s-param', $prefix));
        foreach ($annotations as $parameterAnnotation) {
            if ($parameterAnnotation->isInvalid()) {
                continue;
            }
            $parametersAnnotations[$parameterAnnotation->getValue()->parameterName] = $parameterAnnotation;
        }
    }
    return $parametersAnnotations;
}
RSS feed
Powered by Drupal