Skip to content

Commit 35b60c2

Browse files
committed
Make ArrayShapeUnsealedTypeNode just a Node
1 parent 8a0bb94 commit 35b60c2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Ast/Type/ArrayShapeUnsealedTypeNode.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace PHPStan\PhpDocParser\Ast\Type;
44

5+
use PHPStan\PhpDocParser\Ast\Node;
56
use PHPStan\PhpDocParser\Ast\NodeAttributes;
67
use function sprintf;
78

8-
class ArrayShapeUnsealedTypeNode implements TypeNode
9+
class ArrayShapeUnsealedTypeNode implements Node
910
{
1011

1112
use NodeAttributes;

src/Printer/Printer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ function (PhpDocChildNode $child): string {
230230
$isOptional = $node->isOptional ? '=' : '';
231231
return trim("{$type}{$isReference}{$isVariadic}{$node->parameterName}") . $isOptional;
232232
}
233+
if ($node instanceof ArrayShapeUnsealedTypeNode) {
234+
if ($node->keyType !== null) {
235+
return sprintf('<%s, %s>', $this->printType($node->keyType), $this->printType($node->valueType));
236+
}
237+
return sprintf('<%s>', $this->printType($node->valueType));
238+
}
233239
if ($node instanceof DoctrineAnnotation) {
234240
return (string) $node;
235241
}
@@ -367,7 +373,7 @@ private function printType(TypeNode $node): string
367373
}, $node->items);
368374

369375
if (! $node->sealed) {
370-
$items[] = '...' . ($node->unsealedType === null ? '' : $this->printType($node->unsealedType));
376+
$items[] = '...' . ($node->unsealedType === null ? '' : $this->print($node->unsealedType));
371377
}
372378

373379
return $node->kind . '{' . implode(', ', $items) . '}';
@@ -384,12 +390,6 @@ private function printType(TypeNode $node): string
384390

385391
return $this->printType($node->valueType);
386392
}
387-
if ($node instanceof ArrayShapeUnsealedTypeNode) {
388-
if ($node->keyType !== null) {
389-
return sprintf('<%s, %s>', $this->printType($node->keyType), $this->printType($node->valueType));
390-
}
391-
return sprintf('<%s>', $this->printType($node->valueType));
392-
}
393393
if ($node instanceof ArrayTypeNode) {
394394
return $this->printOffsetAccessType($node->type) . '[]';
395395
}

0 commit comments

Comments
 (0)