From 438b833eb87ecc00a627686bd6b3d86441819249 Mon Sep 17 00:00:00 2001 From: Kirill Nesmeyanov Date: Sat, 28 Oct 2023 05:43:35 +0300 Subject: [PATCH] Add type definitions support --- src/NativeTypePrinter.php | 14 +++++++------- src/PrettyPrinter.php | 40 +++++++++++++++++++-------------------- src/Printer.php | 2 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/NativeTypePrinter.php b/src/NativeTypePrinter.php index 349eef8..629b37f 100644 --- a/src/NativeTypePrinter.php +++ b/src/NativeTypePrinter.php @@ -4,13 +4,13 @@ namespace TypeLang\Printer; -use TypeLang\Parser\Node\Type\CallableTypeNode; -use TypeLang\Parser\Node\Type\ClassConstMaskNode; -use TypeLang\Parser\Node\Type\ClassConstNode; -use TypeLang\Parser\Node\Type\ConstMaskNode; -use TypeLang\Parser\Node\Type\IntersectionTypeNode; -use TypeLang\Parser\Node\Type\NamedTypeNode; -use TypeLang\Parser\Node\Type\UnionTypeNode; +use TypeLang\Parser\Node\Stmt\CallableTypeNode; +use TypeLang\Parser\Node\Stmt\ClassConstMaskNode; +use TypeLang\Parser\Node\Stmt\ClassConstNode; +use TypeLang\Parser\Node\Stmt\ConstMaskNode; +use TypeLang\Parser\Node\Stmt\IntersectionTypeNode; +use TypeLang\Parser\Node\Stmt\NamedTypeNode; +use TypeLang\Parser\Node\Stmt\UnionTypeNode; final class NativeTypePrinter extends PrettyPrinter { diff --git a/src/PrettyPrinter.php b/src/PrettyPrinter.php index 54f622e..1962146 100644 --- a/src/PrettyPrinter.php +++ b/src/PrettyPrinter.php @@ -6,25 +6,25 @@ use TypeLang\Parser\Node\Node; use TypeLang\Parser\Node\Literal\LiteralNode; -use TypeLang\Parser\Node\Type\Callable\ArgumentNode; -use TypeLang\Parser\Node\Type\CallableTypeNode; -use TypeLang\Parser\Node\Type\ClassConstMaskNode; -use TypeLang\Parser\Node\Type\ClassConstNode; -use TypeLang\Parser\Node\Type\ConstMaskNode; -use TypeLang\Parser\Node\Type\IntersectionTypeNode; -use TypeLang\Parser\Node\Type\LogicalTypeNode; -use TypeLang\Parser\Node\Type\NamedTypeNode; -use TypeLang\Parser\Node\Type\NullableTypeNode; -use TypeLang\Parser\Node\Type\Shape\FieldNode; -use TypeLang\Parser\Node\Type\Shape\FieldsListNode; -use TypeLang\Parser\Node\Type\Shape\NamedFieldNode; -use TypeLang\Parser\Node\Type\Shape\NumericFieldNode; +use TypeLang\Parser\Node\Stmt\Callable\ArgumentNode; +use TypeLang\Parser\Node\Stmt\CallableTypeNode; +use TypeLang\Parser\Node\Stmt\ClassConstMaskNode; +use TypeLang\Parser\Node\Stmt\ClassConstNode; +use TypeLang\Parser\Node\Stmt\ConstMaskNode; +use TypeLang\Parser\Node\Stmt\IntersectionTypeNode; +use TypeLang\Parser\Node\Stmt\LogicalTypeNode; +use TypeLang\Parser\Node\Stmt\NamedTypeNode; +use TypeLang\Parser\Node\Stmt\NullableTypeNode; +use TypeLang\Parser\Node\Stmt\Shape\FieldNode; +use TypeLang\Parser\Node\Stmt\Shape\FieldsListNode; +use TypeLang\Parser\Node\Stmt\Shape\NamedFieldNode; +use TypeLang\Parser\Node\Stmt\Shape\NumericFieldNode; use TypeLang\Parser\Node\Statement; -use TypeLang\Parser\Node\Type\Shape\StringNamedFieldNode; -use TypeLang\Parser\Node\Type\Template\ParameterNode; -use TypeLang\Parser\Node\Type\Template\ParametersListNode; -use TypeLang\Parser\Node\Type\TypeStatement; -use TypeLang\Parser\Node\Type\UnionTypeNode; +use TypeLang\Parser\Node\Stmt\Shape\StringNamedFieldNode; +use TypeLang\Parser\Node\Stmt\Template\ArgumentNode; +use TypeLang\Parser\Node\Stmt\Template\ArgumentsListNode; +use TypeLang\Parser\Node\Stmt\TypeStatement; +use TypeLang\Parser\Node\Stmt\UnionTypeNode; use TypeLang\Parser\Traverser; use TypeLang\Printer\Exception\NonPrintableNodeException; @@ -312,7 +312,7 @@ protected function printNamedTypeNode(NamedTypeNode $node): string /** * @return non-empty-string */ - protected function printTemplateParametersNode(ParametersListNode $params): string + protected function printTemplateParametersNode(ArgumentsListNode $params): string { $result = []; @@ -327,7 +327,7 @@ protected function printTemplateParametersNode(ParametersListNode $params): stri /** * @return non-empty-string */ - protected function printTemplateParameterNode(ParameterNode $param): string + protected function printTemplateParameterNode(ArgumentNode $param): string { return $this->make($param->value); } diff --git a/src/Printer.php b/src/Printer.php index c3484f7..f50ac94 100644 --- a/src/Printer.php +++ b/src/Printer.php @@ -5,7 +5,7 @@ namespace TypeLang\Printer; use TypeLang\Parser\Node\Statement; -use TypeLang\Parser\Node\Type\LogicalTypeNode; +use TypeLang\Parser\Node\Stmt\LogicalTypeNode; abstract class Printer implements PrinterInterface {