Automattic\WooCommerce\Vendor\GraphQL\Language
Parser::parseValue
Given a string containing a Automattic\WooCommerce\Vendor\GraphQL value (ex. [42]), parse the AST for that value.
Throws Automattic\WooCommerce\Vendor\GraphQL\Error\SyntaxError if a syntax error is encountered.
This is useful within tools that operate upon Automattic\WooCommerce\Vendor\GraphQL Values directly and in isolation of complete Automattic\WooCommerce\Vendor\GraphQL documents.
Consider providing the results to the utility function: `Automattic\WooCommerce\Vendor\GraphQL\Utils[AST::valueFromAST()](/plugin/woocommerce/function/AST::valueFromAST).
Method of the class: Parser{}
No Hooks.
Returns
BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|NullValueNode|ObjectValueNode|StringValueNode|VariableNode.
Usage
$result = Parser::parseValue( $source, $options );
- $source(Source|string) (required)
- .
- $options(array)
- .
Default:[]
Parser::parseValue() Parser::parseValue code WC 11.0.1
public static function parseValue($source, array $options = [])
{
$parser = new Parser($source, $options);
$parser->expect(Token::SOF);
$value = $parser->parseValueLiteral(false);
$parser->expect(Token::EOF);
return $value;
}