Renamed AST nodes to *Node to disambiguate types

This commit is contained in:
vladar 2016-11-19 06:12:18 +07:00
parent 5ce9a7009a
commit 8d696edee5
109 changed files with 803 additions and 821 deletions

View File

@ -28,7 +28,7 @@ Description of method arguments:
Argument | Type | Notes Argument | Type | Notes
------------ | -------- | ----- ------------ | -------- | -----
schema | `GraphQL\Schema` | **Required.** Instance of your application [Schema](type-system/schema/) schema | `GraphQL\Schema` | **Required.** Instance of your application [Schema](type-system/schema/)
queryString | `string` or `GraphQL\Language\AST\Document` | **Required.** Actual GraphQL query string to be parsed, validated and executed. If you parse query elsewhere before executing - pass corresponding ast document here to avoid new parsing. queryString | `string` or `GraphQL\Language\AST\DocumentNode` | **Required.** Actual GraphQL query string to be parsed, validated and executed. If you parse query elsewhere before executing - pass corresponding ast document here to avoid new parsing.
rootValue | `mixed` | Any value that represents a root of your data graph. It is passed as 1st argument to field resolvers of [Query type](type-system/schema/#query-and-mutation-types). Can be omitted or set to null if actual root values are fetched by Query type itself. rootValue | `mixed` | Any value that represents a root of your data graph. It is passed as 1st argument to field resolvers of [Query type](type-system/schema/#query-and-mutation-types). Can be omitted or set to null if actual root values are fetched by Query type itself.
contextValue | `mixed` | Any value that holds information shared between all field resolvers. Most often they use it to pass currently logged in user, locale details, etc.<br><br>It will be available as 3rd argument in all field resolvers. (see section on [Field Definitions](type-system/object-types/#field-configuration-options) for reference) **graphql-php** never modifies this value and passes it *as is* to all underlying resolvers. contextValue | `mixed` | Any value that holds information shared between all field resolvers. Most often they use it to pass currently logged in user, locale details, etc.<br><br>It will be available as 3rd argument in all field resolvers. (see section on [Field Definitions](type-system/object-types/#field-configuration-options) for reference) **graphql-php** never modifies this value and passes it *as is* to all underlying resolvers.
variableValues | `array` | Map of variable values passed along with query string. See section on [query variables on official GraphQL website](http://graphql.org/learn/queries/#variables) variableValues | `array` | Map of variable values passed along with query string. See section on [query variables on official GraphQL website](http://graphql.org/learn/queries/#variables)

View File

@ -42,7 +42,7 @@ Here is an example of simple `Email` type (using inheritance):
namespace MyApp; namespace MyApp;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\StringValue; use GraphQL\Language\AST\StringValueNode;
use GraphQL\Type\Definition\ScalarType; use GraphQL\Type\Definition\ScalarType;
use GraphQL\Utils; use GraphQL\Utils;
@ -98,7 +98,7 @@ class EmailType extends ScalarType
{ {
// Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL // Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL
// error location in query: // error location in query:
if (!$valueAST instanceof StringValue) { if (!$valueAST instanceof StringValueNode) {
throw new Error('Query error: Can only parse strings got: ' . $valueAST->kind, [$valueAST]); throw new Error('Query error: Can only parse strings got: ' . $valueAST->kind, [$valueAST]);
} }
if (!filter_var($valueAST->value, FILTER_VALIDATE_EMAIL)) { if (!filter_var($valueAST->value, FILTER_VALIDATE_EMAIL)) {

View File

@ -3,7 +3,7 @@ namespace GraphQL\Examples\Blog\Type\Scalar;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Examples\Blog\Type\BaseType; use GraphQL\Examples\Blog\Type\BaseType;
use GraphQL\Language\AST\StringValue; use GraphQL\Language\AST\StringValueNode;
use GraphQL\Type\Definition\CustomScalarType; use GraphQL\Type\Definition\CustomScalarType;
use GraphQL\Utils; use GraphQL\Utils;
@ -61,7 +61,7 @@ class EmailType extends BaseType
{ {
// Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL // Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL
// error location in query: // error location in query:
if (!$valueAST instanceof StringValue) { if (!$valueAST instanceof StringValueNode) {
throw new Error('Query error: Can only parse strings got: ' . $valueAST->kind, [$valueAST]); throw new Error('Query error: Can only parse strings got: ' . $valueAST->kind, [$valueAST]);
} }
if (!filter_var($valueAST->value, FILTER_VALIDATE_EMAIL)) { if (!filter_var($valueAST->value, FILTER_VALIDATE_EMAIL)) {

View File

@ -3,7 +3,7 @@ namespace GraphQL\Examples\Blog\Type\Scalar;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\StringValue; use GraphQL\Language\AST\StringValueNode;
use GraphQL\Type\Definition\ScalarType; use GraphQL\Type\Definition\ScalarType;
use GraphQL\Utils; use GraphQL\Utils;
@ -52,7 +52,7 @@ class UrlType extends ScalarType
{ {
// Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL // Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL
// error location in query: // error location in query:
if (!($ast instanceof StringValue)) { if (!($ast instanceof StringValueNode)) {
throw new Error('Query error: Can only parse strings got: ' . $ast->kind, [$ast]); throw new Error('Query error: Can only parse strings got: ' . $ast->kind, [$ast]);
} }
if (!is_string($ast->value) || !filter_var($ast->value, FILTER_VALIDATE_URL)) { if (!is_string($ast->value) || !filter_var($ast->value, FILTER_VALIDATE_URL)) {

View File

@ -2,7 +2,7 @@
namespace GraphQL\Executor; namespace GraphQL\Executor;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Schema; use GraphQL\Schema;
/** /**
@ -19,7 +19,7 @@ class ExecutionContext
public $schema; public $schema;
/** /**
* @var array<string, FragmentDefinition> * @var array<string, FragmentDefinitionNode>
*/ */
public $fragments; public $fragments;
@ -34,7 +34,7 @@ class ExecutionContext
public $contextValue; public $contextValue;
/** /**
* @var OperationDefinition * @var OperationDefinitionNode
*/ */
public $operation; public $operation;

View File

@ -3,13 +3,13 @@ namespace GraphQL\Executor;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation; use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\Document; use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\AST\SelectionSet; use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Schema; use GraphQL\Schema;
use GraphQL\Type\Definition\AbstractType; use GraphQL\Type\Definition\AbstractType;
use GraphQL\Type\Definition\Directive; use GraphQL\Type\Definition\Directive;
@ -62,14 +62,14 @@ class Executor
/** /**
* @param Schema $schema * @param Schema $schema
* @param Document $ast * @param DocumentNode $ast
* @param $rootValue * @param $rootValue
* @param $contextValue * @param $contextValue
* @param array|\ArrayAccess $variableValues * @param array|\ArrayAccess $variableValues
* @param null $operationName * @param null $operationName
* @return ExecutionResult * @return ExecutionResult
*/ */
public static function execute(Schema $schema, Document $ast, $rootValue = null, $contextValue = null, $variableValues = null, $operationName = null) public static function execute(Schema $schema, DocumentNode $ast, $rootValue = null, $contextValue = null, $variableValues = null, $operationName = null)
{ {
if (!self::$UNDEFINED) { if (!self::$UNDEFINED) {
self::$UNDEFINED = new \stdClass(); self::$UNDEFINED = new \stdClass();
@ -106,7 +106,7 @@ class Executor
*/ */
private static function buildExecutionContext( private static function buildExecutionContext(
Schema $schema, Schema $schema,
Document $documentAst, DocumentNode $documentAst,
$rootValue, $rootValue,
$contextValue, $contextValue,
$rawVariableValues, $rawVariableValues,
@ -162,7 +162,7 @@ class Executor
/** /**
* Implements the "Evaluating operations" section of the spec. * Implements the "Evaluating operations" section of the spec.
*/ */
private static function executeOperation(ExecutionContext $exeContext, OperationDefinition $operation, $rootValue) private static function executeOperation(ExecutionContext $exeContext, OperationDefinitionNode $operation, $rootValue)
{ {
$type = self::getOperationRootType($exeContext->schema, $operation); $type = self::getOperationRootType($exeContext->schema, $operation);
$fields = self::collectFields($exeContext, $type, $operation->selectionSet, new \ArrayObject(), new \ArrayObject()); $fields = self::collectFields($exeContext, $type, $operation->selectionSet, new \ArrayObject(), new \ArrayObject());
@ -180,11 +180,11 @@ class Executor
* Extracts the root type of the operation from the schema. * Extracts the root type of the operation from the schema.
* *
* @param Schema $schema * @param Schema $schema
* @param OperationDefinition $operation * @param OperationDefinitionNode $operation
* @return ObjectType * @return ObjectType
* @throws Error * @throws Error
*/ */
private static function getOperationRootType(Schema $schema, OperationDefinition $operation) private static function getOperationRootType(Schema $schema, OperationDefinitionNode $operation)
{ {
switch ($operation->operation) { switch ($operation->operation) {
case 'query': case 'query':
@ -264,7 +264,7 @@ class Executor
private static function collectFields( private static function collectFields(
ExecutionContext $exeContext, ExecutionContext $exeContext,
ObjectType $runtimeType, ObjectType $runtimeType,
SelectionSet $selectionSet, SelectionSetNode $selectionSet,
$fields, $fields,
$visitedFragmentNames $visitedFragmentNames
) )
@ -302,7 +302,7 @@ class Executor
} }
$visitedFragmentNames[$fragName] = true; $visitedFragmentNames[$fragName] = true;
/** @var FragmentDefinition|null $fragment */ /** @var FragmentDefinitionNode|null $fragment */
$fragment = isset($exeContext->fragments[$fragName]) ? $exeContext->fragments[$fragName] : null; $fragment = isset($exeContext->fragments[$fragName]) ? $exeContext->fragments[$fragName] : null;
if (!$fragment || !self::doesFragmentConditionMatch($exeContext, $fragment, $runtimeType)) { if (!$fragment || !self::doesFragmentConditionMatch($exeContext, $fragment, $runtimeType)) {
continue; continue;
@ -329,9 +329,9 @@ class Executor
$skipDirective = Directive::skipDirective(); $skipDirective = Directive::skipDirective();
$includeDirective = Directive::includeDirective(); $includeDirective = Directive::includeDirective();
/** @var \GraphQL\Language\AST\Directive $skipAST */ /** @var \GraphQL\Language\AST\DirectiveNode $skipAST */
$skipAST = $directives $skipAST = $directives
? Utils::find($directives, function(\GraphQL\Language\AST\Directive $directive) use ($skipDirective) { ? Utils::find($directives, function(\GraphQL\Language\AST\DirectiveNode $directive) use ($skipDirective) {
return $directive->name->value === $skipDirective->name; return $directive->name->value === $skipDirective->name;
}) })
: null; : null;
@ -343,9 +343,9 @@ class Executor
} }
} }
/** @var \GraphQL\Language\AST\Directive $includeAST */ /** @var \GraphQL\Language\AST\DirectiveNode $includeAST */
$includeAST = $directives $includeAST = $directives
? Utils::find($directives, function(\GraphQL\Language\AST\Directive $directive) use ($includeDirective) { ? Utils::find($directives, function(\GraphQL\Language\AST\DirectiveNode $directive) use ($includeDirective) {
return $directive->name->value === $includeDirective->name; return $directive->name->value === $includeDirective->name;
}) })
: null; : null;
@ -363,7 +363,7 @@ class Executor
/** /**
* Determines if a fragment is applicable to the given type. * Determines if a fragment is applicable to the given type.
*/ */
private static function doesFragmentConditionMatch(ExecutionContext $exeContext,/* FragmentDefinition | InlineFragment*/ $fragment, ObjectType $type) private static function doesFragmentConditionMatch(ExecutionContext $exeContext,/* FragmentDefinitionNode | InlineFragmentNode*/ $fragment, ObjectType $type)
{ {
$typeConditionAST = $fragment->typeCondition; $typeConditionAST = $fragment->typeCondition;
@ -384,7 +384,7 @@ class Executor
/** /**
* Implements the logic to compute the key of a given fields entry * Implements the logic to compute the key of a given fields entry
*/ */
private static function getFieldEntryKey(Field $node) private static function getFieldEntryKey(FieldNode $node)
{ {
return $node->alias ? $node->alias->value : $node->name->value; return $node->alias ? $node->alias->value : $node->name->value;
} }
@ -468,7 +468,7 @@ class Executor
* *
* @param ExecutionContext $exeContext * @param ExecutionContext $exeContext
* @param FieldDefinition $fieldDef * @param FieldDefinition $fieldDef
* @param Field $fieldAST * @param FieldNode $fieldAST
* @param callable $resolveFn * @param callable $resolveFn
* @param mixed $source * @param mixed $source
* @param mixed $context * @param mixed $context
@ -605,7 +605,7 @@ class Executor
* *
* @param ExecutionContext $exeContext * @param ExecutionContext $exeContext
* @param Type $returnType * @param Type $returnType
* @param Field[] $fieldASTs * @param FieldNode[] $fieldASTs
* @param ResolveInfo $info * @param ResolveInfo $info
* @param array $path * @param array $path
* @param $result * @param $result

View File

@ -4,12 +4,12 @@ namespace GraphQL\Executor;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation; use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\Argument; use GraphQL\Language\AST\ArgumentNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\NullValue; use GraphQL\Language\AST\NullValueNode;
use GraphQL\Language\AST\Value; use GraphQL\Language\AST\ValueNode;
use GraphQL\Language\AST\Variable; use GraphQL\Language\AST\VariableNode;
use GraphQL\Language\AST\VariableDefinition; use GraphQL\Language\AST\VariableDefinitionNode;
use GraphQL\Language\Printer; use GraphQL\Language\Printer;
use GraphQL\Schema; use GraphQL\Schema;
use GraphQL\Type\Definition\Directive; use GraphQL\Type\Definition\Directive;
@ -32,7 +32,7 @@ class Values
* to match the variable definitions, a Error will be thrown. * to match the variable definitions, a Error will be thrown.
* *
* @param Schema $schema * @param Schema $schema
* @param VariableDefinition[] $definitionASTs * @param VariableDefinitionNode[] $definitionASTs
* @param array $inputs * @param array $inputs
* @return array * @return array
* @throws Error * @throws Error
@ -89,7 +89,7 @@ class Values
* definitions and list of argument AST nodes. * definitions and list of argument AST nodes.
* *
* @param FieldDefinition|Directive $def * @param FieldDefinition|Directive $def
* @param Field|\GraphQL\Language\AST\Directive $node * @param FieldNode|\GraphQL\Language\AST\DirectiveNode $node
* @param $variableValues * @param $variableValues
* @return array * @return array
* @throws Error * @throws Error
@ -106,8 +106,8 @@ class Values
$coercedValues = []; $coercedValues = [];
$undefined = Utils::undefined(); $undefined = Utils::undefined();
/** @var Argument[] $argASTMap */ /** @var ArgumentNode[] $argASTMap */
$argASTMap = $argASTs ? Utils::keyMap($argASTs, function (Argument $arg) { $argASTMap = $argASTs ? Utils::keyMap($argASTs, function (ArgumentNode $arg) {
return $arg->name->value; return $arg->name->value;
}) : []; }) : [];
@ -126,7 +126,7 @@ class Values
[$node] [$node]
); );
} }
} else if ($argumentAST->value instanceof Variable) { } else if ($argumentAST->value instanceof VariableNode) {
$variableName = $argumentAST->value->name->value; $variableName = $argumentAST->value->name->value;
if ($variableValues && array_key_exists($variableName, $variableValues)) { if ($variableValues && array_key_exists($variableName, $variableValues)) {

View File

@ -4,7 +4,7 @@ namespace GraphQL;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Executor\ExecutionResult; use GraphQL\Executor\ExecutionResult;
use GraphQL\Executor\Executor; use GraphQL\Executor\Executor;
use GraphQL\Language\AST\Document; use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\Parser; use GraphQL\Language\Parser;
use GraphQL\Language\Source; use GraphQL\Language\Source;
use GraphQL\Type\Definition\Directive; use GraphQL\Type\Definition\Directive;
@ -37,7 +37,7 @@ class GraphQL
public static function executeAndReturnResult(Schema $schema, $requestString, $rootValue = null, $contextValue = null, $variableValues = null, $operationName = null) public static function executeAndReturnResult(Schema $schema, $requestString, $rootValue = null, $contextValue = null, $variableValues = null, $operationName = null)
{ {
try { try {
if ($requestString instanceof Document) { if ($requestString instanceof DocumentNode) {
$documentAST = $requestString; $documentAST = $requestString;
} else { } else {
$source = new Source($requestString ?: '', 'GraphQL request'); $source = new Source($requestString ?: '', 'GraphQL request');

View File

@ -1,17 +1,17 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class Argument extends Node class ArgumentNode extends Node
{ {
public $kind = NodeType::ARGUMENT; public $kind = NodeType::ARGUMENT;
/** /**
* @var Value * @var ValueNode
*/ */
public $value; public $value;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
} }

View File

@ -2,7 +2,7 @@
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class BooleanValue extends Node implements Value class BooleanValueNode extends Node implements ValueNode
{ {
public $kind = NodeType::BOOLEAN; public $kind = NodeType::BOOLEAN;

View File

@ -1,11 +0,0 @@
<?php
namespace GraphQL\Language\AST;
interface Definition
{
/**
* export type Definition = OperationDefinition
* | FragmentDefinition
* | TypeSystemDefinition // experimental non-spec addition.
*/
}

View File

@ -0,0 +1,11 @@
<?php
namespace GraphQL\Language\AST;
interface DefinitionNode
{
/**
* export type DefinitionNode = OperationDefinitionNode
* | FragmentDefinitionNode
* | TypeSystemDefinitionNode // experimental non-spec addition.
*/
}

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class DirectiveDefinition extends Node implements TypeSystemDefinition class DirectiveDefinitionNode extends Node implements TypeSystemDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,17 +9,17 @@ class DirectiveDefinition extends Node implements TypeSystemDefinition
public $kind = NodeType::DIRECTIVE_DEFINITION; public $kind = NodeType::DIRECTIVE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Argument[] * @var ArgumentNode[]
*/ */
public $arguments; public $arguments;
/** /**
* @var Name[] * @var NameNode[]
*/ */
public $locations; public $locations;
} }

View File

@ -1,17 +1,17 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class Directive extends Node class DirectiveNode extends Node
{ {
public $kind = NodeType::DIRECTIVE; public $kind = NodeType::DIRECTIVE;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Argument[] * @var ArgumentNode[]
*/ */
public $arguments; public $arguments;
} }

View File

@ -1,12 +1,12 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class Document extends Node class DocumentNode extends Node
{ {
public $kind = NodeType::DOCUMENT; public $kind = NodeType::DOCUMENT;
/** /**
* @var Definition[] * @var DefinitionNode[]
*/ */
public $definitions; public $definitions;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class EnumTypeDefinition extends Node implements TypeDefinition class EnumTypeDefinitionNode extends Node implements TypeDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,17 +9,17 @@ class EnumTypeDefinition extends Node implements TypeDefinition
public $kind = NodeType::ENUM_TYPE_DEFINITION; public $kind = NodeType::ENUM_TYPE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
/** /**
* @var EnumValueDefinition[] * @var EnumValueDefinitionNode[]
*/ */
public $values; public $values;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class EnumValueDefinition extends Node class EnumValueDefinitionNode extends Node
{ {
/** /**
* @var string * @var string
@ -9,12 +9,12 @@ class EnumValueDefinition extends Node
public $kind = NodeType::ENUM_VALUE_DEFINITION; public $kind = NodeType::ENUM_VALUE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class EnumValue extends Node implements Value class EnumValueNode extends Node implements ValueNode
{ {
public $kind = NodeType::ENUM; public $kind = NodeType::ENUM;

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class FieldDefinition extends Node class FieldDefinitionNode extends Node
{ {
/** /**
* @var string * @var string
@ -9,22 +9,22 @@ class FieldDefinition extends Node
public $kind = NodeType::FIELD_DEFINITION; public $kind = NodeType::FIELD_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var InputValueDefinition[] * @var InputValueDefinitionNode[]
*/ */
public $arguments; public $arguments;
/** /**
* @var Type * @var TypeNode
*/ */
public $type; public $type;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
} }

View File

@ -1,32 +1,32 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class Field extends Node implements Selection class FieldNode extends Node implements SelectionNode
{ {
public $kind = NodeType::FIELD; public $kind = NodeType::FIELD;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Name|null * @var NameNode|null
*/ */
public $alias; public $alias;
/** /**
* @var array<Argument>|null * @var array<ArgumentNode>|null
*/ */
public $arguments; public $arguments;
/** /**
* @var array<Directive>|null * @var array<DirectiveNode>|null
*/ */
public $directives; public $directives;
/** /**
* @var SelectionSet|null * @var SelectionSetNode|null
*/ */
public $selectionSet; public $selectionSet;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class FloatValue extends Node implements Value class FloatValueNode extends Node implements ValueNode
{ {
public $kind = NodeType::FLOAT; public $kind = NodeType::FLOAT;

View File

@ -1,27 +1,27 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class FragmentDefinition extends Node implements Definition, HasSelectionSet class FragmentDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
{ {
public $kind = NodeType::FRAGMENT_DEFINITION; public $kind = NodeType::FRAGMENT_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var NamedType * @var NamedTypeNode
*/ */
public $typeCondition; public $typeCondition;
/** /**
* @var array<Directive> * @var array<DirectiveNode>
*/ */
public $directives; public $directives;
/** /**
* @var SelectionSet * @var SelectionSetNode
*/ */
public $selectionSet; public $selectionSet;
} }

View File

@ -1,17 +1,17 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class FragmentSpread extends Node implements Selection class FragmentSpreadNode extends Node implements SelectionNode
{ {
public $kind = NodeType::FRAGMENT_SPREAD; public $kind = NodeType::FRAGMENT_SPREAD;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var array<Directive> * @var array<DirectiveNode>
*/ */
public $directives; public $directives;
} }

View File

@ -4,7 +4,7 @@ namespace GraphQL\Language\AST;
interface HasSelectionSet interface HasSelectionSet
{ {
/** /**
* export type Definition = OperationDefinition * export type DefinitionNode = OperationDefinitionNode
* | FragmentDefinition * | FragmentDefinitionNode
*/ */
} }

View File

@ -1,22 +1,22 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class InlineFragment extends Node implements Selection class InlineFragmentNode extends Node implements SelectionNode
{ {
public $kind = NodeType::INLINE_FRAGMENT; public $kind = NodeType::INLINE_FRAGMENT;
/** /**
* @var NamedType * @var NamedTypeNode
*/ */
public $typeCondition; public $typeCondition;
/** /**
* @var array<Directive>|null * @var array<DirectiveNode>|null
*/ */
public $directives; public $directives;
/** /**
* @var SelectionSet * @var SelectionSetNode
*/ */
public $selectionSet; public $selectionSet;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class InputObjectTypeDefinition extends Node implements TypeDefinition class InputObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,17 +9,17 @@ class InputObjectTypeDefinition extends Node implements TypeDefinition
public $kind = NodeType::INPUT_OBJECT_TYPE_DEFINITION; public $kind = NodeType::INPUT_OBJECT_TYPE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
/** /**
* @var InputValueDefinition[] * @var InputValueDefinitionNode[]
*/ */
public $fields; public $fields;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class InputValueDefinition extends Node class InputValueDefinitionNode extends Node
{ {
/** /**
* @var string * @var string
@ -9,22 +9,22 @@ class InputValueDefinition extends Node
public $kind = NodeType::INPUT_VALUE_DEFINITION; public $kind = NodeType::INPUT_VALUE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Type * @var TypeNode
*/ */
public $type; public $type;
/** /**
* @var Value * @var ValueNode
*/ */
public $defaultValue; public $defaultValue;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class IntValue extends Node implements Value class IntValueNode extends Node implements ValueNode
{ {
public $kind = NodeType::INT; public $kind = NodeType::INT;

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class InterfaceTypeDefinition extends Node implements TypeDefinition class InterfaceTypeDefinitionNode extends Node implements TypeDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,17 +9,17 @@ class InterfaceTypeDefinition extends Node implements TypeDefinition
public $kind = NodeType::INTERFACE_TYPE_DEFINITION; public $kind = NodeType::INTERFACE_TYPE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
/** /**
* @var FieldDefinition[] * @var FieldDefinitionNode[]
*/ */
public $fields = []; public $fields = [];
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class ListType extends Node implements Type class ListTypeNode extends Node implements TypeNode
{ {
public $kind = NodeType::LIST_TYPE; public $kind = NodeType::LIST_TYPE;

View File

@ -2,12 +2,12 @@
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class ListValue extends Node implements Value class ListValueNode extends Node implements ValueNode
{ {
public $kind = NodeType::LST; public $kind = NodeType::LST;
/** /**
* @var array<Value> * @var array<ValueNode>
*/ */
public $values; public $values;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class Name extends Node implements Type class NameNode extends Node implements TypeNode
{ {
public $kind = NodeType::NAME; public $kind = NodeType::NAME;

View File

@ -1,12 +1,12 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class NamedType extends Node implements Type class NamedTypeNode extends Node implements TypeNode
{ {
public $kind = NodeType::NAMED_TYPE; public $kind = NodeType::NAMED_TYPE;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
} }

View File

@ -6,28 +6,28 @@ use GraphQL\Utils;
abstract class Node abstract class Node
{ {
/** /**
type Node = Name type Node = NameNode
| Document | DocumentNode
| OperationDefinition | OperationDefinitionNode
| VariableDefinition | VariableDefinitionNode
| Variable | VariableNode
| SelectionSet | SelectionSetNode
| Field | FieldNode
| Argument | ArgumentNode
| FragmentSpread | FragmentSpreadNode
| InlineFragment | InlineFragmentNode
| FragmentDefinition | FragmentDefinitionNode
| IntValue | IntValueNode
| FloatValue | FloatValueNode
| StringValue | StringValueNode
| BooleanValue | BooleanValueNode
| EnumValue | EnumValueNode
| ListValue | ListValueNode
| ObjectValue | ObjectValueNode
| ObjectField | ObjectFieldNode
| Directive | DirectiveNode
| ListType | ListTypeNode
| NonNullType | NonNullTypeNode
*/ */
public $kind; public $kind;

View File

@ -1,12 +1,12 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class NonNullType extends Node implements Type class NonNullTypeNode extends Node implements TypeNode
{ {
public $kind = NodeType::NON_NULL_TYPE; public $kind = NodeType::NON_NULL_TYPE;
/** /**
* @var Name | ListType * @var NameNode | ListTypeNode
*/ */
public $type; public $type;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class NullValue extends Node implements Value class NullValueNode extends Node implements ValueNode
{ {
public $kind = NodeType::NULL; public $kind = NodeType::NULL;
} }

View File

@ -2,17 +2,17 @@
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class ObjectField extends Node class ObjectFieldNode extends Node
{ {
public $kind = NodeType::OBJECT_FIELD; public $kind = NodeType::OBJECT_FIELD;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Value * @var ValueNode
*/ */
public $value; public $value;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class ObjectTypeDefinition extends Node implements TypeDefinition class ObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,22 +9,22 @@ class ObjectTypeDefinition extends Node implements TypeDefinition
public $kind = NodeType::OBJECT_TYPE_DEFINITION; public $kind = NodeType::OBJECT_TYPE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var NamedType[] * @var NamedTypeNode[]
*/ */
public $interfaces = []; public $interfaces = [];
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
/** /**
* @var FieldDefinition[] * @var FieldDefinitionNode[]
*/ */
public $fields; public $fields;
} }

View File

@ -1,12 +1,12 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class ObjectValue extends Node implements Value class ObjectValueNode extends Node implements ValueNode
{ {
public $kind = NodeType::OBJECT; public $kind = NodeType::OBJECT;
/** /**
* @var array<ObjectField> * @var array<ObjectFieldNode>
*/ */
public $fields; public $fields;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class OperationDefinition extends Node implements Definition, HasSelectionSet class OperationDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
{ {
/** /**
* @var string * @var string
@ -9,7 +9,7 @@ class OperationDefinition extends Node implements Definition, HasSelectionSet
public $kind = NodeType::OPERATION_DEFINITION; public $kind = NodeType::OPERATION_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
@ -19,17 +19,17 @@ class OperationDefinition extends Node implements Definition, HasSelectionSet
public $operation; public $operation;
/** /**
* @var array<VariableDefinition> * @var array<VariableDefinitionNode>
*/ */
public $variableDefinitions; public $variableDefinitions;
/** /**
* @var array<Directive> * @var array<DirectiveNode>
*/ */
public $directives; public $directives;
/** /**
* @var SelectionSet * @var SelectionSetNode
*/ */
public $selectionSet; public $selectionSet;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class OperationTypeDefinition extends Node class OperationTypeDefinitionNode extends Node
{ {
/** /**
* @var string * @var string
@ -16,7 +16,7 @@ class OperationTypeDefinition extends Node
public $operation; public $operation;
/** /**
* @var NamedType * @var NamedTypeNode
*/ */
public $type; public $type;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class ScalarTypeDefinition extends Node implements TypeDefinition class ScalarTypeDefinitionNode extends Node implements TypeDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,12 +9,12 @@ class ScalarTypeDefinition extends Node implements TypeDefinition
public $kind = NodeType::SCALAR_TYPE_DEFINITION; public $kind = NodeType::SCALAR_TYPE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class SchemaDefinition extends Node implements TypeSystemDefinition class SchemaDefinitionNode extends Node implements TypeSystemDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,12 +9,12 @@ class SchemaDefinition extends Node implements TypeSystemDefinition
public $kind = NodeType::SCHEMA_DEFINITION; public $kind = NodeType::SCHEMA_DEFINITION;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
/** /**
* @var OperationTypeDefinition[] * @var OperationTypeDefinitionNode[]
*/ */
public $operationTypes; public $operationTypes;
} }

View File

@ -1,9 +0,0 @@
<?php
namespace GraphQL\Language\AST;
interface Selection
{
/**
* export type Selection = Field | FragmentSpread | InlineFragment
*/
}

View File

@ -0,0 +1,9 @@
<?php
namespace GraphQL\Language\AST;
interface SelectionNode
{
/**
* export type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode
*/
}

View File

@ -1,12 +1,12 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class SelectionSet extends Node class SelectionSetNode extends Node
{ {
public $kind = NodeType::SELECTION_SET; public $kind = NodeType::SELECTION_SET;
/** /**
* @var array<Selection> * @var array<SelectionNode>
*/ */
public $selections; public $selections;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class StringValue extends Node implements Value class StringValueNode extends Node implements ValueNode
{ {
public $kind = NodeType::STRING; public $kind = NodeType::STRING;

View File

@ -1,13 +0,0 @@
<?php
namespace GraphQL\Language\AST;
interface Type
{
/**
export type Type = NamedType
| ListType
| NonNullType
*/
}

View File

@ -1,14 +0,0 @@
<?php
namespace GraphQL\Language\AST;
interface TypeDefinition extends TypeSystemDefinition
{
/**
export type TypeDefinition = ScalarTypeDefinition
| ObjectTypeDefinition
| InterfaceTypeDefinition
| UnionTypeDefinition
| EnumTypeDefinition
| InputObjectTypeDefinition
*/
}

View File

@ -0,0 +1,14 @@
<?php
namespace GraphQL\Language\AST;
interface TypeDefinitionNode extends TypeSystemDefinitionNode
{
/**
export type TypeDefinitionNode = ScalarTypeDefinitionNode
| ObjectTypeDefinitionNode
| InterfaceTypeDefinitionNode
| UnionTypeDefinitionNode
| EnumTypeDefinitionNode
| InputObjectTypeDefinitionNode
*/
}

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class TypeExtensionDefinition extends Node implements TypeSystemDefinition class TypeExtensionDefinitionNode extends Node implements TypeSystemDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,7 +9,7 @@ class TypeExtensionDefinition extends Node implements TypeSystemDefinition
public $kind = NodeType::TYPE_EXTENSION_DEFINITION; public $kind = NodeType::TYPE_EXTENSION_DEFINITION;
/** /**
* @var ObjectTypeDefinition * @var ObjectTypeDefinitionNode
*/ */
public $definition; public $definition;
} }

View File

@ -0,0 +1,13 @@
<?php
namespace GraphQL\Language\AST;
interface TypeNode
{
/**
export type TypeNode = NamedTypeNode
| ListTypeNode
| NonNullTypeNode
*/
}

View File

@ -1,12 +0,0 @@
<?php
namespace GraphQL\Language\AST;
interface TypeSystemDefinition extends Definition
{
/**
export type TypeSystemDefinition = SchemaDefinition
| TypeDefinition
| TypeExtensionDefinition
| DirectiveDefinition
*/
}

View File

@ -0,0 +1,12 @@
<?php
namespace GraphQL\Language\AST;
interface TypeSystemDefinitionNode extends DefinitionNode
{
/**
export type TypeSystemDefinitionNode = SchemaDefinitionNode
| TypeDefinitionNode
| TypeExtensionDefinitionNode
| DirectiveDefinitionNode
*/
}

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class UnionTypeDefinition extends Node implements TypeDefinition class UnionTypeDefinitionNode extends Node implements TypeDefinitionNode
{ {
/** /**
* @var string * @var string
@ -9,17 +9,17 @@ class UnionTypeDefinition extends Node implements TypeDefinition
public $kind = NodeType::UNION_TYPE_DEFINITION; public $kind = NodeType::UNION_TYPE_DEFINITION;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
/** /**
* @var Directive[] * @var DirectiveNode[]
*/ */
public $directives; public $directives;
/** /**
* @var NamedType[] * @var NamedTypeNode[]
*/ */
public $types = []; public $types = [];
} }

View File

@ -1,17 +0,0 @@
<?php
namespace GraphQL\Language\AST;
/**
export type Value = Variable
| IntValue
| FloatValue
| StringValue
| BooleanValue
| EnumValue
| ListValue
| ObjectValue
*/
interface Value
{
}

View File

@ -0,0 +1,17 @@
<?php
namespace GraphQL\Language\AST;
/**
export type ValueNode = VariableNode
| IntValueNode
| FloatValueNode
| StringValueNode
| BooleanValueNode
| EnumValueNode
| ListValueNode
| ObjectValueNode
*/
interface ValueNode
{
}

View File

@ -1,22 +1,22 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class VariableDefinition extends Node implements Definition class VariableDefinitionNode extends Node implements DefinitionNode
{ {
public $kind = NodeType::VARIABLE_DEFINITION; public $kind = NodeType::VARIABLE_DEFINITION;
/** /**
* @var Variable * @var VariableNode
*/ */
public $variable; public $variable;
/** /**
* @var Type * @var TypeNode
*/ */
public $type; public $type;
/** /**
* @var Value|null * @var ValueNode|null
*/ */
public $defaultValue; public $defaultValue;
} }

View File

@ -1,12 +1,12 @@
<?php <?php
namespace GraphQL\Language\AST; namespace GraphQL\Language\AST;
class Variable extends Node class VariableNode extends Node
{ {
public $kind = NodeType::VARIABLE; public $kind = NodeType::VARIABLE;
/** /**
* @var Name * @var NameNode
*/ */
public $name; public $name;
} }

View File

@ -3,45 +3,45 @@ namespace GraphQL\Language;
// language/parser.js // language/parser.js
use GraphQL\Language\AST\Argument; use GraphQL\Language\AST\ArgumentNode;
use GraphQL\Language\AST\DirectiveDefinition; use GraphQL\Language\AST\DirectiveDefinitionNode;
use GraphQL\Language\AST\EnumTypeDefinition; use GraphQL\Language\AST\EnumTypeDefinitionNode;
use GraphQL\Language\AST\EnumValueDefinition; use GraphQL\Language\AST\EnumValueDefinitionNode;
use GraphQL\Language\AST\FieldDefinition; use GraphQL\Language\AST\FieldDefinitionNode;
use GraphQL\Language\AST\InputObjectTypeDefinition; use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
use GraphQL\Language\AST\InputValueDefinition; use GraphQL\Language\AST\InputValueDefinitionNode;
use GraphQL\Language\AST\InterfaceTypeDefinition; use GraphQL\Language\AST\InterfaceTypeDefinitionNode;
use GraphQL\Language\AST\ListValue; use GraphQL\Language\AST\ListValueNode;
use GraphQL\Language\AST\BooleanValue; use GraphQL\Language\AST\BooleanValueNode;
use GraphQL\Language\AST\Directive; use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\Document; use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\AST\EnumValue; use GraphQL\Language\AST\EnumValueNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FloatValue; use GraphQL\Language\AST\FloatValueNode;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\IntValue; use GraphQL\Language\AST\IntValueNode;
use GraphQL\Language\AST\ListType; use GraphQL\Language\AST\ListTypeNode;
use GraphQL\Language\AST\Location; use GraphQL\Language\AST\Location;
use GraphQL\Language\AST\Name; use GraphQL\Language\AST\NameNode;
use GraphQL\Language\AST\NamedType; use GraphQL\Language\AST\NamedTypeNode;
use GraphQL\Language\AST\NonNullType; use GraphQL\Language\AST\NonNullTypeNode;
use GraphQL\Language\AST\NullValue; use GraphQL\Language\AST\NullValueNode;
use GraphQL\Language\AST\ObjectField; use GraphQL\Language\AST\ObjectFieldNode;
use GraphQL\Language\AST\ObjectTypeDefinition; use GraphQL\Language\AST\ObjectTypeDefinitionNode;
use GraphQL\Language\AST\ObjectValue; use GraphQL\Language\AST\ObjectValueNode;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\AST\OperationTypeDefinition; use GraphQL\Language\AST\OperationTypeDefinitionNode;
use GraphQL\Language\AST\ScalarTypeDefinition; use GraphQL\Language\AST\ScalarTypeDefinitionNode;
use GraphQL\Language\AST\SchemaDefinition; use GraphQL\Language\AST\SchemaDefinitionNode;
use GraphQL\Language\AST\SelectionSet; use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Language\AST\StringValue; use GraphQL\Language\AST\StringValueNode;
use GraphQL\Language\AST\TypeExtensionDefinition; use GraphQL\Language\AST\TypeExtensionDefinitionNode;
use GraphQL\Language\AST\TypeSystemDefinition; use GraphQL\Language\AST\TypeSystemDefinitionNode;
use GraphQL\Language\AST\UnionTypeDefinition; use GraphQL\Language\AST\UnionTypeDefinitionNode;
use GraphQL\Language\AST\Variable; use GraphQL\Language\AST\VariableNode;
use GraphQL\Language\AST\VariableDefinition; use GraphQL\Language\AST\VariableDefinitionNode;
use GraphQL\Error\SyntaxError; use GraphQL\Error\SyntaxError;
class Parser class Parser
@ -56,7 +56,7 @@ class Parser
* *
* @param Source|string $source * @param Source|string $source
* @param array $options * @param array $options
* @return Document * @return DocumentNode
*/ */
public static function parse($source, array $options = []) public static function parse($source, array $options = [])
{ {
@ -78,7 +78,7 @@ class Parser
* *
* @param Source|string $source * @param Source|string $source
* @param array $options * @param array $options
* @return BooleanValue|EnumValue|FloatValue|IntValue|ListValue|ObjectValue|StringValue|Variable * @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|ObjectValueNode|StringValueNode|VariableNode
*/ */
public static function parseValue($source, array $options = []) public static function parseValue($source, array $options = [])
{ {
@ -101,7 +101,7 @@ class Parser
* Consider providing the results to the utility function: typeFromAST(). * Consider providing the results to the utility function: typeFromAST().
* @param Source|string $source * @param Source|string $source
* @param array $options * @param array $options
* @return ListType|Name|NonNullType * @return ListTypeNode|NameNode|NonNullTypeNode
*/ */
public static function parseType($source, array $options = []) public static function parseType($source, array $options = [])
{ {
@ -277,14 +277,14 @@ class Parser
/** /**
* Converts a name lex token into a name parse node. * Converts a name lex token into a name parse node.
* *
* @return Name * @return NameNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseName() function parseName()
{ {
$token = $this->expect(Token::NAME); $token = $this->expect(Token::NAME);
return new Name([ return new NameNode([
'value' => $token->value, 'value' => $token->value,
'loc' => $this->loc($token) 'loc' => $this->loc($token)
]); ]);
@ -293,7 +293,7 @@ class Parser
/** /**
* Implements the parsing rules in the Document section. * Implements the parsing rules in the Document section.
* *
* @return Document * @return DocumentNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseDocument() function parseDocument()
@ -306,14 +306,14 @@ class Parser
$definitions[] = $this->parseDefinition(); $definitions[] = $this->parseDefinition();
} while (!$this->skip(Token::EOF)); } while (!$this->skip(Token::EOF));
return new Document([ return new DocumentNode([
'definitions' => $definitions, 'definitions' => $definitions,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
} }
/** /**
* @return OperationDefinition|FragmentDefinition|TypeSystemDefinition * @return OperationDefinitionNode|FragmentDefinitionNode|TypeSystemDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseDefinition() function parseDefinition()
@ -352,14 +352,14 @@ class Parser
// Implements the parsing rules in the Operations section. // Implements the parsing rules in the Operations section.
/** /**
* @return OperationDefinition * @return OperationDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseOperationDefinition() function parseOperationDefinition()
{ {
$start = $this->lexer->token; $start = $this->lexer->token;
if ($this->peek(Token::BRACE_L)) { if ($this->peek(Token::BRACE_L)) {
return new OperationDefinition([ return new OperationDefinitionNode([
'operation' => 'query', 'operation' => 'query',
'name' => null, 'name' => null,
'variableDefinitions' => null, 'variableDefinitions' => null,
@ -376,7 +376,7 @@ class Parser
$name = $this->parseName(); $name = $this->parseName();
} }
return new OperationDefinition([ return new OperationDefinitionNode([
'operation' => $operation, 'operation' => $operation,
'name' => $name, 'name' => $name,
'variableDefinitions' => $this->parseVariableDefinitions(), 'variableDefinitions' => $this->parseVariableDefinitions(),
@ -404,7 +404,7 @@ class Parser
} }
/** /**
* @return array<VariableDefinition> * @return array<VariableDefinitionNode>
*/ */
function parseVariableDefinitions() function parseVariableDefinitions()
{ {
@ -418,7 +418,7 @@ class Parser
} }
/** /**
* @return VariableDefinition * @return VariableDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseVariableDefinition() function parseVariableDefinition()
@ -429,7 +429,7 @@ class Parser
$this->expect(Token::COLON); $this->expect(Token::COLON);
$type = $this->parseTypeReference(); $type = $this->parseTypeReference();
return new VariableDefinition([ return new VariableDefinitionNode([
'variable' => $var, 'variable' => $var,
'type' => $type, 'type' => $type,
'defaultValue' => 'defaultValue' =>
@ -439,7 +439,7 @@ class Parser
} }
/** /**
* @return Variable * @return VariableNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseVariable() function parseVariable()
@ -447,19 +447,19 @@ class Parser
$start = $this->lexer->token; $start = $this->lexer->token;
$this->expect(Token::DOLLAR); $this->expect(Token::DOLLAR);
return new Variable([ return new VariableNode([
'name' => $this->parseName(), 'name' => $this->parseName(),
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
} }
/** /**
* @return SelectionSet * @return SelectionSetNode
*/ */
function parseSelectionSet() function parseSelectionSet()
{ {
$start = $this->lexer->token; $start = $this->lexer->token;
return new SelectionSet([ return new SelectionSetNode([
'selections' => $this->many(Token::BRACE_L, [$this, 'parseSelection'], Token::BRACE_R), 'selections' => $this->many(Token::BRACE_L, [$this, 'parseSelection'], Token::BRACE_R),
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
@ -481,7 +481,7 @@ class Parser
} }
/** /**
* @return Field * @return FieldNode
*/ */
function parseField() function parseField()
{ {
@ -496,7 +496,7 @@ class Parser
$name = $nameOrAlias; $name = $nameOrAlias;
} }
return new Field([ return new FieldNode([
'alias' => $alias, 'alias' => $alias,
'name' => $name, 'name' => $name,
'arguments' => $this->parseArguments(), 'arguments' => $this->parseArguments(),
@ -507,7 +507,7 @@ class Parser
} }
/** /**
* @return array<Argument> * @return array<ArgumentNode>
*/ */
function parseArguments() function parseArguments()
{ {
@ -517,7 +517,7 @@ class Parser
} }
/** /**
* @return Argument * @return ArgumentNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseArgument() function parseArgument()
@ -528,7 +528,7 @@ class Parser
$this->expect(Token::COLON); $this->expect(Token::COLON);
$value = $this->parseValueLiteral(false); $value = $this->parseValueLiteral(false);
return new Argument([ return new ArgumentNode([
'name' => $name, 'name' => $name,
'value' => $value, 'value' => $value,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
@ -538,7 +538,7 @@ class Parser
// Implements the parsing rules in the Fragments section. // Implements the parsing rules in the Fragments section.
/** /**
* @return FragmentSpread|InlineFragment * @return FragmentSpreadNode|InlineFragmentNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseFragment() function parseFragment()
@ -547,7 +547,7 @@ class Parser
$this->expect(Token::SPREAD); $this->expect(Token::SPREAD);
if ($this->peek(Token::NAME) && $this->lexer->token->value !== 'on') { if ($this->peek(Token::NAME) && $this->lexer->token->value !== 'on') {
return new FragmentSpread([ return new FragmentSpreadNode([
'name' => $this->parseFragmentName(), 'name' => $this->parseFragmentName(),
'directives' => $this->parseDirectives(), 'directives' => $this->parseDirectives(),
'loc' => $this->loc($start) 'loc' => $this->loc($start)
@ -560,7 +560,7 @@ class Parser
$typeCondition = $this->parseNamedType(); $typeCondition = $this->parseNamedType();
} }
return new InlineFragment([ return new InlineFragmentNode([
'typeCondition' => $typeCondition, 'typeCondition' => $typeCondition,
'directives' => $this->parseDirectives(), 'directives' => $this->parseDirectives(),
'selectionSet' => $this->parseSelectionSet(), 'selectionSet' => $this->parseSelectionSet(),
@ -569,7 +569,7 @@ class Parser
} }
/** /**
* @return FragmentDefinition * @return FragmentDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseFragmentDefinition() function parseFragmentDefinition()
@ -581,7 +581,7 @@ class Parser
$this->expectKeyword('on'); $this->expectKeyword('on');
$typeCondition = $this->parseNamedType(); $typeCondition = $this->parseNamedType();
return new FragmentDefinition([ return new FragmentDefinitionNode([
'name' => $name, 'name' => $name,
'typeCondition' => $typeCondition, 'typeCondition' => $typeCondition,
'directives' => $this->parseDirectives(), 'directives' => $this->parseDirectives(),
@ -591,7 +591,7 @@ class Parser
} }
/** /**
* @return Name * @return NameNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseFragmentName() function parseFragmentName()
@ -623,7 +623,7 @@ class Parser
* EnumValue : Name but not `true`, `false` or `null` * EnumValue : Name but not `true`, `false` or `null`
* *
* @param $isConst * @param $isConst
* @return BooleanValue|EnumValue|FloatValue|IntValue|StringValue|Variable|ListValue|ObjectValue|NullValue * @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|StringValueNode|VariableNode|ListValueNode|ObjectValueNode|NullValueNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseValueLiteral($isConst) function parseValueLiteral($isConst)
@ -636,37 +636,37 @@ class Parser
return $this->parseObject($isConst); return $this->parseObject($isConst);
case Token::INT: case Token::INT:
$this->lexer->advance(); $this->lexer->advance();
return new IntValue([ return new IntValueNode([
'value' => $token->value, 'value' => $token->value,
'loc' => $this->loc($token) 'loc' => $this->loc($token)
]); ]);
case Token::FLOAT: case Token::FLOAT:
$this->lexer->advance(); $this->lexer->advance();
return new FloatValue([ return new FloatValueNode([
'value' => $token->value, 'value' => $token->value,
'loc' => $this->loc($token) 'loc' => $this->loc($token)
]); ]);
case Token::STRING: case Token::STRING:
$this->lexer->advance(); $this->lexer->advance();
return new StringValue([ return new StringValueNode([
'value' => $token->value, 'value' => $token->value,
'loc' => $this->loc($token) 'loc' => $this->loc($token)
]); ]);
case Token::NAME: case Token::NAME:
if ($token->value === 'true' || $token->value === 'false') { if ($token->value === 'true' || $token->value === 'false') {
$this->lexer->advance(); $this->lexer->advance();
return new BooleanValue([ return new BooleanValueNode([
'value' => $token->value === 'true', 'value' => $token->value === 'true',
'loc' => $this->loc($token) 'loc' => $this->loc($token)
]); ]);
} else if ($token->value === 'null') { } else if ($token->value === 'null') {
$this->lexer->advance(); $this->lexer->advance();
return new NullValue([ return new NullValueNode([
'loc' => $this->loc($token) 'loc' => $this->loc($token)
]); ]);
} else { } else {
$this->lexer->advance(); $this->lexer->advance();
return new EnumValue([ return new EnumValueNode([
'value' => $token->value, 'value' => $token->value,
'loc' => $this->loc($token) 'loc' => $this->loc($token)
]); ]);
@ -683,7 +683,7 @@ class Parser
} }
/** /**
* @return BooleanValue|EnumValue|FloatValue|IntValue|StringValue|Variable * @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|StringValueNode|VariableNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseConstValue() function parseConstValue()
@ -692,7 +692,7 @@ class Parser
} }
/** /**
* @return BooleanValue|EnumValue|FloatValue|IntValue|ListValue|ObjectValue|StringValue|Variable * @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|ObjectValueNode|StringValueNode|VariableNode
*/ */
function parseVariableValue() function parseVariableValue()
{ {
@ -701,13 +701,13 @@ class Parser
/** /**
* @param bool $isConst * @param bool $isConst
* @return ListValue * @return ListValueNode
*/ */
function parseArray($isConst) function parseArray($isConst)
{ {
$start = $this->lexer->token; $start = $this->lexer->token;
$item = $isConst ? 'parseConstValue' : 'parseVariableValue'; $item = $isConst ? 'parseConstValue' : 'parseVariableValue';
return new ListValue([ return new ListValueNode([
'values' => $this->any(Token::BRACKET_L, [$this, $item], Token::BRACKET_R), 'values' => $this->any(Token::BRACKET_L, [$this, $item], Token::BRACKET_R),
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
@ -715,7 +715,7 @@ class Parser
/** /**
* @param $isConst * @param $isConst
* @return ObjectValue * @return ObjectValueNode
*/ */
function parseObject($isConst) function parseObject($isConst)
{ {
@ -725,7 +725,7 @@ class Parser
while (!$this->skip(Token::BRACE_R)) { while (!$this->skip(Token::BRACE_R)) {
$fields[] = $this->parseObjectField($isConst); $fields[] = $this->parseObjectField($isConst);
} }
return new ObjectValue([ return new ObjectValueNode([
'fields' => $fields, 'fields' => $fields,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
@ -733,7 +733,7 @@ class Parser
/** /**
* @param $isConst * @param $isConst
* @return ObjectField * @return ObjectFieldNode
*/ */
function parseObjectField($isConst) function parseObjectField($isConst)
{ {
@ -742,7 +742,7 @@ class Parser
$this->expect(Token::COLON); $this->expect(Token::COLON);
return new ObjectField([ return new ObjectFieldNode([
'name' => $name, 'name' => $name,
'value' => $this->parseValueLiteral($isConst), 'value' => $this->parseValueLiteral($isConst),
'loc' => $this->loc($start) 'loc' => $this->loc($start)
@ -752,7 +752,7 @@ class Parser
// Implements the parsing rules in the Directives section. // Implements the parsing rules in the Directives section.
/** /**
* @return array<Directive> * @return array<DirectiveNode>
*/ */
function parseDirectives() function parseDirectives()
{ {
@ -764,14 +764,14 @@ class Parser
} }
/** /**
* @return Directive * @return DirectiveNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseDirective() function parseDirective()
{ {
$start = $this->lexer->token; $start = $this->lexer->token;
$this->expect(Token::AT); $this->expect(Token::AT);
return new Directive([ return new DirectiveNode([
'name' => $this->parseName(), 'name' => $this->parseName(),
'arguments' => $this->parseArguments(), 'arguments' => $this->parseArguments(),
'loc' => $this->loc($start) 'loc' => $this->loc($start)
@ -783,7 +783,7 @@ class Parser
/** /**
* Handles the Type: TypeName, ListType, and NonNullType parsing rules. * Handles the Type: TypeName, ListType, and NonNullType parsing rules.
* *
* @return ListType|Name|NonNullType * @return ListTypeNode|NameNode|NonNullTypeNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseTypeReference() function parseTypeReference()
@ -793,7 +793,7 @@ class Parser
if ($this->skip(Token::BRACKET_L)) { if ($this->skip(Token::BRACKET_L)) {
$type = $this->parseTypeReference(); $type = $this->parseTypeReference();
$this->expect(Token::BRACKET_R); $this->expect(Token::BRACKET_R);
$type = new ListType([ $type = new ListTypeNode([
'type' => $type, 'type' => $type,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
@ -801,7 +801,7 @@ class Parser
$type = $this->parseNamedType(); $type = $this->parseNamedType();
} }
if ($this->skip(Token::BANG)) { if ($this->skip(Token::BANG)) {
return new NonNullType([ return new NonNullTypeNode([
'type' => $type, 'type' => $type,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
@ -814,7 +814,7 @@ class Parser
{ {
$start = $this->lexer->token; $start = $this->lexer->token;
return new NamedType([ return new NamedTypeNode([
'name' => $this->parseName(), 'name' => $this->parseName(),
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
@ -837,7 +837,7 @@ class Parser
* - EnumTypeDefinition * - EnumTypeDefinition
* - InputObjectTypeDefinition * - InputObjectTypeDefinition
* *
* @return TypeSystemDefinition * @return TypeSystemDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseTypeSystemDefinition() function parseTypeSystemDefinition()
@ -860,7 +860,7 @@ class Parser
} }
/** /**
* @return SchemaDefinition * @return SchemaDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseSchemaDefinition() function parseSchemaDefinition()
@ -875,7 +875,7 @@ class Parser
Token::BRACE_R Token::BRACE_R
); );
return new SchemaDefinition([ return new SchemaDefinitionNode([
'directives' => $directives, 'directives' => $directives,
'operationTypes' => $operationTypes, 'operationTypes' => $operationTypes,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
@ -883,7 +883,7 @@ class Parser
} }
/** /**
* @return OperationTypeDefinition * @return OperationTypeDefinitionNode
*/ */
function parseOperationTypeDefinition() function parseOperationTypeDefinition()
{ {
@ -892,7 +892,7 @@ class Parser
$this->expect(Token::COLON); $this->expect(Token::COLON);
$type = $this->parseNamedType(); $type = $this->parseNamedType();
return new OperationTypeDefinition([ return new OperationTypeDefinitionNode([
'operation' => $operation, 'operation' => $operation,
'type' => $type, 'type' => $type,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
@ -900,7 +900,7 @@ class Parser
} }
/** /**
* @return ScalarTypeDefinition * @return ScalarTypeDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseScalarTypeDefinition() function parseScalarTypeDefinition()
@ -910,7 +910,7 @@ class Parser
$name = $this->parseName(); $name = $this->parseName();
$directives = $this->parseDirectives(); $directives = $this->parseDirectives();
return new ScalarTypeDefinition([ return new ScalarTypeDefinitionNode([
'name' => $name, 'name' => $name,
'directives' => $directives, 'directives' => $directives,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
@ -918,7 +918,7 @@ class Parser
} }
/** /**
* @return ObjectTypeDefinition * @return ObjectTypeDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseObjectTypeDefinition() function parseObjectTypeDefinition()
@ -935,7 +935,7 @@ class Parser
Token::BRACE_R Token::BRACE_R
); );
return new ObjectTypeDefinition([ return new ObjectTypeDefinitionNode([
'name' => $name, 'name' => $name,
'interfaces' => $interfaces, 'interfaces' => $interfaces,
'directives' => $directives, 'directives' => $directives,
@ -945,7 +945,7 @@ class Parser
} }
/** /**
* @return NamedType[] * @return NamedTypeNode[]
*/ */
function parseImplementsInterfaces() function parseImplementsInterfaces()
{ {
@ -960,7 +960,7 @@ class Parser
} }
/** /**
* @return FieldDefinition * @return FieldDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseFieldDefinition() function parseFieldDefinition()
@ -972,7 +972,7 @@ class Parser
$type = $this->parseTypeReference(); $type = $this->parseTypeReference();
$directives = $this->parseDirectives(); $directives = $this->parseDirectives();
return new FieldDefinition([ return new FieldDefinitionNode([
'name' => $name, 'name' => $name,
'arguments' => $args, 'arguments' => $args,
'type' => $type, 'type' => $type,
@ -982,7 +982,7 @@ class Parser
} }
/** /**
* @return InputValueDefinition[] * @return InputValueDefinitionNode[]
*/ */
function parseArgumentDefs() function parseArgumentDefs()
{ {
@ -993,7 +993,7 @@ class Parser
} }
/** /**
* @return InputValueDefinition * @return InputValueDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseInputValueDef() function parseInputValueDef()
@ -1007,7 +1007,7 @@ class Parser
$defaultValue = $this->parseConstValue(); $defaultValue = $this->parseConstValue();
} }
$directives = $this->parseDirectives(); $directives = $this->parseDirectives();
return new InputValueDefinition([ return new InputValueDefinitionNode([
'name' => $name, 'name' => $name,
'type' => $type, 'type' => $type,
'defaultValue' => $defaultValue, 'defaultValue' => $defaultValue,
@ -1017,7 +1017,7 @@ class Parser
} }
/** /**
* @return InterfaceTypeDefinition * @return InterfaceTypeDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseInterfaceTypeDefinition() function parseInterfaceTypeDefinition()
@ -1032,7 +1032,7 @@ class Parser
Token::BRACE_R Token::BRACE_R
); );
return new InterfaceTypeDefinition([ return new InterfaceTypeDefinitionNode([
'name' => $name, 'name' => $name,
'directives' => $directives, 'directives' => $directives,
'fields' => $fields, 'fields' => $fields,
@ -1041,7 +1041,7 @@ class Parser
} }
/** /**
* @return UnionTypeDefinition * @return UnionTypeDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseUnionTypeDefinition() function parseUnionTypeDefinition()
@ -1053,7 +1053,7 @@ class Parser
$this->expect(Token::EQUALS); $this->expect(Token::EQUALS);
$types = $this->parseUnionMembers(); $types = $this->parseUnionMembers();
return new UnionTypeDefinition([ return new UnionTypeDefinitionNode([
'name' => $name, 'name' => $name,
'directives' => $directives, 'directives' => $directives,
'types' => $types, 'types' => $types,
@ -1066,7 +1066,7 @@ class Parser
* - NamedType * - NamedType
* - UnionMembers | NamedType * - UnionMembers | NamedType
* *
* @return NamedType[] * @return NamedTypeNode[]
*/ */
function parseUnionMembers() function parseUnionMembers()
{ {
@ -1078,7 +1078,7 @@ class Parser
} }
/** /**
* @return EnumTypeDefinition * @return EnumTypeDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseEnumTypeDefinition() function parseEnumTypeDefinition()
@ -1093,7 +1093,7 @@ class Parser
Token::BRACE_R Token::BRACE_R
); );
return new EnumTypeDefinition([ return new EnumTypeDefinitionNode([
'name' => $name, 'name' => $name,
'directives' => $directives, 'directives' => $directives,
'values' => $values, 'values' => $values,
@ -1102,7 +1102,7 @@ class Parser
} }
/** /**
* @return EnumValueDefinition * @return EnumValueDefinitionNode
*/ */
function parseEnumValueDefinition() function parseEnumValueDefinition()
{ {
@ -1110,7 +1110,7 @@ class Parser
$name = $this->parseName(); $name = $this->parseName();
$directives = $this->parseDirectives(); $directives = $this->parseDirectives();
return new EnumValueDefinition([ return new EnumValueDefinitionNode([
'name' => $name, 'name' => $name,
'directives' => $directives, 'directives' => $directives,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
@ -1118,7 +1118,7 @@ class Parser
} }
/** /**
* @return InputObjectTypeDefinition * @return InputObjectTypeDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseInputObjectTypeDefinition() function parseInputObjectTypeDefinition()
@ -1133,7 +1133,7 @@ class Parser
Token::BRACE_R Token::BRACE_R
); );
return new InputObjectTypeDefinition([ return new InputObjectTypeDefinitionNode([
'name' => $name, 'name' => $name,
'directives' => $directives, 'directives' => $directives,
'fields' => $fields, 'fields' => $fields,
@ -1142,7 +1142,7 @@ class Parser
} }
/** /**
* @return TypeExtensionDefinition * @return TypeExtensionDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseTypeExtensionDefinition() function parseTypeExtensionDefinition()
@ -1151,7 +1151,7 @@ class Parser
$this->expectKeyword('extend'); $this->expectKeyword('extend');
$definition = $this->parseObjectTypeDefinition(); $definition = $this->parseObjectTypeDefinition();
return new TypeExtensionDefinition([ return new TypeExtensionDefinitionNode([
'definition' => $definition, 'definition' => $definition,
'loc' => $this->loc($start) 'loc' => $this->loc($start)
]); ]);
@ -1161,7 +1161,7 @@ class Parser
* DirectiveDefinition : * DirectiveDefinition :
* - directive @ Name ArgumentsDefinition? on DirectiveLocations * - directive @ Name ArgumentsDefinition? on DirectiveLocations
* *
* @return DirectiveDefinition * @return DirectiveDefinitionNode
* @throws SyntaxError * @throws SyntaxError
*/ */
function parseDirectiveDefinition() function parseDirectiveDefinition()
@ -1174,7 +1174,7 @@ class Parser
$this->expectKeyword('on'); $this->expectKeyword('on');
$locations = $this->parseDirectiveLocations(); $locations = $this->parseDirectiveLocations();
return new DirectiveDefinition([ return new DirectiveDefinitionNode([
'name' => $name, 'name' => $name,
'arguments' => $args, 'arguments' => $args,
'locations' => $locations, 'locations' => $locations,
@ -1183,7 +1183,7 @@ class Parser
} }
/** /**
* @return Name[] * @return NameNode[]
*/ */
function parseDirectiveLocations() function parseDirectiveLocations()
{ {

View File

@ -1,43 +1,43 @@
<?php <?php
namespace GraphQL\Language; namespace GraphQL\Language;
use GraphQL\Language\AST\Argument; use GraphQL\Language\AST\ArgumentNode;
use GraphQL\Language\AST\DirectiveDefinition; use GraphQL\Language\AST\DirectiveDefinitionNode;
use GraphQL\Language\AST\EnumTypeDefinition; use GraphQL\Language\AST\EnumTypeDefinitionNode;
use GraphQL\Language\AST\EnumValueDefinition; use GraphQL\Language\AST\EnumValueDefinitionNode;
use GraphQL\Language\AST\FieldDefinition; use GraphQL\Language\AST\FieldDefinitionNode;
use GraphQL\Language\AST\InputObjectTypeDefinition; use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
use GraphQL\Language\AST\InputValueDefinition; use GraphQL\Language\AST\InputValueDefinitionNode;
use GraphQL\Language\AST\InterfaceTypeDefinition; use GraphQL\Language\AST\InterfaceTypeDefinitionNode;
use GraphQL\Language\AST\ListValue; use GraphQL\Language\AST\ListValueNode;
use GraphQL\Language\AST\BooleanValue; use GraphQL\Language\AST\BooleanValueNode;
use GraphQL\Language\AST\Directive; use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\Document; use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\AST\EnumValue; use GraphQL\Language\AST\EnumValueNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FloatValue; use GraphQL\Language\AST\FloatValueNode;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\IntValue; use GraphQL\Language\AST\IntValueNode;
use GraphQL\Language\AST\ListType; use GraphQL\Language\AST\ListTypeNode;
use GraphQL\Language\AST\NamedType; use GraphQL\Language\AST\NamedTypeNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\NonNullType; use GraphQL\Language\AST\NonNullTypeNode;
use GraphQL\Language\AST\NullValue; use GraphQL\Language\AST\NullValueNode;
use GraphQL\Language\AST\ObjectField; use GraphQL\Language\AST\ObjectFieldNode;
use GraphQL\Language\AST\ObjectTypeDefinition; use GraphQL\Language\AST\ObjectTypeDefinitionNode;
use GraphQL\Language\AST\ObjectValue; use GraphQL\Language\AST\ObjectValueNode;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\AST\OperationTypeDefinition; use GraphQL\Language\AST\OperationTypeDefinitionNode;
use GraphQL\Language\AST\ScalarTypeDefinition; use GraphQL\Language\AST\ScalarTypeDefinitionNode;
use GraphQL\Language\AST\SchemaDefinition; use GraphQL\Language\AST\SchemaDefinitionNode;
use GraphQL\Language\AST\SelectionSet; use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Language\AST\StringValue; use GraphQL\Language\AST\StringValueNode;
use GraphQL\Language\AST\TypeExtensionDefinition; use GraphQL\Language\AST\TypeExtensionDefinitionNode;
use GraphQL\Language\AST\UnionTypeDefinition; use GraphQL\Language\AST\UnionTypeDefinitionNode;
use GraphQL\Language\AST\VariableDefinition; use GraphQL\Language\AST\VariableDefinitionNode;
class Printer class Printer
{ {
@ -61,10 +61,10 @@ class Printer
NodeType::VARIABLE => function($node) { NodeType::VARIABLE => function($node) {
return '$' . $node->name; return '$' . $node->name;
}, },
NodeType::DOCUMENT => function(Document $node) { NodeType::DOCUMENT => function(DocumentNode $node) {
return $this->join($node->definitions, "\n\n") . "\n"; return $this->join($node->definitions, "\n\n") . "\n";
}, },
NodeType::OPERATION_DEFINITION => function(OperationDefinition $node) { NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) {
$op = $node->operation; $op = $node->operation;
$name = $node->name; $name = $node->name;
$varDefs = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')'); $varDefs = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')');
@ -76,28 +76,28 @@ class Printer
? $selectionSet ? $selectionSet
: $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' '); : $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');
}, },
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $node) { NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) {
return $node->variable . ': ' . $node->type . $this->wrap(' = ', $node->defaultValue); return $node->variable . ': ' . $node->type . $this->wrap(' = ', $node->defaultValue);
}, },
NodeType::SELECTION_SET => function(SelectionSet $node) { NodeType::SELECTION_SET => function(SelectionSetNode $node) {
return $this->block($node->selections); return $this->block($node->selections);
}, },
NodeType::FIELD => function(Field $node) { NodeType::FIELD => function(FieldNode $node) {
return $this->join([ return $this->join([
$this->wrap('', $node->alias, ': ') . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')'), $this->wrap('', $node->alias, ': ') . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')'),
$this->join($node->directives, ' '), $this->join($node->directives, ' '),
$node->selectionSet $node->selectionSet
], ' '); ], ' ');
}, },
NodeType::ARGUMENT => function(Argument $node) { NodeType::ARGUMENT => function(ArgumentNode $node) {
return $node->name . ': ' . $node->value; return $node->name . ': ' . $node->value;
}, },
// Fragments // Fragments
NodeType::FRAGMENT_SPREAD => function(FragmentSpread $node) { NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) {
return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' ')); return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));
}, },
NodeType::INLINE_FRAGMENT => function(InlineFragment $node) { NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) {
return $this->join([ return $this->join([
"...", "...",
$this->wrap('on ', $node->typeCondition), $this->wrap('on ', $node->typeCondition),
@ -105,73 +105,73 @@ class Printer
$node->selectionSet $node->selectionSet
], ' '); ], ' ');
}, },
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinition $node) { NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) {
return "fragment {$node->name} on {$node->typeCondition} " return "fragment {$node->name} on {$node->typeCondition} "
. $this->wrap('', $this->join($node->directives, ' '), ' ') . $this->wrap('', $this->join($node->directives, ' '), ' ')
. $node->selectionSet; . $node->selectionSet;
}, },
// Value // Value
NodeType::INT => function(IntValue $node) { NodeType::INT => function(IntValueNode $node) {
return $node->value; return $node->value;
}, },
NodeType::FLOAT => function(FloatValue $node) { NodeType::FLOAT => function(FloatValueNode $node) {
return $node->value; return $node->value;
}, },
NodeType::STRING => function(StringValue $node) { NodeType::STRING => function(StringValueNode $node) {
return json_encode($node->value); return json_encode($node->value);
}, },
NodeType::BOOLEAN => function(BooleanValue $node) { NodeType::BOOLEAN => function(BooleanValueNode $node) {
return $node->value ? 'true' : 'false'; return $node->value ? 'true' : 'false';
}, },
NodeType::NULL => function(NullValue $node) { NodeType::NULL => function(NullValueNode $node) {
return 'null'; return 'null';
}, },
NodeType::ENUM => function(EnumValue $node) { NodeType::ENUM => function(EnumValueNode $node) {
return $node->value; return $node->value;
}, },
NodeType::LST => function(ListValue $node) { NodeType::LST => function(ListValueNode $node) {
return '[' . $this->join($node->values, ', ') . ']'; return '[' . $this->join($node->values, ', ') . ']';
}, },
NodeType::OBJECT => function(ObjectValue $node) { NodeType::OBJECT => function(ObjectValueNode $node) {
return '{' . $this->join($node->fields, ', ') . '}'; return '{' . $this->join($node->fields, ', ') . '}';
}, },
NodeType::OBJECT_FIELD => function(ObjectField $node) { NodeType::OBJECT_FIELD => function(ObjectFieldNode $node) {
return $node->name . ': ' . $node->value; return $node->name . ': ' . $node->value;
}, },
// Directive // DirectiveNode
NodeType::DIRECTIVE => function(Directive $node) { NodeType::DIRECTIVE => function(DirectiveNode $node) {
return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')'); return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');
}, },
// Type // Type
NodeType::NAMED_TYPE => function(NamedType $node) { NodeType::NAMED_TYPE => function(NamedTypeNode $node) {
return $node->name; return $node->name;
}, },
NodeType::LIST_TYPE => function(ListType $node) { NodeType::LIST_TYPE => function(ListTypeNode $node) {
return '[' . $node->type . ']'; return '[' . $node->type . ']';
}, },
NodeType::NON_NULL_TYPE => function(NonNullType $node) { NodeType::NON_NULL_TYPE => function(NonNullTypeNode $node) {
return $node->type . '!'; return $node->type . '!';
}, },
// Type System Definitions // Type System Definitions
NodeType::SCHEMA_DEFINITION => function(SchemaDefinition $def) { NodeType::SCHEMA_DEFINITION => function(SchemaDefinitionNode $def) {
return $this->join([ return $this->join([
'schema', 'schema',
$this->join($def->directives, ' '), $this->join($def->directives, ' '),
$this->block($def->operationTypes) $this->block($def->operationTypes)
], ' '); ], ' ');
}, },
NodeType::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinition $def) { NodeType::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinitionNode $def) {
return $def->operation . ': ' . $def->type; return $def->operation . ': ' . $def->type;
}, },
NodeType::SCALAR_TYPE_DEFINITION => function(ScalarTypeDefinition $def) { NodeType::SCALAR_TYPE_DEFINITION => function(ScalarTypeDefinitionNode $def) {
return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' '); return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');
}, },
NodeType::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinition $def) { NodeType::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinitionNode $def) {
return $this->join([ return $this->join([
'type', 'type',
$def->name, $def->name,
@ -180,20 +180,20 @@ class Printer
$this->block($def->fields) $this->block($def->fields)
], ' '); ], ' ');
}, },
NodeType::FIELD_DEFINITION => function(FieldDefinition $def) { NodeType::FIELD_DEFINITION => function(FieldDefinitionNode $def) {
return $def->name return $def->name
. $this->wrap('(', $this->join($def->arguments, ', '), ')') . $this->wrap('(', $this->join($def->arguments, ', '), ')')
. ': ' . $def->type . ': ' . $def->type
. $this->wrap(' ', $this->join($def->directives, ' ')); . $this->wrap(' ', $this->join($def->directives, ' '));
}, },
NodeType::INPUT_VALUE_DEFINITION => function(InputValueDefinition $def) { NodeType::INPUT_VALUE_DEFINITION => function(InputValueDefinitionNode $def) {
return $this->join([ return $this->join([
$def->name . ': ' . $def->type, $def->name . ': ' . $def->type,
$this->wrap('= ', $def->defaultValue), $this->wrap('= ', $def->defaultValue),
$this->join($def->directives, ' ') $this->join($def->directives, ' ')
], ' '); ], ' ');
}, },
NodeType::INTERFACE_TYPE_DEFINITION => function(InterfaceTypeDefinition $def) { NodeType::INTERFACE_TYPE_DEFINITION => function(InterfaceTypeDefinitionNode $def) {
return $this->join([ return $this->join([
'interface', 'interface',
$def->name, $def->name,
@ -201,7 +201,7 @@ class Printer
$this->block($def->fields) $this->block($def->fields)
], ' '); ], ' ');
}, },
NodeType::UNION_TYPE_DEFINITION => function(UnionTypeDefinition $def) { NodeType::UNION_TYPE_DEFINITION => function(UnionTypeDefinitionNode $def) {
return $this->join([ return $this->join([
'union', 'union',
$def->name, $def->name,
@ -209,7 +209,7 @@ class Printer
'= ' . $this->join($def->types, ' | ') '= ' . $this->join($def->types, ' | ')
], ' '); ], ' ');
}, },
NodeType::ENUM_TYPE_DEFINITION => function(EnumTypeDefinition $def) { NodeType::ENUM_TYPE_DEFINITION => function(EnumTypeDefinitionNode $def) {
return $this->join([ return $this->join([
'enum', 'enum',
$def->name, $def->name,
@ -217,13 +217,13 @@ class Printer
$this->block($def->values) $this->block($def->values)
], ' '); ], ' ');
}, },
NodeType::ENUM_VALUE_DEFINITION => function(EnumValueDefinition $def) { NodeType::ENUM_VALUE_DEFINITION => function(EnumValueDefinitionNode $def) {
return $this->join([ return $this->join([
$def->name, $def->name,
$this->join($def->directives, ' ') $this->join($def->directives, ' ')
], ' '); ], ' ');
}, },
NodeType::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinition $def) { NodeType::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinitionNode $def) {
return $this->join([ return $this->join([
'input', 'input',
$def->name, $def->name,
@ -231,10 +231,10 @@ class Printer
$this->block($def->fields) $this->block($def->fields)
], ' '); ], ' ');
}, },
NodeType::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinition $def) { NodeType::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinitionNode $def) {
return "extend {$def->definition}"; return "extend {$def->definition}";
}, },
NodeType::DIRECTIVE_DEFINITION => function(DirectiveDefinition $def) { NodeType::DIRECTIVE_DEFINITION => function(DirectiveDefinitionNode $def) {
return 'directive @' . $def->name . $this->wrap('(', $this->join($def->arguments, ', '), ')') return 'directive @' . $def->name . $this->wrap('(', $this->join($def->arguments, ', '), ')')
. ' on ' . $this->join($def->locations, ' | '); . ' on ' . $this->join($def->locations, ' | ');
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Type\Definition; namespace GraphQL\Type\Definition;
use GraphQL\Language\AST\BooleanValue; use GraphQL\Language\AST\BooleanValueNode;
/** /**
* Class BooleanType * Class BooleanType
@ -43,7 +43,7 @@ class BooleanType extends ScalarType
*/ */
public function parseLiteral($ast) public function parseLiteral($ast)
{ {
if ($ast instanceof BooleanValue) { if ($ast instanceof BooleanValueNode) {
return (bool) $ast->value; return (bool) $ast->value;
} }
return null; return null;

View File

@ -45,7 +45,7 @@ class CustomScalarType extends ScalarType
* @param $valueAST * @param $valueAST
* @return mixed * @return mixed
*/ */
public function parseLiteral(/* GraphQL\Language\AST\Value */ $valueAST) public function parseLiteral(/* GraphQL\Language\AST\ValueNode */ $valueAST)
{ {
return call_user_func($this->config['parseLiteral'], $valueAST); return call_user_func($this->config['parseLiteral'], $valueAST);
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Type\Definition; namespace GraphQL\Type\Definition;
use GraphQL\Language\AST\EnumValue; use GraphQL\Language\AST\EnumValueNode;
use GraphQL\Utils; use GraphQL\Utils;
/** /**
@ -95,7 +95,7 @@ class EnumType extends Type implements InputType, OutputType, LeafType
*/ */
public function parseLiteral($value) public function parseLiteral($value)
{ {
if ($value instanceof EnumValue) { if ($value instanceof EnumValueNode) {
$lookup = $this->getNameLookup(); $lookup = $this->getNameLookup();
if (isset($lookup[$value->value])) { if (isset($lookup[$value->value])) {
$enumValue = $lookup[$value->value]; $enumValue = $lookup[$value->value];
@ -124,7 +124,7 @@ class EnumType extends Type implements InputType, OutputType, LeafType
} }
/** /**
* @return \ArrayObject<string, GraphQLEnumValueDefinition> * @return \ArrayObject<string, EnumValueDefinition>
*/ */
private function getNameLookup() private function getNameLookup()
{ {

View File

@ -6,7 +6,7 @@ namespace GraphQL\Type\Definition;
* Class FieldArgument * Class FieldArgument
* *
* @package GraphQL\Type\Definition * @package GraphQL\Type\Definition
* @todo Rename to Argument as it is also applicable to directives, not only fields * @todo Rename to ArgumentNode as it is also applicable to directives, not only fields
*/ */
class FieldArgument class FieldArgument
{ {

View File

@ -2,8 +2,8 @@
namespace GraphQL\Type\Definition; namespace GraphQL\Type\Definition;
use GraphQL\Error\InvariantViolation; use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\FloatValue; use GraphQL\Language\AST\FloatValueNode;
use GraphQL\Language\AST\IntValue; use GraphQL\Language\AST\IntValueNode;
use GraphQL\Utils; use GraphQL\Utils;
/** /**
@ -66,7 +66,7 @@ values as specified by
*/ */
public function parseLiteral($ast) public function parseLiteral($ast)
{ {
if ($ast instanceof FloatValue || $ast instanceof IntValue) { if ($ast instanceof FloatValueNode || $ast instanceof IntValueNode) {
return (float) $ast->value; return (float) $ast->value;
} }
return null; return null;

View File

@ -1,8 +1,8 @@
<?php <?php
namespace GraphQL\Type\Definition; namespace GraphQL\Type\Definition;
use GraphQL\Language\AST\IntValue; use GraphQL\Language\AST\IntValueNode;
use GraphQL\Language\AST\StringValue; use GraphQL\Language\AST\StringValueNode;
/** /**
* Class IDType * Class IDType
@ -55,7 +55,7 @@ When expected as an input type, any string (such as `"4"`) or integer
*/ */
public function parseLiteral($ast) public function parseLiteral($ast)
{ {
if ($ast instanceof StringValue || $ast instanceof IntValue) { if ($ast instanceof StringValueNode || $ast instanceof IntValueNode) {
return $ast->value; return $ast->value;
} }
return null; return null;

View File

@ -2,8 +2,8 @@
namespace GraphQL\Type\Definition; namespace GraphQL\Type\Definition;
use GraphQL\Error\InvariantViolation; use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\IntValue; use GraphQL\Language\AST\IntValueNode;
use GraphQL\Language\AST\Value; use GraphQL\Language\AST\ValueNode;
use GraphQL\Utils; use GraphQL\Utils;
/** /**
@ -78,7 +78,7 @@ values. Int can represent values between -(2^31) and 2^31 - 1. ';
*/ */
public function parseLiteral($ast) public function parseLiteral($ast)
{ {
if ($ast instanceof IntValue) { if ($ast instanceof IntValueNode) {
$val = (int) $ast->value; $val = (int) $ast->value;
if ($ast->value === (string) $val && self::MIN_INT <= $val && $val <= self::MAX_INT) { if ($ast->value === (string) $val && self::MIN_INT <= $val && $val <= self::MAX_INT) {
return $val; return $val;

View File

@ -1,12 +1,12 @@
<?php <?php
namespace GraphQL\Type\Definition; namespace GraphQL\Type\Definition;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\AST\Selection; use GraphQL\Language\AST\SelectionNode;
use GraphQL\Language\AST\SelectionSet; use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Schema; use GraphQL\Schema;
use GraphQL\Utils; use GraphQL\Utils;
@ -22,7 +22,7 @@ class ResolveInfo
public $fieldName; public $fieldName;
/** /**
* @var Field[] * @var FieldNode[]
*/ */
public $fieldASTs; public $fieldASTs;
@ -57,7 +57,7 @@ class ResolveInfo
public $rootValue; public $rootValue;
/** /**
* @var OperationDefinition * @var OperationDefinitionNode
*/ */
public $operation; public $operation;
@ -106,7 +106,7 @@ class ResolveInfo
{ {
$fields = []; $fields = [];
/** @var Field $fieldAST */ /** @var FieldNode $fieldAST */
foreach ($this->fieldASTs as $fieldAST) { foreach ($this->fieldASTs as $fieldAST) {
$fields = array_merge_recursive($fields, $this->foldSelectionSet($fieldAST->selectionSet, $depth)); $fields = array_merge_recursive($fields, $this->foldSelectionSet($fieldAST->selectionSet, $depth));
} }
@ -114,19 +114,19 @@ class ResolveInfo
return $fields; return $fields;
} }
private function foldSelectionSet(SelectionSet $selectionSet, $descend) private function foldSelectionSet(SelectionSetNode $selectionSet, $descend)
{ {
$fields = []; $fields = [];
foreach ($selectionSet->selections as $selectionAST) { foreach ($selectionSet->selections as $selectionAST) {
if ($selectionAST instanceof Field) { if ($selectionAST instanceof FieldNode) {
$fields[$selectionAST->name->value] = $descend > 0 && !empty($selectionAST->selectionSet) $fields[$selectionAST->name->value] = $descend > 0 && !empty($selectionAST->selectionSet)
? $this->foldSelectionSet($selectionAST->selectionSet, $descend - 1) ? $this->foldSelectionSet($selectionAST->selectionSet, $descend - 1)
: true; : true;
} else if ($selectionAST instanceof FragmentSpread) { } else if ($selectionAST instanceof FragmentSpreadNode) {
$spreadName = $selectionAST->name->value; $spreadName = $selectionAST->name->value;
if (isset($this->fragments[$spreadName])) { if (isset($this->fragments[$spreadName])) {
/** @var FragmentDefinition $fragment */ /** @var FragmentDefinitionNode $fragment */
$fragment = $this->fragments[$spreadName]; $fragment = $this->fragments[$spreadName];
$fields += $this->foldSelectionSet($fragment->selectionSet, $descend); $fields += $this->foldSelectionSet($fragment->selectionSet, $descend);
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace GraphQL\Type\Definition; namespace GraphQL\Type\Definition;
use GraphQL\Language\AST\StringValue; use GraphQL\Language\AST\StringValueNode;
/** /**
* Class StringType * Class StringType
@ -52,7 +52,7 @@ represent free-form human-readable text.';
*/ */
public function parseLiteral($ast) public function parseLiteral($ast)
{ {
if ($ast instanceof StringValue) { if ($ast instanceof StringValueNode) {
return $ast->value; return $ast->value;
} }
return null; return null;

View File

@ -2,19 +2,19 @@
namespace GraphQL\Utils; namespace GraphQL\Utils;
use GraphQL\Error\InvariantViolation; use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\BooleanValue; use GraphQL\Language\AST\BooleanValueNode;
use GraphQL\Language\AST\EnumValue; use GraphQL\Language\AST\EnumValueNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FloatValue; use GraphQL\Language\AST\FloatValueNode;
use GraphQL\Language\AST\IntValue; use GraphQL\Language\AST\IntValueNode;
use GraphQL\Language\AST\ListValue; use GraphQL\Language\AST\ListValueNode;
use GraphQL\Language\AST\Name; use GraphQL\Language\AST\NameNode;
use GraphQL\Language\AST\NullValue; use GraphQL\Language\AST\NullValueNode;
use GraphQL\Language\AST\ObjectField; use GraphQL\Language\AST\ObjectFieldNode;
use GraphQL\Language\AST\ObjectValue; use GraphQL\Language\AST\ObjectValueNode;
use GraphQL\Language\AST\StringValue; use GraphQL\Language\AST\StringValueNode;
use GraphQL\Language\AST\Value; use GraphQL\Language\AST\ValueNode;
use GraphQL\Language\AST\Variable; use GraphQL\Language\AST\VariableNode;
use GraphQL\Type\Definition\EnumType; use GraphQL\Type\Definition\EnumType;
use GraphQL\Type\Definition\IDType; use GraphQL\Type\Definition\IDType;
use GraphQL\Type\Definition\InputObjectType; use GraphQL\Type\Definition\InputObjectType;
@ -50,20 +50,20 @@ class AST
* *
* @param $value * @param $value
* @param InputType $type * @param InputType $type
* @return ObjectValue|ListValue|BooleanValue|IntValue|FloatValue|EnumValue|StringValue|NullValue * @return ObjectValueNode|ListValueNode|BooleanValueNode|IntValueNode|FloatValueNode|EnumValueNode|StringValueNode|NullValueNode
*/ */
static function astFromValue($value, InputType $type) static function astFromValue($value, InputType $type)
{ {
if ($type instanceof NonNull) { if ($type instanceof NonNull) {
$astValue = self::astFromValue($value, $type->getWrappedType()); $astValue = self::astFromValue($value, $type->getWrappedType());
if ($astValue instanceof NullValue) { if ($astValue instanceof NullValueNode) {
return null; return null;
} }
return $astValue; return $astValue;
} }
if ($value === null) { if ($value === null) {
return new NullValue([]); return new NullValueNode([]);
} }
// Convert PHP array to GraphQL list. If the GraphQLType is a list, but // Convert PHP array to GraphQL list. If the GraphQLType is a list, but
@ -78,7 +78,7 @@ class AST
$valuesASTs[] = $itemAST; $valuesASTs[] = $itemAST;
} }
} }
return new ListValue(['values' => $valuesASTs]); return new ListValueNode(['values' => $valuesASTs]);
} }
return self::astFromValue($value, $itemType); return self::astFromValue($value, $itemType);
} }
@ -117,14 +117,14 @@ class AST
$fieldNode = self::astFromValue($fieldValue, $field->getType()); $fieldNode = self::astFromValue($fieldValue, $field->getType());
if ($fieldNode) { if ($fieldNode) {
$fieldASTs[] = new ObjectField([ $fieldASTs[] = new ObjectFieldNode([
'name' => new Name(['value' => $fieldName]), 'name' => new NameNode(['value' => $fieldName]),
'value' => $fieldNode 'value' => $fieldNode
]); ]);
} }
} }
} }
return new ObjectValue(['fields' => $fieldASTs]); return new ObjectValueNode(['fields' => $fieldASTs]);
} }
// Since value is an internally represented value, it must be serialized // Since value is an internally represented value, it must be serialized
@ -141,32 +141,32 @@ class AST
// Others serialize based on their corresponding PHP scalar types. // Others serialize based on their corresponding PHP scalar types.
if (is_bool($serialized)) { if (is_bool($serialized)) {
return new BooleanValue(['value' => $serialized]); return new BooleanValueNode(['value' => $serialized]);
} }
if (is_int($serialized)) { if (is_int($serialized)) {
return new IntValue(['value' => $serialized]); return new IntValueNode(['value' => $serialized]);
} }
if (is_float($serialized)) { if (is_float($serialized)) {
if ((int) $serialized == $serialized) { if ((int) $serialized == $serialized) {
return new IntValue(['value' => $serialized]); return new IntValueNode(['value' => $serialized]);
} }
return new FloatValue(['value' => $serialized]); return new FloatValueNode(['value' => $serialized]);
} }
if (is_string($serialized)) { if (is_string($serialized)) {
// Enum types use Enum literals. // Enum types use Enum literals.
if ($type instanceof EnumType) { if ($type instanceof EnumType) {
return new EnumValue(['value' => $serialized]); return new EnumValueNode(['value' => $serialized]);
} }
// ID types can use Int literals. // ID types can use Int literals.
$asInt = (int) $serialized; $asInt = (int) $serialized;
if ($type instanceof IDType && (string) $asInt === $serialized) { if ($type instanceof IDType && (string) $asInt === $serialized) {
return new IntValue(['value' => $serialized]); return new IntValueNode(['value' => $serialized]);
} }
// Use json_encode, which uses the same string encoding as GraphQL, // Use json_encode, which uses the same string encoding as GraphQL,
// then remove the quotes. // then remove the quotes.
return new StringValue([ return new StringValueNode([
'value' => substr(json_encode($serialized), 1, -1) 'value' => substr(json_encode($serialized), 1, -1)
]); ]);
} }
@ -210,19 +210,19 @@ class AST
} }
if ($type instanceof NonNull) { if ($type instanceof NonNull) {
if ($valueAST instanceof NullValue) { if ($valueAST instanceof NullValueNode) {
// Invalid: intentionally return no value. // Invalid: intentionally return no value.
return $undefined; return $undefined;
} }
return self::valueFromAST($valueAST, $type->getWrappedType(), $variables); return self::valueFromAST($valueAST, $type->getWrappedType(), $variables);
} }
if ($valueAST instanceof NullValue) { if ($valueAST instanceof NullValueNode) {
// This is explicitly returning the value null. // This is explicitly returning the value null.
return null; return null;
} }
if ($valueAST instanceof Variable) { if ($valueAST instanceof VariableNode) {
$variableName = $valueAST->name->value; $variableName = $valueAST->name->value;
if (!$variables || !array_key_exists($variableName, $variables)) { if (!$variables || !array_key_exists($variableName, $variables)) {
@ -238,7 +238,7 @@ class AST
if ($type instanceof ListOfType) { if ($type instanceof ListOfType) {
$itemType = $type->getWrappedType(); $itemType = $type->getWrappedType();
if ($valueAST instanceof ListValue) { if ($valueAST instanceof ListValueNode) {
$coercedValues = []; $coercedValues = [];
$itemASTs = $valueAST->values; $itemASTs = $valueAST->values;
foreach ($itemASTs as $itemAST) { foreach ($itemASTs as $itemAST) {
@ -270,7 +270,7 @@ class AST
} }
if ($type instanceof InputObjectType) { if ($type instanceof InputObjectType) {
if (!$valueAST instanceof ObjectValue) { if (!$valueAST instanceof ObjectValueNode) {
// Invalid: intentionally return no value. // Invalid: intentionally return no value.
return $undefined; return $undefined;
} }
@ -279,7 +279,7 @@ class AST
$fields = $type->getFields(); $fields = $type->getFields();
$fieldASTs = Utils::keyMap($valueAST->fields, function($field) {return $field->name->value;}); $fieldASTs = Utils::keyMap($valueAST->fields, function($field) {return $field->name->value;});
foreach ($fields as $field) { foreach ($fields as $field) {
/** @var Value $fieldAST */ /** @var ValueNode $fieldAST */
$fieldName = $field->name; $fieldName = $field->name;
$fieldAST = isset($fieldASTs[$fieldName]) ? $fieldASTs[$fieldName] : null; $fieldAST = isset($fieldASTs[$fieldName]) ? $fieldASTs[$fieldName] : null;
@ -329,7 +329,7 @@ class AST
*/ */
private static function isMissingVariable($valueAST, $variables) private static function isMissingVariable($valueAST, $variables)
{ {
return $valueAST instanceof Variable && return $valueAST instanceof VariableNode &&
(!$variables || !array_key_exists($valueAST->name->value, $variables)); (!$variables || !array_key_exists($valueAST->name->value, $variables));
} }
} }

View File

@ -1,12 +1,12 @@
<?php <?php
namespace GraphQL\Utils; namespace GraphQL\Utils;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\ListType; use GraphQL\Language\AST\ListTypeNode;
use GraphQL\Language\AST\NamedType; use GraphQL\Language\AST\NamedTypeNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\NonNullType; use GraphQL\Language\AST\NonNullTypeNode;
use GraphQL\Schema; use GraphQL\Schema;
use GraphQL\Type\Definition\AbstractType; use GraphQL\Type\Definition\AbstractType;
use GraphQL\Type\Definition\CompositeType; use GraphQL\Type\Definition\CompositeType;
@ -149,16 +149,16 @@ class TypeInfo
*/ */
public static function typeFromAST(Schema $schema, $inputTypeAst) public static function typeFromAST(Schema $schema, $inputTypeAst)
{ {
if ($inputTypeAst instanceof ListType) { if ($inputTypeAst instanceof ListTypeNode) {
$innerType = self::typeFromAST($schema, $inputTypeAst->type); $innerType = self::typeFromAST($schema, $inputTypeAst->type);
return $innerType ? new ListOfType($innerType) : null; return $innerType ? new ListOfType($innerType) : null;
} }
if ($inputTypeAst instanceof NonNullType) { if ($inputTypeAst instanceof NonNullTypeNode) {
$innerType = self::typeFromAST($schema, $inputTypeAst->type); $innerType = self::typeFromAST($schema, $inputTypeAst->type);
return $innerType ? new NonNull($innerType) : null; return $innerType ? new NonNull($innerType) : null;
} }
Utils::invariant($inputTypeAst && $inputTypeAst instanceof NamedType, 'Must be a named type'); Utils::invariant($inputTypeAst && $inputTypeAst instanceof NamedTypeNode, 'Must be a named type');
return $schema->getType($inputTypeAst->name->value); return $schema->getType($inputTypeAst->name->value);
} }
@ -169,7 +169,7 @@ class TypeInfo
* *
* @return FieldDefinition * @return FieldDefinition
*/ */
static private function getFieldDefinition(Schema $schema, Type $parentType, Field $fieldAST) static private function getFieldDefinition(Schema $schema, Type $parentType, FieldNode $fieldAST)
{ {
$name = $fieldAST->name->value; $name = $fieldAST->name->value;
$schemaMeta = Introspection::schemaMetaFieldDef(); $schemaMeta = Introspection::schemaMetaFieldDef();

View File

@ -3,14 +3,14 @@ namespace GraphQL\Validator;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation; use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\ListValue; use GraphQL\Language\AST\ListValueNode;
use GraphQL\Language\AST\Document; use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\NullValue; use GraphQL\Language\AST\NullValueNode;
use GraphQL\Language\AST\Value; use GraphQL\Language\AST\ValueNode;
use GraphQL\Language\AST\Variable; use GraphQL\Language\AST\VariableNode;
use GraphQL\Language\Printer; use GraphQL\Language\Printer;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
use GraphQL\Language\VisitorOperation; use GraphQL\Language\VisitorOperation;
@ -120,7 +120,7 @@ class DocumentValidator
self::$rules[$name] = $rule; self::$rules[$name] = $rule;
} }
public static function validate(Schema $schema, Document $ast, array $rules = null) public static function validate(Schema $schema, DocumentNode $ast, array $rules = null)
{ {
$typeInfo = new TypeInfo($schema); $typeInfo = new TypeInfo($schema);
$errors = static::visitUsingRules($schema, $typeInfo, $ast, $rules ?: static::allRules()); $errors = static::visitUsingRules($schema, $typeInfo, $ast, $rules ?: static::allRules());
@ -157,26 +157,26 @@ class DocumentValidator
{ {
// A value must be provided if the type is non-null. // A value must be provided if the type is non-null.
if ($type instanceof NonNull) { if ($type instanceof NonNull) {
if (!$valueAST || $valueAST instanceof NullValue) { if (!$valueAST || $valueAST instanceof NullValueNode) {
return [ 'Expected "' . Utils::printSafe($type) . '", found null.' ]; return [ 'Expected "' . Utils::printSafe($type) . '", found null.' ];
} }
return static::isValidLiteralValue($type->getWrappedType(), $valueAST); return static::isValidLiteralValue($type->getWrappedType(), $valueAST);
} }
if (!$valueAST || $valueAST instanceof NullValue) { if (!$valueAST || $valueAST instanceof NullValueNode) {
return []; return [];
} }
// This function only tests literals, and assumes variables will provide // This function only tests literals, and assumes variables will provide
// values of the correct type. // values of the correct type.
if ($valueAST instanceof Variable) { if ($valueAST instanceof VariableNode) {
return []; return [];
} }
// Lists accept a non-list value as a list of one. // Lists accept a non-list value as a list of one.
if ($type instanceof ListOfType) { if ($type instanceof ListOfType) {
$itemType = $type->getWrappedType(); $itemType = $type->getWrappedType();
if ($valueAST instanceof ListValue) { if ($valueAST instanceof ListValueNode) {
$errors = []; $errors = [];
foreach($valueAST->values as $index => $itemAST) { foreach($valueAST->values as $index => $itemAST) {
$tmp = static::isValidLiteralValue($itemType, $itemAST); $tmp = static::isValidLiteralValue($itemType, $itemAST);
@ -250,11 +250,11 @@ class DocumentValidator
* *
* @param Schema $schema * @param Schema $schema
* @param TypeInfo $typeInfo * @param TypeInfo $typeInfo
* @param Document $documentAST * @param DocumentNode $documentAST
* @param array $rules * @param array $rules
* @return array * @return array
*/ */
public static function visitUsingRules(Schema $schema, TypeInfo $typeInfo, Document $documentAST, array $rules) public static function visitUsingRules(Schema $schema, TypeInfo $typeInfo, DocumentNode $documentAST, array $rules)
{ {
$context = new ValidationContext($schema, $documentAST, $typeInfo); $context = new ValidationContext($schema, $documentAST, $typeInfo);
$visitors = []; $visitors = [];

View File

@ -2,13 +2,13 @@
namespace GraphQL\Validator\Rules; namespace GraphQL\Validator\Rules;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\SelectionSet; use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Type\Definition\Type; use GraphQL\Type\Definition\Type;
use GraphQL\Type\Introspection; use GraphQL\Type\Introspection;
use GraphQL\Utils\TypeInfo; use GraphQL\Utils\TypeInfo;
@ -19,12 +19,12 @@ abstract class AbstractQuerySecurity
const DISABLED = 0; const DISABLED = 0;
/** /**
* @var FragmentDefinition[] * @var FragmentDefinitionNode[]
*/ */
private $fragments = []; private $fragments = [];
/** /**
* @return \GraphQL\Language\AST\FragmentDefinition[] * @return \GraphQL\Language\AST\FragmentDefinitionNode[]
*/ */
protected function getFragments() protected function getFragments()
{ {
@ -49,13 +49,13 @@ abstract class AbstractQuerySecurity
// Importantly this does not include inline fragments. // Importantly this does not include inline fragments.
$definitions = $context->getDocument()->definitions; $definitions = $context->getDocument()->definitions;
foreach ($definitions as $node) { foreach ($definitions as $node) {
if ($node instanceof FragmentDefinition) { if ($node instanceof FragmentDefinitionNode) {
$this->fragments[$node->name->value] = $node; $this->fragments[$node->name->value] = $node;
} }
} }
} }
protected function getFragment(FragmentSpread $fragmentSpread) protected function getFragment(FragmentSpreadNode $fragmentSpread)
{ {
$spreadName = $fragmentSpread->name->value; $spreadName = $fragmentSpread->name->value;
$fragments = $this->getFragments(); $fragments = $this->getFragments();
@ -87,13 +87,13 @@ abstract class AbstractQuerySecurity
* *
* @param ValidationContext $context * @param ValidationContext $context
* @param Type|null $parentType * @param Type|null $parentType
* @param SelectionSet $selectionSet * @param SelectionSetNode $selectionSet
* @param \ArrayObject $visitedFragmentNames * @param \ArrayObject $visitedFragmentNames
* @param \ArrayObject $astAndDefs * @param \ArrayObject $astAndDefs
* *
* @return \ArrayObject * @return \ArrayObject
*/ */
protected function collectFieldASTsAndDefs(ValidationContext $context, $parentType, SelectionSet $selectionSet, \ArrayObject $visitedFragmentNames = null, \ArrayObject $astAndDefs = null) protected function collectFieldASTsAndDefs(ValidationContext $context, $parentType, SelectionSetNode $selectionSet, \ArrayObject $visitedFragmentNames = null, \ArrayObject $astAndDefs = null)
{ {
$_visitedFragmentNames = $visitedFragmentNames ?: new \ArrayObject(); $_visitedFragmentNames = $visitedFragmentNames ?: new \ArrayObject();
$_astAndDefs = $astAndDefs ?: new \ArrayObject(); $_astAndDefs = $astAndDefs ?: new \ArrayObject();
@ -101,7 +101,7 @@ abstract class AbstractQuerySecurity
foreach ($selectionSet->selections as $selection) { foreach ($selectionSet->selections as $selection) {
switch ($selection->kind) { switch ($selection->kind) {
case NodeType::FIELD: case NodeType::FIELD:
/* @var Field $selection */ /* @var FieldNode $selection */
$fieldName = $selection->name->value; $fieldName = $selection->name->value;
$fieldDef = null; $fieldDef = null;
if ($parentType && method_exists($parentType, 'getFields')) { if ($parentType && method_exists($parentType, 'getFields')) {
@ -128,7 +128,7 @@ abstract class AbstractQuerySecurity
$_astAndDefs[$responseName][] = [$selection, $fieldDef]; $_astAndDefs[$responseName][] = [$selection, $fieldDef];
break; break;
case NodeType::INLINE_FRAGMENT: case NodeType::INLINE_FRAGMENT:
/* @var InlineFragment $selection */ /* @var InlineFragmentNode $selection */
$_astAndDefs = $this->collectFieldASTsAndDefs( $_astAndDefs = $this->collectFieldASTsAndDefs(
$context, $context,
TypeInfo::typeFromAST($context->getSchema(), $selection->typeCondition), TypeInfo::typeFromAST($context->getSchema(), $selection->typeCondition),
@ -138,7 +138,7 @@ abstract class AbstractQuerySecurity
); );
break; break;
case NodeType::FRAGMENT_SPREAD: case NodeType::FRAGMENT_SPREAD:
/* @var FragmentSpread $selection */ /* @var FragmentSpreadNode $selection */
$fragName = $selection->name->value; $fragName = $selection->name->value;
if (empty($_visitedFragmentNames[$fragName])) { if (empty($_visitedFragmentNames[$fragName])) {
@ -162,7 +162,7 @@ abstract class AbstractQuerySecurity
return $_astAndDefs; return $_astAndDefs;
} }
protected function getFieldName(Field $node) protected function getFieldName(FieldNode $node)
{ {
$fieldName = $node->name->value; $fieldName = $node->name->value;
$responseName = $node->alias ? $node->alias->value : $fieldName; $responseName = $node->alias ? $node->alias->value : $fieldName;

View File

@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument; use GraphQL\Language\AST\ArgumentNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\Printer; use GraphQL\Language\Printer;
@ -26,7 +26,7 @@ class ArgumentsOfCorrectType
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::ARGUMENT => function(Argument $argAST) use ($context) { NodeType::ARGUMENT => function(ArgumentNode $argAST) use ($context) {
$argDef = $context->getArgument(); $argDef = $context->getArgument();
if ($argDef) { if ($argDef) {
$errors = DocumentValidator::isValidLiteralValue($argDef->getType(), $argAST->value); $errors = DocumentValidator::isValidLiteralValue($argDef->getType(), $argAST->value);

View File

@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\VariableDefinition; use GraphQL\Language\AST\VariableDefinitionNode;
use GraphQL\Language\Printer; use GraphQL\Language\Printer;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
use GraphQL\Type\Definition\NonNull; use GraphQL\Type\Definition\NonNull;
@ -30,7 +30,7 @@ class DefaultValuesOfCorrectType
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $varDefAST) use ($context) { NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $varDefAST) use ($context) {
$name = $varDefAST->variable->name->value; $name = $varDefAST->variable->name->value;
$defaultValue = $varDefAST->defaultValue; $defaultValue = $varDefAST->defaultValue;
$type = $context->getInputType(); $type = $context->getInputType();

View File

@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Schema; use GraphQL\Schema;
@ -37,7 +37,7 @@ class FieldsOnCorrectType
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::FIELD => function(Field $node) use ($context) { NodeType::FIELD => function(FieldNode $node) use ($context) {
$type = $context->getParentType(); $type = $context->getParentType();
if ($type) { if ($type) {
$fieldDef = $context->getFieldDef(); $fieldDef = $context->getFieldDef();

View File

@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\Printer; use GraphQL\Language\Printer;
@ -28,7 +28,7 @@ class FragmentsOnCompositeTypes
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::INLINE_FRAGMENT => function(InlineFragment $node) use ($context) { NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) {
$type = $context->getType(); $type = $context->getType();
if ($node->typeCondition && $type && !Type::isCompositeType($type)) { if ($node->typeCondition && $type && !Type::isCompositeType($type)) {
@ -38,7 +38,7 @@ class FragmentsOnCompositeTypes
)); ));
} }
}, },
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinition $node) use ($context) { NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) use ($context) {
$type = $context->getType(); $type = $context->getType();
if ($type && !Type::isCompositeType($type)) { if ($type && !Type::isCompositeType($type)) {

View File

@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument; use GraphQL\Language\AST\ArgumentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Utils; use GraphQL\Utils;
@ -25,7 +25,7 @@ class KnownArgumentNames
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::ARGUMENT => function(Argument $node, $key, $parent, $path, $ancestors) use ($context) { NodeType::ARGUMENT => function(ArgumentNode $node, $key, $parent, $path, $ancestors) use ($context) {
$argumentOf = $ancestors[count($ancestors) - 1]; $argumentOf = $ancestors[count($ancestors) - 1];
if ($argumentOf->kind === NodeType::FIELD) { if ($argumentOf->kind === NodeType::FIELD) {
$fieldDef = $context->getFieldDef(); $fieldDef = $context->getFieldDef();

View File

@ -3,14 +3,14 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Directive; use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Validator\Messages; use GraphQL\Validator\Messages;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
use GraphQL\Type\Definition\Directive as DirectiveDef; use GraphQL\Type\Definition\Directive as DirectiveDef;
@ -30,7 +30,7 @@ class KnownDirectives
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::DIRECTIVE => function (Directive $node, $key, $parent, $path, $ancestors) use ($context) { NodeType::DIRECTIVE => function (DirectiveNode $node, $key, $parent, $path, $ancestors) use ($context) {
$directiveDef = null; $directiveDef = null;
foreach ($context->getSchema()->getDirectives() as $def) { foreach ($context->getSchema()->getDirectives() as $def) {
if ($def->name === $node->name->value) { if ($def->name === $node->name->value) {

View File

@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -18,7 +18,7 @@ class KnownFragmentNames
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::FRAGMENT_SPREAD => function(FragmentSpread $node) use ($context) { NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) {
$fragmentName = $node->name->value; $fragmentName = $node->name->value;
$fragment = $context->getFragment($fragmentName); $fragment = $context->getFragment($fragmentName);
if (!$fragment) { if (!$fragment) {

View File

@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\NamedType; use GraphQL\Language\AST\NamedTypeNode;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -25,7 +25,7 @@ class KnownTypeNames
NodeType::UNION_TYPE_DEFINITION => $skip, NodeType::UNION_TYPE_DEFINITION => $skip,
NodeType::INPUT_OBJECT_TYPE_DEFINITION => $skip, NodeType::INPUT_OBJECT_TYPE_DEFINITION => $skip,
NodeType::NAMED_TYPE => function(NamedType $node, $key) use ($context) { NodeType::NAMED_TYPE => function(NamedTypeNode $node, $key) use ($context) {
$typeName = $node->name->value; $typeName = $node->name->value;
$type = $context->getSchema()->getType($typeName); $type = $context->getSchema()->getType($typeName);
if (!$type) { if (!$type) {

View File

@ -2,10 +2,10 @@
namespace GraphQL\Validator\Rules; namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Document; use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Utils; use GraphQL\Utils;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -26,7 +26,7 @@ class LoneAnonymousOperation
{ {
$operationCount = 0; $operationCount = 0;
return [ return [
NodeType::DOCUMENT => function(Document $node) use (&$operationCount) { NodeType::DOCUMENT => function(DocumentNode $node) use (&$operationCount) {
$tmp = Utils::filter( $tmp = Utils::filter(
$node->definitions, $node->definitions,
function ($definition) { function ($definition) {
@ -35,7 +35,7 @@ class LoneAnonymousOperation
); );
$operationCount = count($tmp); $operationCount = count($tmp);
}, },
NodeType::OPERATION_DEFINITION => function(OperationDefinition $node) use (&$operationCount, $context) { NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use (&$operationCount, $context) {
if (!$node->name && $operationCount > 1) { if (!$node->name && $operationCount > 1) {
$context->reportError( $context->reportError(
new Error(self::anonOperationNotAloneMessage(), [$node]) new Error(self::anonOperationNotAloneMessage(), [$node])

View File

@ -10,8 +10,8 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
@ -48,7 +48,7 @@ class NoFragmentCycles
NodeType::OPERATION_DEFINITION => function () { NodeType::OPERATION_DEFINITION => function () {
return Visitor::skipNode(); return Visitor::skipNode();
}, },
NodeType::FRAGMENT_DEFINITION => function (FragmentDefinition $node) use ($context) { NodeType::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
if (!isset($this->visitedFrags[$node->name->value])) { if (!isset($this->visitedFrags[$node->name->value])) {
$this->detectCycleRecursive($node, $context); $this->detectCycleRecursive($node, $context);
} }
@ -57,7 +57,7 @@ class NoFragmentCycles
]; ];
} }
private function detectCycleRecursive(FragmentDefinition $fragment, ValidationContext $context) private function detectCycleRecursive(FragmentDefinitionNode $fragment, ValidationContext $context)
{ {
$fragmentName = $fragment->name->value; $fragmentName = $fragment->name->value;
$this->visitedFrags[$fragmentName] = true; $this->visitedFrags[$fragmentName] = true;

View File

@ -3,13 +3,13 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\AST\Variable; use GraphQL\Language\AST\VariableNode;
use GraphQL\Language\AST\VariableDefinition; use GraphQL\Language\AST\VariableDefinitionNode;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
use GraphQL\Validator\Messages; use GraphQL\Validator\Messages;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -40,7 +40,7 @@ class NoUndefinedVariables
'enter' => function() use (&$variableNameDefined) { 'enter' => function() use (&$variableNameDefined) {
$variableNameDefined = []; $variableNameDefined = [];
}, },
'leave' => function(OperationDefinition $operation) use (&$variableNameDefined, $context) { 'leave' => function(OperationDefinitionNode $operation) use (&$variableNameDefined, $context) {
$usages = $context->getRecursiveVariableUsages($operation); $usages = $context->getRecursiveVariableUsages($operation);
foreach ($usages as $usage) { foreach ($usages as $usage) {
@ -59,7 +59,7 @@ class NoUndefinedVariables
} }
} }
], ],
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $def) use (&$variableNameDefined) { NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $def) use (&$variableNameDefined) {
$variableNameDefined[$def->variable->name->value] = true; $variableNameDefined[$def->variable->name->value] = true;
} }
]; ];

View File

@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
@ -32,7 +32,7 @@ class NoUnusedFragments
$this->operationDefs[] = $node; $this->operationDefs[] = $node;
return Visitor::skipNode(); return Visitor::skipNode();
}, },
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinition $def) { NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $def) {
$this->fragmentDefs[] = $def; $this->fragmentDefs[] = $def;
return Visitor::skipNode(); return Visitor::skipNode();
}, },

View File

@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
use GraphQL\Validator\Messages; use GraphQL\Validator\Messages;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -30,7 +30,7 @@ class NoUnusedVariables
'enter' => function() { 'enter' => function() {
$this->variableDefs = []; $this->variableDefs = [];
}, },
'leave' => function(OperationDefinition $operation) use ($context) { 'leave' => function(OperationDefinitionNode $operation) use ($context) {
$variableNameUsed = []; $variableNameUsed = [];
$usages = $context->getRecursiveVariableUsages($operation); $usages = $context->getRecursiveVariableUsages($operation);
$opName = $operation->name ? $operation->name->value : null; $opName = $operation->name ? $operation->name->value : null;

View File

@ -3,14 +3,14 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Directive; use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\NamedType; use GraphQL\Language\AST\NamedTypeNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\SelectionSet; use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Language\Printer; use GraphQL\Language\Printer;
use GraphQL\Type\Definition\ListOfType; use GraphQL\Type\Definition\ListOfType;
use GraphQL\Type\Definition\NonNull; use GraphQL\Type\Definition\NonNull;
@ -56,7 +56,7 @@ class OverlappingFieldsCanBeMerged
NodeType::SELECTION_SET => [ NodeType::SELECTION_SET => [
// Note: we validate on the reverse traversal so deeper conflicts will be // Note: we validate on the reverse traversal so deeper conflicts will be
// caught first, for clearer error messages. // caught first, for clearer error messages.
'leave' => function(SelectionSet $selectionSet) use ($context) { 'leave' => function(SelectionSetNode $selectionSet) use ($context) {
$fieldMap = $this->collectFieldASTsAndDefs( $fieldMap = $this->collectFieldASTsAndDefs(
$context, $context,
$context->getParentType(), $context->getParentType(),
@ -110,8 +110,8 @@ class OverlappingFieldsCanBeMerged
/** /**
* @param $parentFieldsAreMutuallyExclusive * @param $parentFieldsAreMutuallyExclusive
* @param $responseName * @param $responseName
* @param [Field, GraphQLFieldDefinition] $pair1 * @param [FieldNode, GraphQLFieldDefinition] $pair1
* @param [Field, GraphQLFieldDefinition] $pair2 * @param [FieldNode, GraphQLFieldDefinition] $pair2
* @param ValidationContext $context * @param ValidationContext $context
* @return array|null * @return array|null
*/ */
@ -206,9 +206,9 @@ class OverlappingFieldsCanBeMerged
} }
private function getSubfieldMap( private function getSubfieldMap(
Field $ast1, FieldNode $ast1,
$type1, $type1,
Field $ast2, FieldNode $ast2,
$type2, $type2,
ValidationContext $context ValidationContext $context
) { ) {
@ -236,8 +236,8 @@ class OverlappingFieldsCanBeMerged
private function subfieldConflicts( private function subfieldConflicts(
array $conflicts, array $conflicts,
$responseName, $responseName,
Field $ast1, FieldNode $ast1,
Field $ast2 FieldNode $ast2
) )
{ {
if (!empty($conflicts)) { if (!empty($conflicts)) {
@ -303,12 +303,12 @@ class OverlappingFieldsCanBeMerged
* *
* @param ValidationContext $context * @param ValidationContext $context
* @param mixed $parentType * @param mixed $parentType
* @param SelectionSet $selectionSet * @param SelectionSetNode $selectionSet
* @param \ArrayObject $visitedFragmentNames * @param \ArrayObject $visitedFragmentNames
* @param \ArrayObject $astAndDefs * @param \ArrayObject $astAndDefs
* @return mixed * @return mixed
*/ */
private function collectFieldASTsAndDefs(ValidationContext $context, $parentType, SelectionSet $selectionSet, \ArrayObject $visitedFragmentNames = null, \ArrayObject $astAndDefs = null) private function collectFieldASTsAndDefs(ValidationContext $context, $parentType, SelectionSetNode $selectionSet, \ArrayObject $visitedFragmentNames = null, \ArrayObject $astAndDefs = null)
{ {
$_visitedFragmentNames = $visitedFragmentNames ?: new \ArrayObject(); $_visitedFragmentNames = $visitedFragmentNames ?: new \ArrayObject();
$_astAndDefs = $astAndDefs ?: new \ArrayObject(); $_astAndDefs = $astAndDefs ?: new \ArrayObject();
@ -348,7 +348,7 @@ class OverlappingFieldsCanBeMerged
); );
break; break;
case NodeType::FRAGMENT_SPREAD: case NodeType::FRAGMENT_SPREAD:
/** @var FragmentSpread $selection */ /** @var FragmentSpreadNode $selection */
$fragName = $selection->name->value; $fragName = $selection->name->value;
if (!empty($_visitedFragmentNames[$fragName])) { if (!empty($_visitedFragmentNames[$fragName])) {
continue; continue;
@ -373,8 +373,8 @@ class OverlappingFieldsCanBeMerged
} }
/** /**
* @param Array<Argument | Directive> $pairs1 * @param Array<ArgumentNode | DirectiveNode> $pairs1
* @param Array<Argument | Directive> $pairs2 * @param Array<ArgumentNode | DirectiveNode> $pairs2
* @return bool|string * @return bool|string
*/ */
private function sameArguments(array $arguments1, array $arguments2) private function sameArguments(array $arguments1, array $arguments2)

View File

@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Utils; use GraphQL\Utils;
@ -26,7 +26,7 @@ class PossibleFragmentSpreads
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::INLINE_FRAGMENT => function(InlineFragment $node) use ($context) { NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) {
$fragType = $context->getType(); $fragType = $context->getType();
$parentType = $context->getParentType(); $parentType = $context->getParentType();
@ -37,7 +37,7 @@ class PossibleFragmentSpreads
)); ));
} }
}, },
NodeType::FRAGMENT_SPREAD => function(FragmentSpread $node) use ($context) { NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) {
$fragName = $node->name->value; $fragName = $node->name->value;
$fragType = $this->getFragmentType($context, $fragName); $fragType = $this->getFragmentType($context, $fragName);
$parentType = $context->getParentType(); $parentType = $context->getParentType();

View File

@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Directive; use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
@ -28,7 +28,7 @@ class ProvidedNonNullArguments
{ {
return [ return [
NodeType::FIELD => [ NodeType::FIELD => [
'leave' => function(Field $fieldAST) use ($context) { 'leave' => function(FieldNode $fieldAST) use ($context) {
$fieldDef = $context->getFieldDef(); $fieldDef = $context->getFieldDef();
if (!$fieldDef) { if (!$fieldDef) {
@ -52,7 +52,7 @@ class ProvidedNonNullArguments
} }
], ],
NodeType::DIRECTIVE => [ NodeType::DIRECTIVE => [
'leave' => function(Directive $directiveAST) use ($context) { 'leave' => function(DirectiveNode $directiveAST) use ($context) {
$directiveDef = $context->getDirective(); $directiveDef = $context->getDirective();
if (!$directiveDef) { if (!$directiveDef) {
return Visitor::skipNode(); return Visitor::skipNode();

View File

@ -4,13 +4,13 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Executor\Values; use GraphQL\Executor\Values;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\AST\SelectionSet; use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
use GraphQL\Type\Definition\FieldDefinition; use GraphQL\Type\Definition\FieldDefinition;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -78,7 +78,7 @@ class QueryComplexity extends AbstractQuerySecurity
return $this->invokeIfNeeded( return $this->invokeIfNeeded(
$context, $context,
[ [
NodeType::SELECTION_SET => function (SelectionSet $selectionSet) use ($context) { NodeType::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) {
$this->fieldAstAndDefs = $this->collectFieldASTsAndDefs( $this->fieldAstAndDefs = $this->collectFieldASTsAndDefs(
$context, $context,
$context->getParentType(), $context->getParentType(),
@ -92,7 +92,7 @@ class QueryComplexity extends AbstractQuerySecurity
return Visitor::skipNode(); return Visitor::skipNode();
}, },
NodeType::OPERATION_DEFINITION => [ NodeType::OPERATION_DEFINITION => [
'leave' => function (OperationDefinition $operationDefinition) use ($context, &$complexity) { 'leave' => function (OperationDefinitionNode $operationDefinition) use ($context, &$complexity) {
$complexity = $this->fieldComplexity($operationDefinition, $complexity); $complexity = $this->fieldComplexity($operationDefinition, $complexity);
if ($complexity > $this->getMaxQueryComplexity()) { if ($complexity > $this->getMaxQueryComplexity()) {
@ -108,7 +108,7 @@ class QueryComplexity extends AbstractQuerySecurity
private function fieldComplexity($node, $complexity = 0) private function fieldComplexity($node, $complexity = 0)
{ {
if (isset($node->selectionSet) && $node->selectionSet instanceof SelectionSet) { if (isset($node->selectionSet) && $node->selectionSet instanceof SelectionSetNode) {
foreach ($node->selectionSet->selections as $childNode) { foreach ($node->selectionSet->selections as $childNode) {
$complexity = $this->nodeComplexity($childNode, $complexity); $complexity = $this->nodeComplexity($childNode, $complexity);
} }
@ -121,7 +121,7 @@ class QueryComplexity extends AbstractQuerySecurity
{ {
switch ($node->kind) { switch ($node->kind) {
case NodeType::FIELD: case NodeType::FIELD:
/* @var Field $node */ /* @var FieldNode $node */
// default values // default values
$args = []; $args = [];
$complexityFn = FieldDefinition::DEFAULT_COMPLEXITY_FN; $complexityFn = FieldDefinition::DEFAULT_COMPLEXITY_FN;
@ -149,7 +149,7 @@ class QueryComplexity extends AbstractQuerySecurity
break; break;
case NodeType::INLINE_FRAGMENT: case NodeType::INLINE_FRAGMENT:
/* @var InlineFragment $node */ /* @var InlineFragmentNode $node */
// node has children? // node has children?
if (isset($node->selectionSet)) { if (isset($node->selectionSet)) {
$complexity = $this->fieldComplexity($node, $complexity); $complexity = $this->fieldComplexity($node, $complexity);
@ -157,7 +157,7 @@ class QueryComplexity extends AbstractQuerySecurity
break; break;
case NodeType::FRAGMENT_SPREAD: case NodeType::FRAGMENT_SPREAD:
/* @var FragmentSpread $node */ /* @var FragmentSpreadNode $node */
$fragment = $this->getFragment($node); $fragment = $this->getFragment($node);
if (null !== $fragment) { if (null !== $fragment) {
@ -169,7 +169,7 @@ class QueryComplexity extends AbstractQuerySecurity
return $complexity; return $complexity;
} }
private function astFieldInfo(Field $field) private function astFieldInfo(FieldNode $field)
{ {
$fieldName = $this->getFieldName($field); $fieldName = $this->getFieldName($field);
$astFieldInfo = [null, null]; $astFieldInfo = [null, null];
@ -185,7 +185,7 @@ class QueryComplexity extends AbstractQuerySecurity
return $astFieldInfo; return $astFieldInfo;
} }
private function buildFieldArguments(Field $node) private function buildFieldArguments(FieldNode $node)
{ {
$rawVariableValues = $this->getRawVariableValues(); $rawVariableValues = $this->getRawVariableValues();
$astFieldInfo = $this->astFieldInfo($node); $astFieldInfo = $this->astFieldInfo($node);

View File

@ -2,13 +2,13 @@
namespace GraphQL\Validator\Rules; namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\FragmentSpread; use GraphQL\Language\AST\FragmentSpreadNode;
use GraphQL\Language\AST\InlineFragment; use GraphQL\Language\AST\InlineFragmentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\AST\SelectionSet; use GraphQL\Language\AST\SelectionSetNode;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
class QueryDepth extends AbstractQuerySecurity class QueryDepth extends AbstractQuerySecurity
@ -51,7 +51,7 @@ class QueryDepth extends AbstractQuerySecurity
$context, $context,
[ [
NodeType::OPERATION_DEFINITION => [ NodeType::OPERATION_DEFINITION => [
'leave' => function (OperationDefinition $operationDefinition) use ($context) { 'leave' => function (OperationDefinitionNode $operationDefinition) use ($context) {
$maxDepth = $this->fieldDepth($operationDefinition); $maxDepth = $this->fieldDepth($operationDefinition);
if ($maxDepth > $this->getMaxQueryDepth()) { if ($maxDepth > $this->getMaxQueryDepth()) {
@ -72,7 +72,7 @@ class QueryDepth extends AbstractQuerySecurity
private function fieldDepth($node, $depth = 0, $maxDepth = 0) private function fieldDepth($node, $depth = 0, $maxDepth = 0)
{ {
if (isset($node->selectionSet) && $node->selectionSet instanceof SelectionSet) { if (isset($node->selectionSet) && $node->selectionSet instanceof SelectionSetNode) {
foreach ($node->selectionSet->selections as $childNode) { foreach ($node->selectionSet->selections as $childNode) {
$maxDepth = $this->nodeDepth($childNode, $depth, $maxDepth); $maxDepth = $this->nodeDepth($childNode, $depth, $maxDepth);
} }
@ -85,7 +85,7 @@ class QueryDepth extends AbstractQuerySecurity
{ {
switch ($node->kind) { switch ($node->kind) {
case NodeType::FIELD: case NodeType::FIELD:
/* @var Field $node */ /* @var FieldNode $node */
// node has children? // node has children?
if (null !== $node->selectionSet) { if (null !== $node->selectionSet) {
// update maxDepth if needed // update maxDepth if needed
@ -97,7 +97,7 @@ class QueryDepth extends AbstractQuerySecurity
break; break;
case NodeType::INLINE_FRAGMENT: case NodeType::INLINE_FRAGMENT:
/* @var InlineFragment $node */ /* @var InlineFragmentNode $node */
// node has children? // node has children?
if (null !== $node->selectionSet) { if (null !== $node->selectionSet) {
$maxDepth = $this->fieldDepth($node, $depth, $maxDepth); $maxDepth = $this->fieldDepth($node, $depth, $maxDepth);
@ -105,7 +105,7 @@ class QueryDepth extends AbstractQuerySecurity
break; break;
case NodeType::FRAGMENT_SPREAD: case NodeType::FRAGMENT_SPREAD:
/* @var FragmentSpread $node */ /* @var FragmentSpreadNode $node */
$fragment = $this->getFragment($node); $fragment = $this->getFragment($node);
if (null !== $fragment) { if (null !== $fragment) {

View File

@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Field; use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Type\Definition\Type; use GraphQL\Type\Definition\Type;
@ -25,7 +25,7 @@ class ScalarLeafs
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::FIELD => function(Field $node) use ($context) { NodeType::FIELD => function(FieldNode $node) use ($context) {
$type = $context->getType(); $type = $context->getType();
if ($type) { if ($type) {
if (Type::isLeafType($type)) { if (Type::isLeafType($type)) {

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules; namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument; use GraphQL\Language\AST\ArgumentNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
@ -28,7 +28,7 @@ class UniqueArgumentNames
NodeType::DIRECTIVE => function () { NodeType::DIRECTIVE => function () {
$this->knownArgNames = []; $this->knownArgNames = [];
}, },
NodeType::ARGUMENT => function (Argument $node) use ($context) { NodeType::ARGUMENT => function (ArgumentNode $node) use ($context) {
$argName = $node->name->value; $argName = $node->name->value;
if (!empty($this->knownArgNames[$argName])) { if (!empty($this->knownArgNames[$argName])) {
$context->reportError(new Error( $context->reportError(new Error(

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules; namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Directive; use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -20,7 +20,7 @@ class UniqueDirectivesPerLocation
if (isset($node->directives)) { if (isset($node->directives)) {
$knownDirectives = []; $knownDirectives = [];
foreach ($node->directives as $directive) { foreach ($node->directives as $directive) {
/** @var Directive $directive */ /** @var DirectiveNode $directive */
$directiveName = $directive->name->value; $directiveName = $directive->name->value;
if (isset($knownDirectives[$directiveName])) { if (isset($knownDirectives[$directiveName])) {
$context->reportError(new Error( $context->reportError(new Error(

View File

@ -2,8 +2,8 @@
namespace GraphQL\Validator\Rules; namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument; use GraphQL\Language\AST\ArgumentNode;
use GraphQL\Language\AST\FragmentDefinition; use GraphQL\Language\AST\FragmentDefinitionNode;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
@ -26,7 +26,7 @@ class UniqueFragmentNames
NodeType::OPERATION_DEFINITION => function () { NodeType::OPERATION_DEFINITION => function () {
return Visitor::skipNode(); return Visitor::skipNode();
}, },
NodeType::FRAGMENT_DEFINITION => function (FragmentDefinition $node) use ($context) { NodeType::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
$fragmentName = $node->name->value; $fragmentName = $node->name->value;
if (!empty($this->knownFragmentNames[$fragmentName])) { if (!empty($this->knownFragmentNames[$fragmentName])) {
$context->reportError(new Error( $context->reportError(new Error(

View File

@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\ObjectField; use GraphQL\Language\AST\ObjectFieldNode;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -33,7 +33,7 @@ class UniqueInputFieldNames
$this->knownNames = array_pop($this->knownNameStack); $this->knownNames = array_pop($this->knownNameStack);
} }
], ],
NodeType::OBJECT_FIELD => function(ObjectField $node) use ($context) { NodeType::OBJECT_FIELD => function(ObjectFieldNode $node) use ($context) {
$fieldName = $node->name->value; $fieldName = $node->name->value;
if (!empty($this->knownNames[$fieldName])) { if (!empty($this->knownNames[$fieldName])) {

View File

@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\OperationDefinition; use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\Visitor; use GraphQL\Language\Visitor;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
@ -22,7 +22,7 @@ class UniqueOperationNames
$this->knownOperationNames = []; $this->knownOperationNames = [];
return [ return [
NodeType::OPERATION_DEFINITION => function(OperationDefinition $node) use ($context) { NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) {
$operationName = $node->name; $operationName = $node->name;
if ($operationName) { if ($operationName) {

View File

@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\VariableDefinition; use GraphQL\Language\AST\VariableDefinitionNode;
use GraphQL\Validator\ValidationContext; use GraphQL\Validator\ValidationContext;
class UniqueVariableNames class UniqueVariableNames
@ -24,7 +24,7 @@ class UniqueVariableNames
NodeType::OPERATION_DEFINITION => function() { NodeType::OPERATION_DEFINITION => function() {
$this->knownVariableNames = []; $this->knownVariableNames = [];
}, },
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $node) use ($context) { NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) {
$variableName = $node->variable->name->value; $variableName = $node->variable->name->value;
if (!empty($this->knownVariableNames[$variableName])) { if (!empty($this->knownVariableNames[$variableName])) {
$context->reportError(new Error( $context->reportError(new Error(

View File

@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error; use GraphQL\Error\Error;
use GraphQL\Language\AST\Node; use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType; use GraphQL\Language\AST\NodeType;
use GraphQL\Language\AST\VariableDefinition; use GraphQL\Language\AST\VariableDefinitionNode;
use GraphQL\Language\Printer; use GraphQL\Language\Printer;
use GraphQL\Type\Definition\InputType; use GraphQL\Type\Definition\InputType;
use GraphQL\Type\Definition\Type; use GraphQL\Type\Definition\Type;
@ -22,7 +22,7 @@ class VariablesAreInputTypes
public function __invoke(ValidationContext $context) public function __invoke(ValidationContext $context)
{ {
return [ return [
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $node) use ($context) { NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) {
$type = Utils\TypeInfo::typeFromAST($context->getSchema(), $node->type); $type = Utils\TypeInfo::typeFromAST($context->getSchema(), $node->type);
// If the variable type is not an input type, return an error. // If the variable type is not an input type, return an error.

Some files were not shown because too many files have changed in this diff Show More