Skip to content

Commit fcaefac

Browse files
staabmondrejmirtes
authored andcommitted
TemplateTagValueNode name cannot be empty string
1 parent 536889f commit fcaefac

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/Ast/PhpDoc/TemplateTagValueNode.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TemplateTagValueNode implements PhpDocTagValueNode
1111

1212
use NodeAttributes;
1313

14-
/** @var string */
14+
/** @var non-empty-string */
1515
public $name;
1616

1717
/** @var TypeNode|null */
@@ -23,6 +23,9 @@ class TemplateTagValueNode implements PhpDocTagValueNode
2323
/** @var string (may be empty) */
2424
public $description;
2525

26+
/**
27+
* @param non-empty-string $name
28+
*/
2629
public function __construct(string $name, ?TypeNode $bound, string $description, ?TypeNode $default = null)
2730
{
2831
$this->name = $name;

src/Parser/TypeParser.php

+4
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ public function parseTemplateTagValue(
510510
$description = '';
511511
}
512512

513+
if ($name === '') {
514+
throw new LogicException('Template tag name cannot be empty.');
515+
}
516+
513517
return new Ast\PhpDoc\TemplateTagValueNode($name, $bound, $description, $default);
514518
}
515519

tests/PHPStan/Printer/PrinterTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ public function enterNode(Node $node)
17921792
}
17931793

17941794
/**
1795-
* @return iterable<list{TypeNode, string}>
1795+
* @return iterable<array{TypeNode, string}>
17961796
*/
17971797
public function dataPrintType(): iterable
17981798
{
@@ -1905,7 +1905,7 @@ public function testPrintType(TypeNode $node, string $expectedResult): void
19051905
}
19061906

19071907
/**
1908-
* @return iterable<list{PhpDocNode, string}>
1908+
* @return iterable<array{PhpDocNode, string}>
19091909
*/
19101910
public function dataPrintPhpDocNode(): iterable
19111911
{

0 commit comments

Comments
 (0)