rector/packages/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php
Tomas Votruba 0b3c5d9bcc Updated Rector to commit f22ddc8f18ef345d5e9c99cbb667548c3c854d7d
f22ddc8f18 Add not null compare to FlipTypeControlToUseExclusiveTypeRector (#3513)
2023-03-23 23:21:34 +00:00

30 lines
931 B
PHP

<?php
declare (strict_types=1);
namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc;
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use Stringable;
final class SpacingAwareTemplateTagValueNode extends TemplateTagValueNode
{
/**
* @readonly
* @var string
*/
private $preposition;
public function __construct(string $name, ?TypeNode $typeNode, string $description, string $preposition)
{
$this->preposition = $preposition;
parent::__construct($name, $typeNode, $description);
}
public function __toString() : string
{
// @see https://github.com/rectorphp/rector/issues/3438
# 'as'/'of'
$bound = $this->bound instanceof TypeNode ? ' ' . $this->preposition . ' ' . $this->bound : '';
$content = $this->name . $bound . ' ' . $this->description;
return \trim($content);
}
}