diff --git a/src/Language/Printer.php b/src/Language/Printer.php index 6e105d84a..884b51f6e 100644 --- a/src/Language/Printer.php +++ b/src/Language/Printer.php @@ -92,7 +92,7 @@ public function printAST(Node $node): string } /** @throws \JsonException */ - protected function p(?Node $node, bool $isDescription = false): string + protected function p(?Node $node): string { if ($node === null) { return ''; @@ -100,6 +100,7 @@ protected function p(?Node $node, bool $isDescription = false): string switch (true) { case $node instanceof ArgumentNode: + case $node instanceof ObjectFieldNode: return $this->p($node->name) . ': ' . $this->p($node->value); case $node instanceof BooleanValueNode: @@ -166,6 +167,9 @@ protected function p(?Node $node, bool $isDescription = false): string ); case $node instanceof EnumValueNode: + case $node instanceof FloatValueNode: + case $node instanceof IntValueNode: + case $node instanceof NameNode: return $node->value; case $node instanceof FieldDefinitionNode: @@ -219,9 +223,6 @@ protected function p(?Node $node, bool $isDescription = false): string ' ' ); - case $node instanceof FloatValueNode: - return $node->value; - case $node instanceof FragmentDefinitionNode: // Note: fragment variable definitions are experimental and may be changed or removed in the future. return 'fragment ' . $this->p($node->name) @@ -310,18 +311,12 @@ protected function p(?Node $node, bool $isDescription = false): string ' ' ); - case $node instanceof IntValueNode: - return $node->value; - case $node instanceof ListTypeNode: return '[' . $this->p($node->type) . ']'; case $node instanceof ListValueNode: return '[' . $this->printList($node->values, ', ') . ']'; - case $node instanceof NameNode: - return $node->value; - case $node instanceof NamedTypeNode: return $this->p($node->name); @@ -331,9 +326,6 @@ protected function p(?Node $node, bool $isDescription = false): string case $node instanceof NullValueNode: return 'null'; - case $node instanceof ObjectFieldNode: - return $this->p($node->name) . ': ' . $this->p($node->value); - case $node instanceof ObjectTypeDefinitionNode: return $this->addDescription($node->description, $this->join( [ @@ -511,7 +503,7 @@ protected function printListBlock(NodeList $list): string /** @throws \JsonException */ protected function addDescription(?StringValueNode $description, string $body): string { - return $this->join([$this->p($description, true), $body], "\n"); + return $this->join([$this->p($description), $body], "\n"); } /** diff --git a/tests/Type/EnumTypeTest.php b/tests/Type/EnumTypeTest.php index 87fb59537..7e24a9c4d 100644 --- a/tests/Type/EnumTypeTest.php +++ b/tests/Type/EnumTypeTest.php @@ -198,7 +198,10 @@ public function setUp(): void } if ($args['provideTwo'] ?? false) { - return ['two', 'TWO']; + return [ + 'two', + 'TWO', + ]; } return $args['fromEnum'];