diff --git a/src/NativeTypePrinter.php b/src/NativeTypePrinter.php index af2f1b8..baf1bcc 100644 --- a/src/NativeTypePrinter.php +++ b/src/NativeTypePrinter.php @@ -4,10 +4,8 @@ namespace TypeLang\Printer; -use TypeLang\Parser\Node\Literal\BoolLiteralNode; use TypeLang\Parser\Node\Literal\LiteralNode; use TypeLang\Parser\Node\Literal\VariableLiteralNode; -use TypeLang\Parser\Node\Statement; use TypeLang\Parser\Node\Stmt\CallableTypeNode; use TypeLang\Parser\Node\Stmt\ClassConstMaskNode; use TypeLang\Parser\Node\Stmt\ClassConstNode; @@ -19,7 +17,6 @@ use TypeLang\Parser\Node\Stmt\NamedTypeNode; use TypeLang\Parser\Node\Stmt\TernaryConditionNode; use TypeLang\Parser\Node\Stmt\TypesListNode; -use TypeLang\Parser\Node\Stmt\TypeStatement; use TypeLang\Parser\Node\Stmt\UnionTypeNode; use TypeLang\Printer\Exception\NonPrintableNodeException; @@ -116,6 +113,7 @@ public function __construct( /** * @api + * * @param non-empty-string $alias * @param non-empty-string $type */ @@ -126,6 +124,7 @@ public function addTypeAlias(string $alias, string $type): void /** * @api + * * @param non-empty-string $alias * @param non-empty-list $types */ @@ -138,6 +137,7 @@ public function addUnionTypeAlias(string $alias, array $types): void /** * @api + * * @param non-empty-string $alias * @param non-empty-list $types */ @@ -210,6 +210,7 @@ protected function printUnionTypeNode(UnionTypeNode $node): string * Replace "true" + "false" pair into "bool" * * @param list $result + * * @return list */ private function formatBoolWithTrueAndFalse(array $result): array @@ -234,6 +235,7 @@ private function formatBoolWithTrueAndFalse(array $result): array * if one of the types is "mixed". * * @param list $result + * * @return list */ private function formatUnionWithMixed(array $result): array diff --git a/src/PrettyPrinter.php b/src/PrettyPrinter.php index 5bf4f69..8383642 100644 --- a/src/PrettyPrinter.php +++ b/src/PrettyPrinter.php @@ -30,8 +30,8 @@ use TypeLang\Parser\Node\Stmt\Shape\NamedFieldNode; use TypeLang\Parser\Node\Stmt\Shape\NumericFieldNode; use TypeLang\Parser\Node\Stmt\Shape\StringNamedFieldNode; -use TypeLang\Parser\Node\Stmt\Template\TemplateArgumentNode as TemplateArgumentNode; -use TypeLang\Parser\Node\Stmt\Template\TemplateArgumentsListNode as TemplateArgumentsListNode; +use TypeLang\Parser\Node\Stmt\Template\TemplateArgumentNode; +use TypeLang\Parser\Node\Stmt\Template\TemplateArgumentsListNode; use TypeLang\Parser\Node\Stmt\TernaryConditionNode; use TypeLang\Parser\Node\Stmt\TypesListNode; use TypeLang\Parser\Node\Stmt\TypeStatement; @@ -335,7 +335,7 @@ protected function printClassConstNode(ClassConstNode $node): string { return \vsprintf('%s::%s', [ $node->class->toString(), - (string)$node->constant?->toString(), + (string) $node->constant?->toString(), ]); } @@ -346,7 +346,7 @@ protected function printClassConstMaskNode(ClassConstMaskNode $node): string { return \vsprintf('%s::%s', [ $node->class->toString(), - (string)$node->constant?->toString() . '*', + (string) $node->constant?->toString() . '*', ]); } @@ -440,7 +440,8 @@ protected function shouldWrapReturnType(TypeStatement $type): bool $visitor = Traverser::through( visitor: new Traverser\ClassNameMatcherVisitor( - class: LogicalTypeNode::class, break: static function (Node $node): bool { + class: LogicalTypeNode::class, + break: static function (Node $node): bool { // Break on non-empty template parameters. $isInTemplate = $node instanceof NamedTypeNode && $node->arguments !== null && $node->arguments->items !== [];