Skip to content

Commit

Permalink
Apply phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Sep 26, 2024
1 parent e9d8431 commit 9f6d34e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/NativeTypePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -116,6 +113,7 @@ public function __construct(

/**
* @api
*
* @param non-empty-string $alias
* @param non-empty-string $type
*/
Expand All @@ -126,6 +124,7 @@ public function addTypeAlias(string $alias, string $type): void

/**
* @api
*
* @param non-empty-string $alias
* @param non-empty-list<non-empty-string> $types
*/
Expand All @@ -138,6 +137,7 @@ public function addUnionTypeAlias(string $alias, array $types): void

/**
* @api
*
* @param non-empty-string $alias
* @param non-empty-list<non-empty-string> $types
*/
Expand Down Expand Up @@ -210,6 +210,7 @@ protected function printUnionTypeNode(UnionTypeNode $node): string
* Replace "true" + "false" pair into "bool"
*
* @param list<non-empty-string> $result
*
* @return list<non-empty-string>
*/
private function formatBoolWithTrueAndFalse(array $result): array
Expand All @@ -234,6 +235,7 @@ private function formatBoolWithTrueAndFalse(array $result): array
* if one of the types is "mixed".
*
* @param list<non-empty-string> $result
*
* @return list<non-empty-string>
*/
private function formatUnionWithMixed(array $result): array
Expand Down
11 changes: 6 additions & 5 deletions src/PrettyPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
]);
}

Expand All @@ -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() . '*',
]);
}

Expand Down Expand Up @@ -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 !== [];

Expand Down

0 comments on commit 9f6d34e

Please sign in to comment.