Skip to content

Commit eb067bd

Browse files
author
Kirill Nesmeyanov
committed
Add support of offset access in native type printer
1 parent 415688f commit eb067bd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/NativeTypePrinter.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use TypeLang\Parser\Node\Stmt\IntersectionTypeNode;
1717
use TypeLang\Parser\Node\Stmt\NamedTypeNode;
1818
use TypeLang\Parser\Node\Stmt\TernaryConditionNode;
19+
use TypeLang\Parser\Node\Stmt\TypeOffsetAccessNode;
1920
use TypeLang\Parser\Node\Stmt\TypesListNode;
2021
use TypeLang\Parser\Node\Stmt\UnionTypeNode;
2122
use TypeLang\Printer\Exception\NonPrintableNodeException;
@@ -288,6 +289,14 @@ protected function printLiteralNode(LiteralNode $node): string
288289
return 'mixed';
289290
}
290291

291-
return parent::printLiteralNode($node);
292+
return \get_debug_type($node->getRawValue());
293+
}
294+
295+
#[\Override]
296+
protected function printTypeOffsetAccessNode(TypeOffsetAccessNode $node): string
297+
{
298+
// Getting an offset requires information about the data from which the
299+
// offset is needed. Therefore, we return a mixed type.
300+
return 'mixed';
292301
}
293302
}

0 commit comments

Comments
 (0)