Printer
in package
Prints AST to string. Capable of printing Automattic\WooCommerce\Vendor\GraphQL queries and Type definition language.
Useful for pretty-printing queries or printing back AST for logging, documentation, etc.
Usage example:
$query = 'query myQuery {someField}';
$ast = Automattic\WooCommerce\Vendor\GraphQL\Language\Parser::parse($query);
$printed = Automattic\WooCommerce\Vendor\GraphQL\Language\Printer::doPrint($ast);
Tags
Table of Contents
- doPrint() : string
- Converts the AST of a Automattic\WooCommerce\Vendor\GraphQL node to a string.
- addDescription() : string
- indent() : string
- join() : string
- p() : string
- printList() : string
- printListBlock() : string
- Print each item on its own line, wrapped in an indented "{ }" block.
- wrap() : string
- If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
Methods
doPrint()
Converts the AST of a Automattic\WooCommerce\Vendor\GraphQL node to a string.
public
static doPrint(Node $ast) : string
Handles both executable definitions and schema definitions.
Parameters
- $ast : Node
Tags
Return values
string —addDescription()
protected
static addDescription(StringValueNode|null $description, string $body) : string
Parameters
- $description : StringValueNode|null
- $body : string
Tags
Return values
string —indent()
protected
static indent(string $string) : string
Parameters
- $string : string
Return values
string —join()
protected
static join(array<string|int, string|null> $parts[, string $separator = '' ]) : string
Parameters
- $parts : array<string|int, string|null>
- $separator : string = ''
Return values
string —p()
protected
static p(Node|null $node) : string
Parameters
- $node : Node|null
Tags
Return values
string —printList()
protected
static printList(NodeList<string|int, TNode> $list[, string $separator = '' ]) : string
Parameters
- $list : NodeList<string|int, TNode>
- $separator : string = ''
Tags
Return values
string —printListBlock()
Print each item on its own line, wrapped in an indented "{ }" block.
protected
static printListBlock(NodeList<string|int, TNode> $list) : string
Parameters
- $list : NodeList<string|int, TNode>
Tags
Return values
string —wrap()
If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
protected
static wrap(string $start, string|null $maybeString[, string $end = '' ]) : string
Parameters
- $start : string
- $maybeString : string|null
- $end : string = ''
