TemplateTagValueNode: $bound is nullable

This commit is contained in:
Jan Tvrdik 2019-10-06 12:03:17 +02:00
parent 3e956143ed
commit b3040ade88
3 changed files with 7 additions and 6 deletions

View File

@ -10,13 +10,13 @@ class TemplateTagValueNode implements PhpDocTagValueNode
/** @var string */
public $name;
/** @var TypeNode */
/** @var TypeNode|null */
public $bound;
/** @var string (may be empty) */
public $description;
public function __construct(string $name, TypeNode $bound, string $description)
public function __construct(string $name, ?TypeNode $bound, string $description)
{
$this->name = $name;
$this->bound = $bound;
@ -26,7 +26,8 @@ class TemplateTagValueNode implements PhpDocTagValueNode
public function __toString(): string
{
return trim("{$this->name} of {$this->bound} {$this->description}");
$bound = $this->bound ? " of {$this->bound}" : '';
return trim("{$this->name}{$bound} {$this->description}");
}
}

View File

@ -293,7 +293,7 @@ class PhpDocParser
$bound = $this->typeParser->parse($tokens);
} else {
$bound = new IdentifierTypeNode('mixed');
$bound = null;
}
$description = $this->parseOptionalDescription($tokens);

View File

@ -2282,7 +2282,7 @@ some text in the middle'
'@template',
new TemplateTagValueNode(
'T',
new IdentifierTypeNode('mixed'),
null,
''
)
),
@ -2297,7 +2297,7 @@ some text in the middle'
'@template',
new TemplateTagValueNode(
'T',
new IdentifierTypeNode('mixed'),
null,
'the value type'
)
),