Skip to content

Commit dbff0db

Browse files
committed
Apply rector, simplifying Printer
1 parent 41ea3fc commit dbff0db

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/Language/Printer.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,15 @@ public function printAST(Node $node): string
9292
}
9393

9494
/** @throws \JsonException */
95-
protected function p(?Node $node, bool $isDescription = false): string
95+
protected function p(?Node $node): string
9696
{
9797
if ($node === null) {
9898
return '';
9999
}
100100

101101
switch (true) {
102102
case $node instanceof ArgumentNode:
103+
case $node instanceof ObjectFieldNode:
103104
return $this->p($node->name) . ': ' . $this->p($node->value);
104105

105106
case $node instanceof BooleanValueNode:
@@ -166,6 +167,9 @@ protected function p(?Node $node, bool $isDescription = false): string
166167
);
167168

168169
case $node instanceof EnumValueNode:
170+
case $node instanceof FloatValueNode:
171+
case $node instanceof IntValueNode:
172+
case $node instanceof NameNode:
169173
return $node->value;
170174

171175
case $node instanceof FieldDefinitionNode:
@@ -219,9 +223,6 @@ protected function p(?Node $node, bool $isDescription = false): string
219223
' '
220224
);
221225

222-
case $node instanceof FloatValueNode:
223-
return $node->value;
224-
225226
case $node instanceof FragmentDefinitionNode:
226227
// Note: fragment variable definitions are experimental and may be changed or removed in the future.
227228
return 'fragment ' . $this->p($node->name)
@@ -310,18 +311,12 @@ protected function p(?Node $node, bool $isDescription = false): string
310311
' '
311312
);
312313

313-
case $node instanceof IntValueNode:
314-
return $node->value;
315-
316314
case $node instanceof ListTypeNode:
317315
return '[' . $this->p($node->type) . ']';
318316

319317
case $node instanceof ListValueNode:
320318
return '[' . $this->printList($node->values, ', ') . ']';
321319

322-
case $node instanceof NameNode:
323-
return $node->value;
324-
325320
case $node instanceof NamedTypeNode:
326321
return $this->p($node->name);
327322

@@ -331,9 +326,6 @@ protected function p(?Node $node, bool $isDescription = false): string
331326
case $node instanceof NullValueNode:
332327
return 'null';
333328

334-
case $node instanceof ObjectFieldNode:
335-
return $this->p($node->name) . ': ' . $this->p($node->value);
336-
337329
case $node instanceof ObjectTypeDefinitionNode:
338330
return $this->addDescription($node->description, $this->join(
339331
[
@@ -511,7 +503,7 @@ protected function printListBlock(NodeList $list): string
511503
/** @throws \JsonException */
512504
protected function addDescription(?StringValueNode $description, string $body): string
513505
{
514-
return $this->join([$this->p($description, true), $body], "\n");
506+
return $this->join([$this->p($description), $body], "\n");
515507
}
516508

517509
/**

tests/Type/EnumTypeTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ public function setUp(): void
198198
}
199199

200200
if ($args['provideTwo'] ?? false) {
201-
return ['two', 'TWO'];
201+
return [
202+
'two',
203+
'TWO',
204+
];
202205
}
203206

204207
return $args['fromEnum'];

0 commit comments

Comments
 (0)