rector/packages/PhpAttribute/AnnotationToAttributeMapper/StringNodeAnnotationToAttributeMapper.php
Tomas Votruba 3dc5be2274 Updated Rector to commit 92ff716761e19c7f30bd68065af7eeefac0480de
92ff716761 Improve string support in Doctrine Annotations (#3645)
2023-06-02 09:42:16 +00:00

31 lines
849 B
PHP

<?php
declare (strict_types=1);
namespace Rector\PhpAttribute\AnnotationToAttributeMapper;
use PhpParser\Node\Expr;
use PhpParser\Node\Scalar\String_;
use Rector\BetterPhpDocParser\PhpDoc\StringNode;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
/**
* @implements AnnotationToAttributeMapperInterface<StringNode>
*/
final class StringNodeAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface
{
/**
* @param mixed $value
*/
public function isCandidate($value) : bool
{
return $value instanceof StringNode;
}
/**
* @param StringNode $value
*/
public function map($value) : Expr
{
return new String_($value->value, [AttributeKey::KIND => $value->getAttribute(AttributeKey::KIND)]);
}
}