mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 09:50:49 +00:00
d56e7982d0
dedd4b55fe
make node_helper.php safe for similar names
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\BetterPhpDocParser\PhpDoc;
|
|
|
|
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode;
|
|
final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $annotationClass;
|
|
/**
|
|
* @param array<mixed, mixed> $values
|
|
*/
|
|
public function __construct(
|
|
// values
|
|
string $annotationClass,
|
|
?string $originalContent = null,
|
|
array $values = [],
|
|
?string $silentKey = null
|
|
)
|
|
{
|
|
$this->hasChanged = \true;
|
|
$this->annotationClass = $annotationClass;
|
|
parent::__construct($values, $originalContent, $silentKey);
|
|
}
|
|
public function __toString() : string
|
|
{
|
|
if (!$this->hasChanged) {
|
|
if ($this->originalContent === null) {
|
|
return '';
|
|
}
|
|
return $this->originalContent;
|
|
}
|
|
if ($this->values === []) {
|
|
if ($this->originalContent === '()') {
|
|
// empty brackets
|
|
return $this->originalContent;
|
|
}
|
|
return '';
|
|
}
|
|
$itemContents = $this->printValuesContent($this->values);
|
|
return \sprintf('(%s)', $itemContents);
|
|
}
|
|
public function getAnnotationClass() : string
|
|
{
|
|
return $this->annotationClass;
|
|
}
|
|
}
|