Skip to content

Commit 536451b

Browse files
committed
Fix Printer
1 parent c3180bf commit 536451b

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/Printer/Printer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ final class Printer
141141
CallableTypeNode::class,
142142
UnionTypeNode::class,
143143
IntersectionTypeNode::class,
144-
ConstTypeNode::class,
145144
NullableTypeNode::class,
146145
],
147146
];
@@ -512,7 +511,6 @@ private function printOffsetAccessType(TypeNode $type): string
512511
$type instanceof CallableTypeNode
513512
|| $type instanceof UnionTypeNode
514513
|| $type instanceof IntersectionTypeNode
515-
|| $type instanceof ConstTypeNode
516514
|| $type instanceof NullableTypeNode
517515
) {
518516
return $this->wrapInParentheses($type);

tests/PHPStan/Printer/PrinterTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,23 @@ public function enterNode(Node $node)
17231723

17241724
},
17251725
];
1726+
1727+
yield [
1728+
'/** @return Foo[abc] */',
1729+
'/** @return self::FOO[abc] */',
1730+
new class extends AbstractNodeVisitor {
1731+
1732+
public function enterNode(Node $node)
1733+
{
1734+
if ($node instanceof ReturnTagValueNode && $node->type instanceof OffsetAccessTypeNode) {
1735+
$node->type->type = new ConstTypeNode(new ConstFetchNode('self', 'FOO'));
1736+
}
1737+
1738+
return $node;
1739+
}
1740+
1741+
},
1742+
];
17261743
}
17271744

17281745
/**
@@ -1862,6 +1879,13 @@ public function dataPrintType(): iterable
18621879
]),
18631880
'Foo|Bar|(Baz|Lorem)',
18641881
];
1882+
yield [
1883+
new OffsetAccessTypeNode(
1884+
new ConstTypeNode(new ConstFetchNode('self', 'TYPES')),
1885+
new IdentifierTypeNode('int')
1886+
),
1887+
'self::TYPES[int]',
1888+
];
18651889
}
18661890

18671891
/**

0 commit comments

Comments
 (0)