function DataProviderHelper::getDataProviderMethods
*
Return value
iterable<array{ClassReflection|null, string, int}>
File
-
vendor/
phpstan/ phpstan-phpunit/ src/ Rules/ PHPUnit/ DataProviderHelper.php, line 59
Class
Namespace
PHPStan\Rules\PHPUnitCode
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;
}
}
}