mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-15 05:15:04 +01:00
34 lines
1.3 KiB
PHP
34 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Php80\NodeFactory;
|
|
|
|
use PhpParser\Node\AttributeGroup;
|
|
use Rector\Php80\ValueObject\DoctrineTagAndAnnotationToAttribute;
|
|
use Rector\PhpAttribute\Printer\PhpAttributeGroupFactory;
|
|
final class AttrGroupsFactory
|
|
{
|
|
/**
|
|
* @var \Rector\PhpAttribute\Printer\PhpAttributeGroupFactory
|
|
*/
|
|
private $phpAttributeGroupFactory;
|
|
public function __construct(\Rector\PhpAttribute\Printer\PhpAttributeGroupFactory $phpAttributeGroupFactory)
|
|
{
|
|
$this->phpAttributeGroupFactory = $phpAttributeGroupFactory;
|
|
}
|
|
/**
|
|
* @param DoctrineTagAndAnnotationToAttribute[] $doctrineTagAndAnnotationToAttributes
|
|
* @return AttributeGroup[]
|
|
*/
|
|
public function create(array $doctrineTagAndAnnotationToAttributes) : array
|
|
{
|
|
$attributeGroups = [];
|
|
foreach ($doctrineTagAndAnnotationToAttributes as $doctrineTagAndAnnotationToAttribute) {
|
|
$doctrineAnnotationTagValueNode = $doctrineTagAndAnnotationToAttribute->getDoctrineAnnotationTagValueNode();
|
|
// add attributes
|
|
$attributeGroups[] = $this->phpAttributeGroupFactory->create($doctrineAnnotationTagValueNode, $doctrineTagAndAnnotationToAttribute->getAnnotationToAttribute());
|
|
}
|
|
return $attributeGroups;
|
|
}
|
|
}
|