|
26 | 26 | use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
|
27 | 27 | use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
|
28 | 28 | use PHPStan\PhpDocParser\Ast\PhpDoc\TypeAliasImportTagValueNode;
|
| 29 | +use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; |
29 | 30 | use PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode;
|
30 | 31 | use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode;
|
31 | 32 | use PHPStan\PhpDocParser\Ast\Type\ArrayShapeUnsealedTypeNode;
|
@@ -2064,4 +2065,24 @@ public function testPrintPhpDocNode(PhpDocNode $node, string $expectedResult): v
|
2064 | 2065 | );
|
2065 | 2066 | }
|
2066 | 2067 |
|
| 2068 | + public function testMaybePrintQuoted(): void |
| 2069 | + { |
| 2070 | + $input = "array{states: array{'Hello World': int}, object{key: string, 'Other Key': int}}"; |
| 2071 | + $expected = "array{states: array{'Hello World': int}, object{key: string, 'Other Key': int}}"; |
| 2072 | + $lexer = new Lexer(); |
| 2073 | + $constExprParser = new ConstExprParser(true, true); |
| 2074 | + $typeParser = new TypeParser($constExprParser); |
| 2075 | + $phpDocParser = new PhpDocParser($typeParser, $constExprParser); |
| 2076 | + |
| 2077 | + $tokens = new TokenIterator($lexer->tokenize($input)); |
| 2078 | + $phpDocNode = $phpDocParser->parseTagValue($tokens, '@var'); |
| 2079 | + |
| 2080 | + $this->assertInstanceOf(VarTagValueNode::class, $phpDocNode); |
| 2081 | + $this->assertInstanceOf(ArrayShapeNode::class, $phpDocNode->type); |
| 2082 | + |
| 2083 | + $printer = new Printer(); |
| 2084 | + $printed = $printer->print($phpDocNode); |
| 2085 | + $this->assertSame($expected, $printed); |
| 2086 | + } |
| 2087 | + |
2067 | 2088 | }
|
0 commit comments