Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -1,17 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ArgumentNode extends Node
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::ARGUMENT;
|
||||
|
||||
/**
|
||||
* @var ValueNode
|
||||
*/
|
||||
/** @var VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class BooleanValueNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::BOOLEAN;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var bool */
|
||||
public $value;
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
* export type DefinitionNode =
|
||||
* | ExecutableDefinitionNode
|
||||
* | TypeSystemDefinitionNode;
|
||||
*/
|
||||
interface DefinitionNode
|
||||
{
|
||||
/**
|
||||
* export type DefinitionNode = OperationDefinitionNode
|
||||
* | FragmentDefinitionNode
|
||||
* | TypeSystemDefinitionNode // experimental non-spec addition.
|
||||
*/
|
||||
}
|
||||
@@ -1,25 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class DirectiveDefinitionNode extends Node implements TypeSystemDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::DIRECTIVE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var ArgumentNode[]
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
|
||||
/** @var NodeList<InputValueDefinitionNode> */
|
||||
public $arguments;
|
||||
|
||||
/**
|
||||
* @var NameNode[]
|
||||
*/
|
||||
/** @var bool */
|
||||
public $repeatable;
|
||||
|
||||
/** @var NodeList<NameNode> */
|
||||
public $locations;
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class DirectiveNode extends Node
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::DIRECTIVE;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var ArgumentNode[]
|
||||
*/
|
||||
/** @var NodeList<ArgumentNode> */
|
||||
public $arguments;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class DocumentNode extends Node
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::DOCUMENT;
|
||||
|
||||
/**
|
||||
* @var DefinitionNode[]
|
||||
*/
|
||||
/** @var NodeList<DefinitionNode&Node> */
|
||||
public $definitions;
|
||||
}
|
||||
@@ -1,30 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class EnumTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::ENUM_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var EnumValueDefinitionNode[]
|
||||
*/
|
||||
/** @var NodeList<EnumValueDefinitionNode> */
|
||||
public $values;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class EnumTypeExtensionNode extends Node implements TypeExtensionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::ENUM_TYPE_EXTENSION;
|
||||
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/** @var NodeList<EnumValueDefinitionNode> */
|
||||
public $values;
|
||||
}
|
||||
@@ -1,25 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class EnumValueDefinitionNode extends Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::ENUM_VALUE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class EnumValueNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::ENUM;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $value;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
* export type ExecutableDefinitionNode =
|
||||
* | OperationDefinitionNode
|
||||
* | FragmentDefinitionNode;
|
||||
*/
|
||||
interface ExecutableDefinitionNode extends DefinitionNode
|
||||
{
|
||||
}
|
||||
@@ -1,35 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FieldDefinitionNode extends Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::FIELD_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var InputValueDefinitionNode[]
|
||||
*/
|
||||
/** @var NodeList<InputValueDefinitionNode> */
|
||||
public $arguments;
|
||||
|
||||
/**
|
||||
* @var TypeNode
|
||||
*/
|
||||
/** @var NamedTypeNode|ListTypeNode|NonNullTypeNode */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
+9
-15
@@ -1,32 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FieldNode extends Node implements SelectionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::FIELD;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var NameNode|null
|
||||
*/
|
||||
/** @var NameNode|null */
|
||||
public $alias;
|
||||
|
||||
/**
|
||||
* @var ArgumentNode[]|null
|
||||
*/
|
||||
/** @var NodeList<ArgumentNode> */
|
||||
public $arguments;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]|null
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var SelectionSetNode|null
|
||||
*/
|
||||
/** @var SelectionSetNode|null */
|
||||
public $selectionSet;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FloatValueNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::FLOAT;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $value;
|
||||
}
|
||||
@@ -1,27 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FragmentDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
|
||||
class FragmentDefinitionNode extends Node implements ExecutableDefinitionNode, HasSelectionSet
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::FRAGMENT_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var NamedTypeNode
|
||||
* Note: fragment variable definitions are experimental and may be changed
|
||||
* or removed in the future.
|
||||
*
|
||||
* @var NodeList<VariableDefinitionNode>
|
||||
*/
|
||||
public $variableDefinitions;
|
||||
|
||||
/** @var NamedTypeNode */
|
||||
public $typeCondition;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var SelectionSetNode
|
||||
*/
|
||||
/** @var SelectionSetNode */
|
||||
public $selectionSet;
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FragmentSpreadNode extends Node implements SelectionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::FRAGMENT_SPREAD;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
* export type DefinitionNode = OperationDefinitionNode
|
||||
* | FragmentDefinitionNode
|
||||
*
|
||||
* @property SelectionSetNode $selectionSet
|
||||
*/
|
||||
interface HasSelectionSet
|
||||
{
|
||||
/**
|
||||
* export type DefinitionNode = OperationDefinitionNode
|
||||
* | FragmentDefinitionNode
|
||||
*/
|
||||
}
|
||||
@@ -1,22 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InlineFragmentNode extends Node implements SelectionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::INLINE_FRAGMENT;
|
||||
|
||||
/**
|
||||
* @var NamedTypeNode
|
||||
*/
|
||||
/** @var NamedTypeNode */
|
||||
public $typeCondition;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]|null
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var SelectionSetNode
|
||||
*/
|
||||
/** @var SelectionSetNode */
|
||||
public $selectionSet;
|
||||
}
|
||||
+8
-15
@@ -1,30 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InputObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::INPUT_OBJECT_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var InputValueDefinitionNode[]
|
||||
*/
|
||||
/** @var NodeList<InputValueDefinitionNode> */
|
||||
public $fields;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InputObjectTypeExtensionNode extends Node implements TypeExtensionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::INPUT_OBJECT_TYPE_EXTENSION;
|
||||
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/** @var NodeList<InputValueDefinitionNode> */
|
||||
public $fields;
|
||||
}
|
||||
@@ -1,35 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InputValueDefinitionNode extends Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::INPUT_VALUE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var TypeNode
|
||||
*/
|
||||
/** @var NamedTypeNode|ListTypeNode|NonNullTypeNode */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var ValueNode
|
||||
*/
|
||||
/** @var VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode|null */
|
||||
public $defaultValue;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class IntValueNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::INT;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $value;
|
||||
}
|
||||
+12
-16
@@ -1,30 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InterfaceTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::INTERFACE_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var FieldDefinitionNode[]
|
||||
*/
|
||||
public $fields = [];
|
||||
/** @var NodeList<NamedTypeNode> */
|
||||
public $interfaces;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var NodeList<FieldDefinitionNode> */
|
||||
public $fields;
|
||||
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InterfaceTypeExtensionNode extends Node implements TypeExtensionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::INTERFACE_TYPE_EXTENSION;
|
||||
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/** @var NodeList<InterfaceTypeDefinitionNode> */
|
||||
public $interfaces;
|
||||
|
||||
/** @var NodeList<FieldDefinitionNode> */
|
||||
public $fields;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ListTypeNode extends Node implements TypeNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::LIST_TYPE;
|
||||
|
||||
/**
|
||||
* @var Node
|
||||
*/
|
||||
/** @var NamedTypeNode|ListTypeNode|NonNullTypeNode */
|
||||
public $type;
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ListValueNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::LST;
|
||||
|
||||
/**
|
||||
* @var ValueNode[]
|
||||
*/
|
||||
/** @var NodeList<ValueNode&Node> */
|
||||
public $values;
|
||||
}
|
||||
+19
-12
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
use GraphQL\Language\Source;
|
||||
@@ -27,14 +30,14 @@ class Location
|
||||
/**
|
||||
* The Token at which this Node begins.
|
||||
*
|
||||
* @var Token
|
||||
* @var Token|null
|
||||
*/
|
||||
public $startToken;
|
||||
|
||||
/**
|
||||
* The Token at which this Node ends.
|
||||
*
|
||||
* @var Token
|
||||
* @var Token|null
|
||||
*/
|
||||
public $endToken;
|
||||
|
||||
@@ -46,27 +49,31 @@ class Location
|
||||
public $source;
|
||||
|
||||
/**
|
||||
* @param $start
|
||||
* @param $end
|
||||
* @param int $start
|
||||
* @param int $end
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create($start, $end)
|
||||
{
|
||||
$tmp = new static();
|
||||
$tmp = new static();
|
||||
$tmp->start = $start;
|
||||
$tmp->end = $end;
|
||||
$tmp->end = $end;
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public function __construct(Token $startToken = null, Token $endToken = null, Source $source = null)
|
||||
public function __construct(?Token $startToken = null, ?Token $endToken = null, ?Source $source = null)
|
||||
{
|
||||
$this->startToken = $startToken;
|
||||
$this->endToken = $endToken;
|
||||
$this->source = $source;
|
||||
$this->endToken = $endToken;
|
||||
$this->source = $source;
|
||||
|
||||
if ($startToken && $endToken) {
|
||||
$this->start = $startToken->start;
|
||||
$this->end = $endToken->end;
|
||||
if ($startToken === null || $endToken === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->start = $startToken->start;
|
||||
$this->end = $endToken->end;
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class NameNode extends Node implements TypeNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::NAME;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $value;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class NamedTypeNode extends Node implements TypeNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::NAMED_TYPE;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
}
|
||||
+74
-59
@@ -1,55 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Utils\Utils;
|
||||
use function count;
|
||||
use function get_object_vars;
|
||||
use function is_array;
|
||||
use function is_scalar;
|
||||
use function json_encode;
|
||||
|
||||
/**
|
||||
* type Node = NameNode
|
||||
* | DocumentNode
|
||||
* | OperationDefinitionNode
|
||||
* | VariableDefinitionNode
|
||||
* | VariableNode
|
||||
* | SelectionSetNode
|
||||
* | FieldNode
|
||||
* | ArgumentNode
|
||||
* | FragmentSpreadNode
|
||||
* | InlineFragmentNode
|
||||
* | FragmentDefinitionNode
|
||||
* | IntValueNode
|
||||
* | FloatValueNode
|
||||
* | StringValueNode
|
||||
* | BooleanValueNode
|
||||
* | EnumValueNode
|
||||
* | ListValueNode
|
||||
* | ObjectValueNode
|
||||
* | ObjectFieldNode
|
||||
* | DirectiveNode
|
||||
* | ListTypeNode
|
||||
* | NonNullTypeNode
|
||||
*/
|
||||
abstract class Node
|
||||
{
|
||||
/**
|
||||
type Node = NameNode
|
||||
| DocumentNode
|
||||
| OperationDefinitionNode
|
||||
| VariableDefinitionNode
|
||||
| VariableNode
|
||||
| SelectionSetNode
|
||||
| FieldNode
|
||||
| ArgumentNode
|
||||
| FragmentSpreadNode
|
||||
| InlineFragmentNode
|
||||
| FragmentDefinitionNode
|
||||
| IntValueNode
|
||||
| FloatValueNode
|
||||
| StringValueNode
|
||||
| BooleanValueNode
|
||||
| EnumValueNode
|
||||
| ListValueNode
|
||||
| ObjectValueNode
|
||||
| ObjectFieldNode
|
||||
| DirectiveNode
|
||||
| ListTypeNode
|
||||
| NonNullTypeNode
|
||||
*/
|
||||
/** @var Location|null */
|
||||
public $loc;
|
||||
|
||||
/** @var string */
|
||||
public $kind;
|
||||
|
||||
/**
|
||||
* @var Location
|
||||
*/
|
||||
public $loc;
|
||||
|
||||
/**
|
||||
* @param array $vars
|
||||
* @param (NameNode|NodeList|SelectionSetNode|Location|string|int|bool|float|null)[] $vars
|
||||
*/
|
||||
public function __construct(array $vars)
|
||||
{
|
||||
if (!empty($vars)) {
|
||||
Utils::assign($this, $vars);
|
||||
if (count($vars) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Utils::assign($this, $vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function cloneDeep()
|
||||
{
|
||||
@@ -57,8 +64,9 @@ abstract class Node
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @return array|Node
|
||||
* @param string|NodeList|Location|Node|(Node|NodeList|Location)[] $value
|
||||
*
|
||||
* @return string|NodeList|Location|Node
|
||||
*/
|
||||
private function cloneValue($value)
|
||||
{
|
||||
@@ -67,7 +75,7 @@ abstract class Node
|
||||
foreach ($value as $key => $arrValue) {
|
||||
$cloned[$key] = $this->cloneValue($arrValue);
|
||||
}
|
||||
} else if ($value instanceof Node) {
|
||||
} elseif ($value instanceof self) {
|
||||
$cloned = clone $value;
|
||||
foreach (get_object_vars($cloned) as $prop => $propValue) {
|
||||
$cloned->{$prop} = $this->cloneValue($propValue);
|
||||
@@ -79,61 +87,67 @@ abstract class Node
|
||||
return $cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString() : string
|
||||
{
|
||||
$tmp = $this->toArray(true);
|
||||
return json_encode($tmp);
|
||||
|
||||
return (string) json_encode($tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $recursive
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function toArray($recursive = false)
|
||||
public function toArray(bool $recursive = false) : array
|
||||
{
|
||||
if ($recursive) {
|
||||
return $this->recursiveToArray($this);
|
||||
} else {
|
||||
$tmp = (array) $this;
|
||||
}
|
||||
|
||||
$tmp = (array) $this;
|
||||
|
||||
if ($this->loc !== null) {
|
||||
$tmp['loc'] = [
|
||||
'start' => $this->loc->start,
|
||||
'end' => $this->loc->end
|
||||
'end' => $this->loc->end,
|
||||
];
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
private function recursiveToArray(Node $node)
|
||||
{
|
||||
$result = [
|
||||
'kind' => $node->kind,
|
||||
'loc' => [
|
||||
'start' => $node->loc->start,
|
||||
'end' => $node->loc->end
|
||||
]
|
||||
];
|
||||
|
||||
if ($node->loc !== null) {
|
||||
$result['loc'] = [
|
||||
'start' => $node->loc->start,
|
||||
'end' => $node->loc->end,
|
||||
];
|
||||
}
|
||||
|
||||
foreach (get_object_vars($node) as $prop => $propValue) {
|
||||
if (isset($result[$prop]))
|
||||
if (isset($result[$prop])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($propValue === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($propValue) || $propValue instanceof NodeList) {
|
||||
$tmp = [];
|
||||
foreach ($propValue as $tmp1) {
|
||||
$tmp[] = $tmp1 instanceof Node ? $this->recursiveToArray($tmp1) : (array) $tmp1;
|
||||
}
|
||||
} else if ($propValue instanceof Node) {
|
||||
} elseif ($propValue instanceof Node) {
|
||||
$tmp = $this->recursiveToArray($propValue);
|
||||
} else if (is_scalar($propValue) || null === $propValue) {
|
||||
} elseif (is_scalar($propValue) || $propValue === null) {
|
||||
$tmp = $propValue;
|
||||
} else {
|
||||
$tmp = null;
|
||||
@@ -141,6 +155,7 @@ abstract class Node
|
||||
|
||||
$result[$prop] = $tmp;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
+81
-78
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class NodeKind
|
||||
@@ -7,129 +9,130 @@ class NodeKind
|
||||
// constants from language/kinds.js:
|
||||
|
||||
const NAME = 'Name';
|
||||
|
||||
// Document
|
||||
|
||||
const DOCUMENT = 'Document';
|
||||
const DOCUMENT = 'Document';
|
||||
const OPERATION_DEFINITION = 'OperationDefinition';
|
||||
const VARIABLE_DEFINITION = 'VariableDefinition';
|
||||
const VARIABLE = 'Variable';
|
||||
const SELECTION_SET = 'SelectionSet';
|
||||
const FIELD = 'Field';
|
||||
const ARGUMENT = 'Argument';
|
||||
|
||||
const VARIABLE_DEFINITION = 'VariableDefinition';
|
||||
const VARIABLE = 'Variable';
|
||||
const SELECTION_SET = 'SelectionSet';
|
||||
const FIELD = 'Field';
|
||||
const ARGUMENT = 'Argument';
|
||||
// Fragments
|
||||
|
||||
const FRAGMENT_SPREAD = 'FragmentSpread';
|
||||
const INLINE_FRAGMENT = 'InlineFragment';
|
||||
const FRAGMENT_SPREAD = 'FragmentSpread';
|
||||
const INLINE_FRAGMENT = 'InlineFragment';
|
||||
const FRAGMENT_DEFINITION = 'FragmentDefinition';
|
||||
|
||||
// Values
|
||||
|
||||
const INT = 'IntValue';
|
||||
const FLOAT = 'FloatValue';
|
||||
const STRING = 'StringValue';
|
||||
const BOOLEAN = 'BooleanValue';
|
||||
const ENUM = 'EnumValue';
|
||||
const NULL = 'NullValue';
|
||||
const LST = 'ListValue';
|
||||
const OBJECT = 'ObjectValue';
|
||||
const INT = 'IntValue';
|
||||
const FLOAT = 'FloatValue';
|
||||
const STRING = 'StringValue';
|
||||
const BOOLEAN = 'BooleanValue';
|
||||
const ENUM = 'EnumValue';
|
||||
const NULL = 'NullValue';
|
||||
const LST = 'ListValue';
|
||||
const OBJECT = 'ObjectValue';
|
||||
const OBJECT_FIELD = 'ObjectField';
|
||||
|
||||
// Directives
|
||||
|
||||
const DIRECTIVE = 'Directive';
|
||||
|
||||
// Types
|
||||
|
||||
const NAMED_TYPE = 'NamedType';
|
||||
const LIST_TYPE = 'ListType';
|
||||
const NAMED_TYPE = 'NamedType';
|
||||
const LIST_TYPE = 'ListType';
|
||||
const NON_NULL_TYPE = 'NonNullType';
|
||||
|
||||
// Type System Definitions
|
||||
|
||||
const SCHEMA_DEFINITION = 'SchemaDefinition';
|
||||
const SCHEMA_DEFINITION = 'SchemaDefinition';
|
||||
const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';
|
||||
|
||||
// Type Definitions
|
||||
|
||||
const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
|
||||
const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
|
||||
const FIELD_DEFINITION = 'FieldDefinition';
|
||||
const INPUT_VALUE_DEFINITION = 'InputValueDefinition';
|
||||
const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
|
||||
const UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
|
||||
const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
|
||||
const ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
|
||||
const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
|
||||
const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
|
||||
const FIELD_DEFINITION = 'FieldDefinition';
|
||||
const INPUT_VALUE_DEFINITION = 'InputValueDefinition';
|
||||
const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
|
||||
const UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
|
||||
const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
|
||||
const ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
|
||||
const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
|
||||
|
||||
// Type Extensions
|
||||
|
||||
const TYPE_EXTENSION_DEFINITION = 'TypeExtensionDefinition';
|
||||
|
||||
const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension';
|
||||
const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension';
|
||||
const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension';
|
||||
const UNION_TYPE_EXTENSION = 'UnionTypeExtension';
|
||||
const ENUM_TYPE_EXTENSION = 'EnumTypeExtension';
|
||||
const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension';
|
||||
// Directive Definitions
|
||||
|
||||
const DIRECTIVE_DEFINITION = 'DirectiveDefinition';
|
||||
|
||||
/**
|
||||
* @todo conver to const array when moving to PHP5.6
|
||||
* @var array
|
||||
*/
|
||||
// Type System Extensions
|
||||
const SCHEMA_EXTENSION = 'SchemaExtension';
|
||||
|
||||
/** @var string[] */
|
||||
public static $classMap = [
|
||||
NodeKind::NAME => NameNode::class,
|
||||
self::NAME => NameNode::class,
|
||||
|
||||
// Document
|
||||
NodeKind::DOCUMENT => DocumentNode::class,
|
||||
NodeKind::OPERATION_DEFINITION => OperationDefinitionNode::class,
|
||||
NodeKind::VARIABLE_DEFINITION => VariableDefinitionNode::class,
|
||||
NodeKind::VARIABLE => VariableNode::class,
|
||||
NodeKind::SELECTION_SET => SelectionSetNode::class,
|
||||
NodeKind::FIELD => FieldNode::class,
|
||||
NodeKind::ARGUMENT => ArgumentNode::class,
|
||||
self::DOCUMENT => DocumentNode::class,
|
||||
self::OPERATION_DEFINITION => OperationDefinitionNode::class,
|
||||
self::VARIABLE_DEFINITION => VariableDefinitionNode::class,
|
||||
self::VARIABLE => VariableNode::class,
|
||||
self::SELECTION_SET => SelectionSetNode::class,
|
||||
self::FIELD => FieldNode::class,
|
||||
self::ARGUMENT => ArgumentNode::class,
|
||||
|
||||
// Fragments
|
||||
NodeKind::FRAGMENT_SPREAD => FragmentSpreadNode::class,
|
||||
NodeKind::INLINE_FRAGMENT => InlineFragmentNode::class,
|
||||
NodeKind::FRAGMENT_DEFINITION => FragmentDefinitionNode::class,
|
||||
self::FRAGMENT_SPREAD => FragmentSpreadNode::class,
|
||||
self::INLINE_FRAGMENT => InlineFragmentNode::class,
|
||||
self::FRAGMENT_DEFINITION => FragmentDefinitionNode::class,
|
||||
|
||||
// Values
|
||||
NodeKind::INT => IntValueNode::class,
|
||||
NodeKind::FLOAT => FloatValueNode::class,
|
||||
NodeKind::STRING => StringValueNode::class,
|
||||
NodeKind::BOOLEAN => BooleanValueNode::class,
|
||||
NodeKind::ENUM => EnumValueNode::class,
|
||||
NodeKind::NULL => NullValueNode::class,
|
||||
NodeKind::LST => ListValueNode::class,
|
||||
NodeKind::OBJECT => ObjectValueNode::class,
|
||||
NodeKind::OBJECT_FIELD => ObjectFieldNode::class,
|
||||
self::INT => IntValueNode::class,
|
||||
self::FLOAT => FloatValueNode::class,
|
||||
self::STRING => StringValueNode::class,
|
||||
self::BOOLEAN => BooleanValueNode::class,
|
||||
self::ENUM => EnumValueNode::class,
|
||||
self::NULL => NullValueNode::class,
|
||||
self::LST => ListValueNode::class,
|
||||
self::OBJECT => ObjectValueNode::class,
|
||||
self::OBJECT_FIELD => ObjectFieldNode::class,
|
||||
|
||||
// Directives
|
||||
NodeKind::DIRECTIVE => DirectiveNode::class,
|
||||
self::DIRECTIVE => DirectiveNode::class,
|
||||
|
||||
// Types
|
||||
NodeKind::NAMED_TYPE => NamedTypeNode::class,
|
||||
NodeKind::LIST_TYPE => ListTypeNode::class,
|
||||
NodeKind::NON_NULL_TYPE => NonNullTypeNode::class,
|
||||
self::NAMED_TYPE => NamedTypeNode::class,
|
||||
self::LIST_TYPE => ListTypeNode::class,
|
||||
self::NON_NULL_TYPE => NonNullTypeNode::class,
|
||||
|
||||
// Type System Definitions
|
||||
NodeKind::SCHEMA_DEFINITION => SchemaDefinitionNode::class,
|
||||
NodeKind::OPERATION_TYPE_DEFINITION => OperationTypeDefinitionNode::class,
|
||||
self::SCHEMA_DEFINITION => SchemaDefinitionNode::class,
|
||||
self::OPERATION_TYPE_DEFINITION => OperationTypeDefinitionNode::class,
|
||||
|
||||
// Type Definitions
|
||||
NodeKind::SCALAR_TYPE_DEFINITION => ScalarTypeDefinitionNode::class,
|
||||
NodeKind::OBJECT_TYPE_DEFINITION => ObjectTypeDefinitionNode::class,
|
||||
NodeKind::FIELD_DEFINITION => FieldDefinitionNode::class,
|
||||
NodeKind::INPUT_VALUE_DEFINITION => InputValueDefinitionNode::class,
|
||||
NodeKind::INTERFACE_TYPE_DEFINITION => InterfaceTypeDefinitionNode::class,
|
||||
NodeKind::UNION_TYPE_DEFINITION => UnionTypeDefinitionNode::class,
|
||||
NodeKind::ENUM_TYPE_DEFINITION => EnumTypeDefinitionNode::class,
|
||||
NodeKind::ENUM_VALUE_DEFINITION => EnumValueDefinitionNode::class,
|
||||
NodeKind::INPUT_OBJECT_TYPE_DEFINITION =>InputObjectTypeDefinitionNode::class,
|
||||
self::SCALAR_TYPE_DEFINITION => ScalarTypeDefinitionNode::class,
|
||||
self::OBJECT_TYPE_DEFINITION => ObjectTypeDefinitionNode::class,
|
||||
self::FIELD_DEFINITION => FieldDefinitionNode::class,
|
||||
self::INPUT_VALUE_DEFINITION => InputValueDefinitionNode::class,
|
||||
self::INTERFACE_TYPE_DEFINITION => InterfaceTypeDefinitionNode::class,
|
||||
self::UNION_TYPE_DEFINITION => UnionTypeDefinitionNode::class,
|
||||
self::ENUM_TYPE_DEFINITION => EnumTypeDefinitionNode::class,
|
||||
self::ENUM_VALUE_DEFINITION => EnumValueDefinitionNode::class,
|
||||
self::INPUT_OBJECT_TYPE_DEFINITION => InputObjectTypeDefinitionNode::class,
|
||||
|
||||
// Type Extensions
|
||||
NodeKind::TYPE_EXTENSION_DEFINITION => TypeExtensionDefinitionNode::class,
|
||||
self::SCALAR_TYPE_EXTENSION => ScalarTypeExtensionNode::class,
|
||||
self::OBJECT_TYPE_EXTENSION => ObjectTypeExtensionNode::class,
|
||||
self::INTERFACE_TYPE_EXTENSION => InterfaceTypeExtensionNode::class,
|
||||
self::UNION_TYPE_EXTENSION => UnionTypeExtensionNode::class,
|
||||
self::ENUM_TYPE_EXTENSION => EnumTypeExtensionNode::class,
|
||||
self::INPUT_OBJECT_TYPE_EXTENSION => InputObjectTypeExtensionNode::class,
|
||||
|
||||
// Directive Definitions
|
||||
NodeKind::DIRECTIVE_DEFINITION => DirectiveDefinitionNode::class
|
||||
self::DIRECTIVE_DEFINITION => DirectiveDefinitionNode::class,
|
||||
];
|
||||
}
|
||||
+74
-43
@@ -1,32 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use GraphQL\Utils\AST;
|
||||
use InvalidArgumentException;
|
||||
use IteratorAggregate;
|
||||
use Traversable;
|
||||
use function array_merge;
|
||||
use function array_splice;
|
||||
use function count;
|
||||
use function is_array;
|
||||
|
||||
/**
|
||||
* Class NodeList
|
||||
*
|
||||
* @package GraphQL\Utils
|
||||
* @template T of Node
|
||||
* @phpstan-implements ArrayAccess<int|string, T>
|
||||
* @phpstan-implements IteratorAggregate<T>
|
||||
*/
|
||||
class NodeList implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
class NodeList implements ArrayAccess, IteratorAggregate, Countable
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
* @var Node[]
|
||||
* @phpstan-var array<T>
|
||||
*/
|
||||
private $nodes;
|
||||
|
||||
/**
|
||||
* @param array $nodes
|
||||
* @return static
|
||||
* @param Node[] $nodes
|
||||
*
|
||||
* @phpstan-param array<T> $nodes
|
||||
* @phpstan-return self<T>
|
||||
*/
|
||||
public static function create(array $nodes)
|
||||
public static function create(array $nodes) : self
|
||||
{
|
||||
return new static($nodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* NodeList constructor.
|
||||
* @param array $nodes
|
||||
* @param Node[] $nodes
|
||||
*
|
||||
* @phpstan-param array<T> $nodes
|
||||
*/
|
||||
public function __construct(array $nodes)
|
||||
{
|
||||
@@ -34,87 +50,102 @@ class NodeList implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @return bool
|
||||
* @param int|string $offset
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
public function offsetExists($offset) : bool
|
||||
{
|
||||
return isset($this->nodes[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @return mixed
|
||||
* TODO enable strict typing by changing how the Visitor deals with NodeList.
|
||||
* Ideally, this function should always return a Node instance.
|
||||
* However, the Visitor currently allows mutation of the NodeList
|
||||
* and puts arbitrary values in the NodeList, such as strings.
|
||||
* We will have to switch to using an array or a less strict
|
||||
* type instead so we can enable strict typing in this class.
|
||||
*
|
||||
* @param int|string $offset
|
||||
*
|
||||
* @phpstan-return T
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
public function offsetGet($offset)// : Node
|
||||
{
|
||||
$item = $this->nodes[$offset];
|
||||
|
||||
if (is_array($item) && isset($item['kind'])) {
|
||||
$this->nodes[$offset] = $item = AST::fromArray($item);
|
||||
/** @phpstan-var T $node */
|
||||
$node = AST::fromArray($item);
|
||||
$this->nodes[$offset] = $node;
|
||||
}
|
||||
|
||||
return $item;
|
||||
return $this->nodes[$offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @param mixed $value
|
||||
* @param int|string|null $offset
|
||||
* @param Node|mixed[] $value
|
||||
*
|
||||
* @phpstan-param T|mixed[] $value
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
public function offsetSet($offset, $value) : void
|
||||
{
|
||||
if (is_array($value) && isset($value['kind'])) {
|
||||
if (is_array($value)) {
|
||||
/** @phpstan-var T $value */
|
||||
$value = AST::fromArray($value);
|
||||
}
|
||||
|
||||
// Happens when a Node is pushed via []=
|
||||
if ($offset === null) {
|
||||
$this->nodes[] = $value;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->nodes[$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @param int|string $offset
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
public function offsetUnset($offset) : void
|
||||
{
|
||||
unset($this->nodes[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $offset
|
||||
* @param int $length
|
||||
* @param mixed $replacement
|
||||
* @return NodeList
|
||||
*
|
||||
* @phpstan-return NodeList<T>
|
||||
*/
|
||||
public function splice($offset, $length, $replacement = null)
|
||||
public function splice(int $offset, int $length, $replacement = null) : NodeList
|
||||
{
|
||||
return new NodeList(array_splice($this->nodes, $offset, $length, $replacement));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $list
|
||||
* @return NodeList
|
||||
* @param NodeList|Node[] $list
|
||||
*
|
||||
* @phpstan-param NodeList<T>|array<T> $list
|
||||
* @phpstan-return NodeList<T>
|
||||
*/
|
||||
public function merge($list)
|
||||
public function merge($list) : NodeList
|
||||
{
|
||||
if ($list instanceof NodeList) {
|
||||
if ($list instanceof self) {
|
||||
$list = $list->nodes;
|
||||
}
|
||||
|
||||
return new NodeList(array_merge($this->nodes, $list));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Generator
|
||||
*/
|
||||
public function getIterator()
|
||||
public function getIterator() : Traversable
|
||||
{
|
||||
$count = count($this->nodes);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
yield $this->offsetGet($i);
|
||||
foreach ($this->nodes as $key => $_) {
|
||||
yield $this->offsetGet($key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count() : int
|
||||
{
|
||||
return count($this->nodes);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class NonNullTypeNode extends Node implements TypeNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::NON_NULL_TYPE;
|
||||
|
||||
/**
|
||||
* @var NameNode | ListTypeNode
|
||||
*/
|
||||
/** @var NamedTypeNode|ListTypeNode */
|
||||
public $type;
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class NullValueNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::NULL;
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ObjectFieldNode extends Node
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::OBJECT_FIELD;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var ValueNode
|
||||
*/
|
||||
/** @var VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode */
|
||||
public $value;
|
||||
}
|
||||
@@ -1,35 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::OBJECT_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var NamedTypeNode[]
|
||||
*/
|
||||
public $interfaces = [];
|
||||
/** @var NodeList<NamedTypeNode> */
|
||||
public $interfaces;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var FieldDefinitionNode[]
|
||||
*/
|
||||
/** @var NodeList<FieldDefinitionNode> */
|
||||
public $fields;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ObjectTypeExtensionNode extends Node implements TypeExtensionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::OBJECT_TYPE_EXTENSION;
|
||||
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/** @var NodeList<NamedTypeNode> */
|
||||
public $interfaces;
|
||||
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/** @var NodeList<FieldDefinitionNode> */
|
||||
public $fields;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ObjectValueNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::OBJECT;
|
||||
|
||||
/**
|
||||
* @var ObjectFieldNode[]
|
||||
*/
|
||||
/** @var NodeList<ObjectFieldNode> */
|
||||
public $fields;
|
||||
}
|
||||
@@ -1,35 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class OperationDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
|
||||
class OperationDefinitionNode extends Node implements ExecutableDefinitionNode, HasSelectionSet
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::OPERATION_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode|null */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var string (oneOf 'query', 'mutation'))
|
||||
*/
|
||||
/** @var string (oneOf 'query', 'mutation', 'subscription')) */
|
||||
public $operation;
|
||||
|
||||
/**
|
||||
* @var VariableDefinitionNode[]
|
||||
*/
|
||||
/** @var NodeList<VariableDefinitionNode> */
|
||||
public $variableDefinitions;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var SelectionSetNode
|
||||
*/
|
||||
/** @var SelectionSetNode */
|
||||
public $selectionSet;
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class OperationTypeDefinitionNode extends Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::OPERATION_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
@@ -15,8 +16,6 @@ class OperationTypeDefinitionNode extends Node
|
||||
*/
|
||||
public $operation;
|
||||
|
||||
/**
|
||||
* @var NamedTypeNode
|
||||
*/
|
||||
/** @var NamedTypeNode */
|
||||
public $type;
|
||||
}
|
||||
@@ -1,25 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ScalarTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::SCALAR_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ScalarTypeExtensionNode extends Node implements TypeExtensionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::SCALAR_TYPE_EXTENSION;
|
||||
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
}
|
||||
@@ -1,20 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class SchemaDefinitionNode extends Node implements TypeSystemDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::SCHEMA_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var OperationTypeDefinitionNode[]
|
||||
*/
|
||||
/** @var NodeList<OperationTypeDefinitionNode> */
|
||||
public $operationTypes;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class SchemaTypeExtensionNode extends Node implements TypeExtensionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::SCHEMA_EXTENSION;
|
||||
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/** @var NodeList<OperationTypeDefinitionNode> */
|
||||
public $operationTypes;
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface SelectionNode
|
||||
{
|
||||
/**
|
||||
* export type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode
|
||||
*/
|
||||
interface SelectionNode
|
||||
{
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class SelectionSetNode extends Node
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::SELECTION_SET;
|
||||
|
||||
/**
|
||||
* @var SelectionNode[]
|
||||
*/
|
||||
/** @var NodeList<SelectionNode&Node> */
|
||||
public $selections;
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class StringValueNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::STRING;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $value;
|
||||
|
||||
/** @var bool */
|
||||
public $block;
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
* export type TypeDefinitionNode = ScalarTypeDefinitionNode
|
||||
* | ObjectTypeDefinitionNode
|
||||
* | InterfaceTypeDefinitionNode
|
||||
* | UnionTypeDefinitionNode
|
||||
* | EnumTypeDefinitionNode
|
||||
* | InputObjectTypeDefinitionNode
|
||||
*/
|
||||
interface TypeDefinitionNode extends TypeSystemDefinitionNode
|
||||
{
|
||||
/**
|
||||
export type TypeDefinitionNode = ScalarTypeDefinitionNode
|
||||
| ObjectTypeDefinitionNode
|
||||
| InterfaceTypeDefinitionNode
|
||||
| UnionTypeDefinitionNode
|
||||
| EnumTypeDefinitionNode
|
||||
| InputObjectTypeDefinitionNode
|
||||
*/
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class TypeExtensionDefinitionNode extends Node implements TypeSystemDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $kind = NodeKind::TYPE_EXTENSION_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var ObjectTypeDefinitionNode
|
||||
*/
|
||||
public $definition;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
* export type TypeExtensionNode =
|
||||
* | ScalarTypeExtensionNode
|
||||
* | ObjectTypeExtensionNode
|
||||
* | InterfaceTypeExtensionNode
|
||||
* | UnionTypeExtensionNode
|
||||
* | EnumTypeExtensionNode
|
||||
* | InputObjectTypeExtensionNode;
|
||||
*/
|
||||
interface TypeExtensionNode extends TypeSystemDefinitionNode
|
||||
{
|
||||
}
|
||||
+8
-7
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
|
||||
/**
|
||||
* export type TypeNode = NamedTypeNode
|
||||
* | ListTypeNode
|
||||
* | NonNullTypeNode
|
||||
*/
|
||||
interface TypeNode
|
||||
{
|
||||
/**
|
||||
export type TypeNode = NamedTypeNode
|
||||
| ListTypeNode
|
||||
| NonNullTypeNode
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
* export type TypeSystemDefinitionNode =
|
||||
* | SchemaDefinitionNode
|
||||
* | TypeDefinitionNode
|
||||
* | TypeExtensionNode
|
||||
* | DirectiveDefinitionNode
|
||||
*
|
||||
* @property NameNode $name
|
||||
*/
|
||||
interface TypeSystemDefinitionNode extends DefinitionNode
|
||||
{
|
||||
/**
|
||||
export type TypeSystemDefinitionNode = SchemaDefinitionNode
|
||||
| TypeDefinitionNode
|
||||
| TypeExtensionDefinitionNode
|
||||
| DirectiveDefinitionNode
|
||||
*/
|
||||
}
|
||||
@@ -1,30 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class UnionTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
public $kind = NodeKind::UNION_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var NamedTypeNode[]
|
||||
*/
|
||||
public $types = [];
|
||||
/** @var NodeList<NamedTypeNode> */
|
||||
public $types;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var StringValueNode|null */
|
||||
public $description;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class UnionTypeExtensionNode extends Node implements TypeExtensionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::UNION_TYPE_EXTENSION;
|
||||
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
|
||||
/** @var NodeList<NamedTypeNode> */
|
||||
public $types;
|
||||
}
|
||||
+4
-1
@@ -1,8 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
export type ValueNode = VariableNode
|
||||
| NullValueNode
|
||||
| IntValueNode
|
||||
| FloatValueNode
|
||||
| StringValueNode
|
||||
@@ -13,5 +17,4 @@ export type ValueNode = VariableNode
|
||||
*/
|
||||
interface ValueNode
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,22 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class VariableDefinitionNode extends Node implements DefinitionNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::VARIABLE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var VariableNode
|
||||
*/
|
||||
/** @var VariableNode */
|
||||
public $variable;
|
||||
|
||||
/**
|
||||
* @var TypeNode
|
||||
*/
|
||||
/** @var NamedTypeNode|ListTypeNode|NonNullTypeNode */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var ValueNode|null
|
||||
*/
|
||||
/** @var VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode|null */
|
||||
public $defaultValue;
|
||||
|
||||
/** @var NodeList<DirectiveNode> */
|
||||
public $directives;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class VariableNode extends Node
|
||||
class VariableNode extends Node implements ValueNode
|
||||
{
|
||||
/** @var string */
|
||||
public $kind = NodeKind::VARIABLE;
|
||||
|
||||
/**
|
||||
* @var NameNode
|
||||
*/
|
||||
/** @var NameNode */
|
||||
public $name;
|
||||
}
|
||||
Reference in new issue
Block a user