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

Breadcrumb

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

function DataProviderHelper::getDataProviderMethods

*

Return value

iterable<array{ClassReflection|null, string, int}>

File

vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderHelper.php, line 59

Class

DataProviderHelper

Namespace

PHPStan\Rules\PHPUnit

Code

public function getDataProviderMethods(Scope $scope, ClassMethod $node, ClassReflection $classReflection) : iterable {
    $docComment = $node->getDocComment();
    if ($docComment !== null) {
        $methodPhpDoc = $this->fileTypeMapper
            ->getResolvedPhpDoc($scope->getFile(), $classReflection->getName(), $scope->isInTrait() ? $scope->getTraitReflection()
            ->getName() : null, $node->name
            ->toString(), $docComment->getText());
        foreach ($this->getDataProviderAnnotations($methodPhpDoc) as $annotation) {
            $dataProviderValue = $this->getDataProviderAnnotationValue($annotation);
            if ($dataProviderValue === null) {
                // Missing value is already handled in NoMissingSpaceInMethodAnnotationRule
                continue;
            }
            $dataProviderMethod = $this->parseDataProviderAnnotationValue($scope, $dataProviderValue);
            $dataProviderMethod[] = $node->getLine();
            (yield $dataProviderValue => $dataProviderMethod);
        }
    }
    if (!$this->phpunit10OrNewer) {
        return;
    }
    foreach ($node->attrGroups as $attrGroup) {
        foreach ($attrGroup->attrs as $attr) {
            $dataProviderMethod = null;
            if ($attr->name
                ->toLowerString() === 'phpunit\\framework\\attributes\\dataprovider') {
                $dataProviderMethod = $this->parseDataProviderAttribute($attr, $classReflection);
            }
            elseif ($attr->name
                ->toLowerString() === 'phpunit\\framework\\attributes\\dataproviderexternal') {
                $dataProviderMethod = $this->parseDataProviderExternalAttribute($attr);
            }
            if ($dataProviderMethod === null) {
                continue;
            }
            yield from $dataProviderMethod;
        }
    }
}

API Navigation

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