2021-11-20 15:31:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare (strict_types=1);
|
|
|
|
namespace Rector\PhpAttribute\AnnotationToAttributeMapper;
|
|
|
|
|
2021-11-28 19:07:44 +00:00
|
|
|
use PhpParser\Node\Expr;
|
2021-11-20 15:31:12 +00:00
|
|
|
use Rector\PhpAttribute\AnnotationToAttributeMapper;
|
|
|
|
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
|
2021-12-19 00:36:48 +00:00
|
|
|
use RectorPrefix20211219\Symfony\Contracts\Service\Attribute\Required;
|
2021-11-20 15:31:12 +00:00
|
|
|
/**
|
2021-11-28 19:07:44 +00:00
|
|
|
* @implements AnnotationToAttributeMapperInterface<mixed[]>
|
2021-11-20 15:31:12 +00:00
|
|
|
*/
|
|
|
|
final class ArrayAnnotationToAttributeMapper implements \Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Rector\PhpAttribute\AnnotationToAttributeMapper
|
|
|
|
*/
|
|
|
|
private $annotationToAttributeMapper;
|
|
|
|
/**
|
|
|
|
* Avoid circular reference
|
|
|
|
* @required
|
|
|
|
*/
|
|
|
|
public function autowire(\Rector\PhpAttribute\AnnotationToAttributeMapper $annotationToAttributeMapper) : void
|
|
|
|
{
|
|
|
|
$this->annotationToAttributeMapper = $annotationToAttributeMapper;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param mixed $value
|
|
|
|
*/
|
|
|
|
public function isCandidate($value) : bool
|
|
|
|
{
|
|
|
|
return \is_array($value);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param mixed[] $value
|
2021-11-28 19:07:44 +00:00
|
|
|
* @return mixed[]|\PhpParser\Node\Expr
|
2021-11-20 15:31:12 +00:00
|
|
|
*/
|
2021-11-28 19:07:44 +00:00
|
|
|
public function map($value)
|
2021-11-20 15:31:12 +00:00
|
|
|
{
|
|
|
|
return \array_map(function ($item) {
|
|
|
|
return $this->annotationToAttributeMapper->map($item);
|
|
|
|
}, $value);
|
|
|
|
}
|
|
|
|
}
|