From fe0452cf1a5e6ff26877720967290301041dc4e4 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Fri, 3 Mar 2023 15:40:02 +0100 Subject: [PATCH 01/11] Add AST type ConstValueNode --- src/Language/AST/BooleanValueNode.php | 2 +- src/Language/AST/ConstValueNode.php | 18 ++++++++++++++++++ src/Language/AST/EnumValueNode.php | 2 +- src/Language/AST/FloatValueNode.php | 2 +- src/Language/AST/IntValueNode.php | 2 +- src/Language/AST/ListValueNode.php | 2 +- src/Language/AST/NullValueNode.php | 2 +- src/Language/AST/ObjectValueNode.php | 2 +- src/Language/AST/StringValueNode.php | 2 +- src/Language/AST/ValueNode.php | 7 ++++--- 10 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 src/Language/AST/ConstValueNode.php diff --git a/src/Language/AST/BooleanValueNode.php b/src/Language/AST/BooleanValueNode.php index 4d987d97f..f89cb7b7e 100644 --- a/src/Language/AST/BooleanValueNode.php +++ b/src/Language/AST/BooleanValueNode.php @@ -2,7 +2,7 @@ namespace GraphQL\Language\AST; -class BooleanValueNode extends Node implements ValueNode +class BooleanValueNode extends Node implements ValueNode, ConstValueNode { public string $kind = NodeKind::BOOLEAN; diff --git a/src/Language/AST/ConstValueNode.php b/src/Language/AST/ConstValueNode.php new file mode 100644 index 000000000..a6c03c1d4 --- /dev/null +++ b/src/Language/AST/ConstValueNode.php @@ -0,0 +1,18 @@ + Date: Wed, 8 Mar 2023 11:56:00 +0100 Subject: [PATCH 02/11] ValueNodeVariants --- src/Executor/Values.php | 10 +++++----- src/Language/AST/ArgumentNode.php | 4 ++-- src/Language/AST/ObjectFieldNode.php | 5 ++++- src/Language/AST/ValueNode.php | 1 + 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Executor/Values.php b/src/Executor/Values.php index ee6a0bc66..97144bd83 100644 --- a/src/Executor/Values.php +++ b/src/Executor/Values.php @@ -3,7 +3,6 @@ namespace GraphQL\Executor; use GraphQL\Error\Error; -use GraphQL\Language\AST\ArgumentNode; use GraphQL\Language\AST\DirectiveNode; use GraphQL\Language\AST\EnumTypeDefinitionNode; use GraphQL\Language\AST\EnumTypeExtensionNode; @@ -29,6 +28,7 @@ use GraphQL\Language\AST\SchemaExtensionNode; use GraphQL\Language\AST\UnionTypeDefinitionNode; use GraphQL\Language\AST\UnionTypeExtensionNode; +use GraphQL\Language\AST\ValueNode; use GraphQL\Language\AST\VariableDefinitionNode; use GraphQL\Language\AST\VariableNode; use GraphQL\Language\Printer; @@ -42,9 +42,9 @@ use GraphQL\Utils\Value; /** - * @see ArgumentNode - force IDE import + * @see ValueNode - force IDE import * - * @phpstan-import-type ArgumentNodeValue from ArgumentNode + * @phpstan-import-type ValueNodeVariants from ValueNode */ class Values { @@ -178,7 +178,7 @@ public static function getArgumentValues($def, Node $node, ?array $variableValue return []; } - /** @var array $argumentValueMap */ + /** @var array $argumentValueMap */ $argumentValueMap = []; // Might not be defined when an AST from JS is used @@ -193,7 +193,7 @@ public static function getArgumentValues($def, Node $node, ?array $variableValue /** * @param FieldDefinition|Directive $def - * @param array $argumentValueMap + * @param array $argumentValueMap * @param array|null $variableValues * * @throws Error diff --git a/src/Language/AST/ArgumentNode.php b/src/Language/AST/ArgumentNode.php index 6add5032b..6871a4d46 100644 --- a/src/Language/AST/ArgumentNode.php +++ b/src/Language/AST/ArgumentNode.php @@ -3,13 +3,13 @@ namespace GraphQL\Language\AST; /** - * @phpstan-type ArgumentNodeValue VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode + * @phpstan-import-type ValueNodeVariants from ValueNode */ class ArgumentNode extends Node { public string $kind = NodeKind::ARGUMENT; - /** @phpstan-var ArgumentNodeValue */ + /** @var ValueNodeVariants */ public ValueNode $value; public NameNode $name; diff --git a/src/Language/AST/ObjectFieldNode.php b/src/Language/AST/ObjectFieldNode.php index 462a23a7d..1edc18241 100644 --- a/src/Language/AST/ObjectFieldNode.php +++ b/src/Language/AST/ObjectFieldNode.php @@ -2,12 +2,15 @@ namespace GraphQL\Language\AST; +/** + * @phpstan-import-type ValueNodeVariants from ValueNode + */ class ObjectFieldNode extends Node { public string $kind = NodeKind::OBJECT_FIELD; public NameNode $name; - /** @var VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode */ + /** @var ValueNodeVariants */ public ValueNode $value; } diff --git a/src/Language/AST/ValueNode.php b/src/Language/AST/ValueNode.php index 2f031b26a..5a44cefa2 100644 --- a/src/Language/AST/ValueNode.php +++ b/src/Language/AST/ValueNode.php @@ -3,6 +3,7 @@ namespace GraphQL\Language\AST; /** + * @phpstan-type ValueNodeVariants VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode export type ValueNode = | VariableNode | IntValueNode From 13f7093b1c3b6dc6bf6525b1cf0838ca3688253a Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 8 Mar 2023 12:35:05 +0100 Subject: [PATCH 03/11] const values everywhere --- src/Language/AST/ConstArgumentNode.php | 16 +++++ src/Language/AST/ConstListValueNode.php | 11 +++ src/Language/AST/ConstObjectFieldNode.php | 16 +++++ src/Language/AST/ConstObjectValueNode.php | 11 +++ src/Language/AST/ConstValueNode.php | 10 +-- src/Language/AST/InputValueDefinitionNode.php | 5 +- src/Language/AST/TypeNode.php | 4 +- src/Language/AST/ValueNode.php | 10 --- src/Language/AST/VariableDefinitionNode.php | 7 +- src/Language/Parser.php | 72 +++++++++++++------ src/Language/Printer.php | 8 ++- src/Type/Definition/LeafType.php | 5 +- src/Utils/AST.php | 8 ++- src/Utils/TypeInfo.php | 6 ++ src/Validator/Rules/UniqueInputFieldNames.php | 4 +- src/Validator/Rules/ValuesOfCorrectType.php | 17 +++-- .../Rules/VariablesInAllowedPosition.php | 7 +- tests/Executor/VariablesTest.php | 5 +- 18 files changed, 158 insertions(+), 64 deletions(-) create mode 100644 src/Language/AST/ConstArgumentNode.php create mode 100644 src/Language/AST/ConstListValueNode.php create mode 100644 src/Language/AST/ConstObjectFieldNode.php create mode 100644 src/Language/AST/ConstObjectValueNode.php diff --git a/src/Language/AST/ConstArgumentNode.php b/src/Language/AST/ConstArgumentNode.php new file mode 100644 index 000000000..6e3d642dc --- /dev/null +++ b/src/Language/AST/ConstArgumentNode.php @@ -0,0 +1,16 @@ + */ + public NodeList $values; +} diff --git a/src/Language/AST/ConstObjectFieldNode.php b/src/Language/AST/ConstObjectFieldNode.php new file mode 100644 index 000000000..a5b217b75 --- /dev/null +++ b/src/Language/AST/ConstObjectFieldNode.php @@ -0,0 +1,16 @@ + */ + public NodeList $fields; +} diff --git a/src/Language/AST/ConstValueNode.php b/src/Language/AST/ConstValueNode.php index a6c03c1d4..e5a6c49d6 100644 --- a/src/Language/AST/ConstValueNode.php +++ b/src/Language/AST/ConstValueNode.php @@ -3,15 +3,7 @@ namespace GraphQL\Language\AST; /** -export type ConstValueNode = -| IntValueNode -| FloatValueNode -| StringValueNode -| BooleanValueNode -| NullValueNode -| EnumValueNode -| ConstListValueNode -| ConstObjectValueNode; + * @phpstan-type ConstValueNodeVariants NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ConstListValueNode|ConstObjectValueNode */ interface ConstValueNode { diff --git a/src/Language/AST/InputValueDefinitionNode.php b/src/Language/AST/InputValueDefinitionNode.php index 46477bbf8..0a6237a05 100644 --- a/src/Language/AST/InputValueDefinitionNode.php +++ b/src/Language/AST/InputValueDefinitionNode.php @@ -2,6 +2,9 @@ namespace GraphQL\Language\AST; +/** + * @phpstan-import-type ValueNodeVariants from ValueNode + */ class InputValueDefinitionNode extends Node { public string $kind = NodeKind::INPUT_VALUE_DEFINITION; @@ -11,7 +14,7 @@ class InputValueDefinitionNode extends Node /** @var NamedTypeNode|ListTypeNode|NonNullTypeNode */ public TypeNode $type; - /** @var VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode|null */ + /** @var ValueNodeVariants|null */ public ?ValueNode $defaultValue = null; /** @var NodeList */ diff --git a/src/Language/AST/TypeNode.php b/src/Language/AST/TypeNode.php index a3abf211f..6f472e200 100644 --- a/src/Language/AST/TypeNode.php +++ b/src/Language/AST/TypeNode.php @@ -3,9 +3,7 @@ namespace GraphQL\Language\AST; /** - * export type TypeNode = NamedTypeNode - * | ListTypeNode - * | NonNullTypeNode. + * @phpstan-type TypeNodeVariants NamedTypeNode|ListTypeNode|NonNullTypeNode */ interface TypeNode { diff --git a/src/Language/AST/ValueNode.php b/src/Language/AST/ValueNode.php index 5a44cefa2..58d8c5bd6 100644 --- a/src/Language/AST/ValueNode.php +++ b/src/Language/AST/ValueNode.php @@ -4,16 +4,6 @@ /** * @phpstan-type ValueNodeVariants VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode -export type ValueNode = -| VariableNode -| IntValueNode -| FloatValueNode -| StringValueNode -| BooleanValueNode -| NullValueNode -| EnumValueNode -| ListValueNode -| ObjectValueNode; */ interface ValueNode { diff --git a/src/Language/AST/VariableDefinitionNode.php b/src/Language/AST/VariableDefinitionNode.php index 608ad282b..75f60ec55 100644 --- a/src/Language/AST/VariableDefinitionNode.php +++ b/src/Language/AST/VariableDefinitionNode.php @@ -2,6 +2,9 @@ namespace GraphQL\Language\AST; +/** + * @phpstan-import-type ConstValueNodeVariants from ConstValueNode + */ class VariableDefinitionNode extends Node implements DefinitionNode { public string $kind = NodeKind::VARIABLE_DEFINITION; @@ -11,8 +14,8 @@ class VariableDefinitionNode extends Node implements DefinitionNode /** @var NamedTypeNode|ListTypeNode|NonNullTypeNode */ public TypeNode $type; - /** @var VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode|null */ - public ?ValueNode $defaultValue = null; + /** @var ConstValueNodeVariants|null */ + public ?ConstValueNode $defaultValue = null; /** @var NodeList */ public NodeList $directives; diff --git a/src/Language/Parser.php b/src/Language/Parser.php index a83607b0d..5116701e8 100644 --- a/src/Language/Parser.php +++ b/src/Language/Parser.php @@ -5,6 +5,10 @@ use GraphQL\Error\SyntaxError; use GraphQL\Language\AST\ArgumentNode; use GraphQL\Language\AST\BooleanValueNode; +use GraphQL\Language\AST\ConstListValueNode; +use GraphQL\Language\AST\ConstObjectFieldNode; +use GraphQL\Language\AST\ConstObjectValueNode; +use GraphQL\Language\AST\ConstValueNode; use GraphQL\Language\AST\DefinitionNode; use GraphQL\Language\AST\DirectiveDefinitionNode; use GraphQL\Language\AST\DirectiveNode; @@ -68,6 +72,10 @@ * experimentalFragmentVariables?: bool * } * + * @phpstan-import-type ConstValueNodeVariants from ConstValueNode + * @phpstan-import-type ValueNodeVariants from ValueNode + * @phpstan-import-type TypeNodeVariants from TypeNode + * * noLocation: * (By default, the parser creates AST nodes that know the location * in the source that they correspond to. This configuration flag @@ -123,17 +131,17 @@ * @method static FragmentSpreadNode|InlineFragmentNode fragment(Source|string $source, bool[] $options = []) * @method static FragmentDefinitionNode fragmentDefinition(Source|string $source, bool[] $options = []) * @method static NameNode fragmentName(Source|string $source, bool[] $options = []) - * @method static BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|NullValueNode|ObjectValueNode|StringValueNode|VariableNode valueLiteral(Source|string $source, bool[] $options = []) - * @method static BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|NullValueNode|ObjectValueNode|StringValueNode constValueLiteral(Source|string $source, bool[] $options = []) + * @method static ValueNodeVariants valueLiteral(Source|string $source, bool[] $options = []) + * @method static ConstValueNodeVariants constValueLiteral(Source|string $source, bool[] $options = []) * @method static StringValueNode stringLiteral(Source|string $source, bool[] $options = []) - * @method static BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|StringValueNode constValue(Source|string $source, bool[] $options = []) - * @method static BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|ObjectValueNode|StringValueNode|VariableNode variableValue(Source|string $source, bool[] $options = []) + * @method static ConstValueNodeVariants constValue(Source|string $source, bool[] $options = []) + * @method static ValueNodeVariants variableValue(Source|string $source, bool[] $options = []) * @method static ListValueNode array(Source|string $source, bool[] $options = []) - * @method static ListValueNode constArray(Source|string $source, bool[] $options = []) + * @method static ConstListValueNode constArray(Source|string $source, bool[] $options = []) * @method static ObjectValueNode object(Source|string $source, bool[] $options = []) - * @method static ObjectValueNode constObject(Source|string $source, bool[] $options = []) + * @method static ConstObjectValueNode constObject(Source|string $source, bool[] $options = []) * @method static ObjectFieldNode objectField(Source|string $source, bool[] $options = []) - * @method static ObjectFieldNode constObjectField(Source|string $source, bool[] $options = []) + * @method static ConstObjectFieldNode constObjectField(Source|string $source, bool[] $options = []) * @method static NodeList directives(Source|string $source, bool[] $options = []) * @method static NodeList constDirectives(Source|string $source, bool[] $options = []) * @method static DirectiveNode directive(Source|string $source, bool[] $options = []) @@ -205,17 +213,18 @@ public static function parse($source, array $options = []): DocumentNode * * @phpstan-param ParserOptions $options * - * @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|NullValueNode|ObjectValueNode|StringValueNode|VariableNode + * @return ValueNodeVariants * * @api */ - public static function parseValue($source, array $options = []) + public static function parseValue($source, array $options = []): ValueNode { $parser = new Parser($source, $options); $parser->expect(Token::SOF); $value = $parser->parseValueLiteral(false); $parser->expect(Token::EOF); + // @phpstan-ignore-next-line isConst false makes sure this is never a ConstValueNode return $value; } @@ -233,11 +242,11 @@ public static function parseValue($source, array $options = []) * * @phpstan-param ParserOptions $options * - * @return ListTypeNode|NamedTypeNode|NonNullTypeNode + * @return TypeNodeVariants * * @api */ - public static function parseType($source, array $options = []) + public static function parseType($source, array $options = []): TypeNode { $parser = new Parser($source, $options); $parser->expect(Token::SOF); @@ -818,9 +827,9 @@ private function parseFragmentName(): NameNode * * EnumValue : Name but not `true`, `false` or `null` * - * @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|StringValueNode|VariableNode|ListValueNode|ObjectValueNode|NullValueNode + * @return ValueNodeVariants|ConstValueNodeVariants */ - private function parseValueLiteral(bool $isConst): ValueNode + private function parseValueLiteral(bool $isConst): Node { $token = $this->lexer->token; switch ($token->kind) { @@ -897,8 +906,9 @@ private function parseStringLiteral(): StringValueNode ]); } - private function parseConstValue(): ValueNode + private function parseConstValue(): ConstValueNode { + // @phpstan-ignore-next-line return type depends on argument return $this->parseValueLiteral(true); } @@ -907,20 +917,29 @@ private function parseVariableValue(): ValueNode return $this->parseValueLiteral(false); } - private function parseArray(bool $isConst): ListValueNode + /** + * @return ListValueNode|ConstListValueNode + */ + private function parseArray(bool $isConst): Node { $start = $this->lexer->token; $parseFn = $isConst - ? fn (): ValueNode => $this->parseConstValue() + ? fn (): ConstValueNode => $this->parseConstValue() : fn (): ValueNode => $this->parseVariableValue(); + $class = $isConst + ? ConstListValueNode::class + : ListValueNode::class; - return new ListValueNode([ + return new $class([ 'values' => $this->any(Token::BRACKET_L, $parseFn, Token::BRACKET_R), 'loc' => $this->loc($start), ]); } - private function parseObject(bool $isConst): ObjectValueNode + /** + * @return ObjectValueNode|ConstObjectValueNode + */ + private function parseObject(bool $isConst): Node { $start = $this->lexer->token; $this->expect(Token::BRACE_L); @@ -928,21 +947,30 @@ private function parseObject(bool $isConst): ObjectValueNode while (! $this->skip(Token::BRACE_R)) { $fields[] = $this->parseObjectField($isConst); } + $class = $isConst + ? ConstObjectValueNode::class + : ObjectValueNode::class; - return new ObjectValueNode([ + return new $class([ 'fields' => new NodeList($fields), 'loc' => $this->loc($start), ]); } - private function parseObjectField(bool $isConst): ObjectFieldNode + /** + * @return ObjectFieldNode|ConstObjectFieldNode + */ + private function parseObjectField(bool $isConst): Node { $start = $this->lexer->token; $name = $this->parseName(); $this->expect(Token::COLON); - return new ObjectFieldNode([ + $class = $isConst + ? ConstObjectFieldNode::class + : ObjectFieldNode::class; + return new $class([ 'name' => $name, 'value' => $this->parseValueLiteral($isConst), 'loc' => $this->loc($start), @@ -981,7 +1009,7 @@ private function parseDirective(bool $isConst): DirectiveNode /** * Handles the Type: TypeName, ListType, and NonNullType parsing rules. * - * @return ListTypeNode|NamedTypeNode|NonNullTypeNode + * @return TypeNodeVariants */ private function parseTypeReference(): TypeNode { diff --git a/src/Language/Printer.php b/src/Language/Printer.php index f6daa4dab..97ae99fd9 100644 --- a/src/Language/Printer.php +++ b/src/Language/Printer.php @@ -4,6 +4,9 @@ use GraphQL\Language\AST\ArgumentNode; use GraphQL\Language\AST\BooleanValueNode; +use GraphQL\Language\AST\ConstListValueNode; +use GraphQL\Language\AST\ConstObjectFieldNode; +use GraphQL\Language\AST\ConstObjectValueNode; use GraphQL\Language\AST\DirectiveDefinitionNode; use GraphQL\Language\AST\DirectiveNode; use GraphQL\Language\AST\DocumentNode; @@ -87,7 +90,7 @@ public function printAST(Node $node): string return $this->p($node); } - protected function p(?Node $node, bool $isDescription = false): string + protected function p(?Node $node): string { if ($node === null) { return ''; @@ -312,6 +315,7 @@ protected function p(?Node $node, bool $isDescription = false): string return '[' . $this->p($node->type) . ']'; case $node instanceof ListValueNode: + case $node instanceof ConstListValueNode: return '[' . $this->printList($node->values, ', ') . ']'; case $node instanceof NameNode: @@ -327,6 +331,7 @@ protected function p(?Node $node, bool $isDescription = false): string return 'null'; case $node instanceof ObjectFieldNode: + case $node instanceof ConstObjectFieldNode: return $this->p($node->name) . ': ' . $this->p($node->value); case $node instanceof ObjectTypeDefinitionNode: @@ -354,6 +359,7 @@ protected function p(?Node $node, bool $isDescription = false): string ); case $node instanceof ObjectValueNode: + case $node instanceof ConstObjectValueNode: return "{ {$this->printList($node->fields, ', ')} }"; case $node instanceof OperationDefinitionNode: diff --git a/src/Type/Definition/LeafType.php b/src/Type/Definition/LeafType.php index cc00e7dd8..118b1c06b 100644 --- a/src/Type/Definition/LeafType.php +++ b/src/Type/Definition/LeafType.php @@ -5,12 +5,11 @@ use GraphQL\Language\AST\Node; use GraphQL\Language\AST\ValueNode; -/* +/** export type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType; -*/ - + */ interface LeafType { /** diff --git a/src/Utils/AST.php b/src/Utils/AST.php index c2050c919..4619c99ad 100644 --- a/src/Utils/AST.php +++ b/src/Utils/AST.php @@ -5,6 +5,8 @@ use GraphQL\Error\Error; use GraphQL\Error\InvariantViolation; use GraphQL\Language\AST\BooleanValueNode; +use GraphQL\Language\AST\ConstListValueNode; +use GraphQL\Language\AST\ConstObjectValueNode; use GraphQL\Language\AST\DefinitionNode; use GraphQL\Language\AST\DocumentNode; use GraphQL\Language\AST\EnumValueNode; @@ -340,7 +342,7 @@ public static function valueFromAST(?ValueNode $valueNode, Type $type, ?array $v if ($type instanceof ListOfType) { $itemType = $type->getWrappedType(); - if ($valueNode instanceof ListValueNode) { + if ($valueNode instanceof ListValueNode || $valueNode instanceof ConstListValueNode) { $coercedValues = []; $itemNodes = $valueNode->values; foreach ($itemNodes as $itemNode) { @@ -377,7 +379,7 @@ public static function valueFromAST(?ValueNode $valueNode, Type $type, ?array $v } if ($type instanceof InputObjectType) { - if (! $valueNode instanceof ObjectValueNode) { + if (! $valueNode instanceof ObjectValueNode && ! $valueNode instanceof ConstObjectValueNode) { // Invalid: intentionally return no value. return $undefined; } @@ -497,6 +499,7 @@ public static function valueFromASTUntyped(Node $valueNode, ?array $variables = return $valueNode->value; case $valueNode instanceof ListValueNode: + case $valueNode instanceof ConstListValueNode: $values = []; foreach ($valueNode->values as $node) { $values[] = self::valueFromASTUntyped($node, $variables); @@ -505,6 +508,7 @@ public static function valueFromASTUntyped(Node $valueNode, ?array $variables = return $values; case $valueNode instanceof ObjectValueNode: + case $valueNode instanceof ConstObjectValueNode: $values = []; foreach ($valueNode->fields as $field) { $values[$field->name->value] = self::valueFromASTUntyped($field->value, $variables); diff --git a/src/Utils/TypeInfo.php b/src/Utils/TypeInfo.php index 8e1d0c4db..6d700e277 100644 --- a/src/Utils/TypeInfo.php +++ b/src/Utils/TypeInfo.php @@ -4,6 +4,8 @@ use GraphQL\Error\InvariantViolation; use GraphQL\Language\AST\ArgumentNode; +use GraphQL\Language\AST\ConstListValueNode; +use GraphQL\Language\AST\ConstObjectFieldNode; use GraphQL\Language\AST\DirectiveNode; use GraphQL\Language\AST\EnumValueNode; use GraphQL\Language\AST\FieldNode; @@ -266,6 +268,7 @@ public function enter(Node $node): void break; case $node instanceof ListValueNode: + case $node instanceof ConstListValueNode: $type = $this->getInputType(); $listType = $type instanceof NonNull ? $type->getWrappedType() @@ -279,6 +282,7 @@ public function enter(Node $node): void break; case $node instanceof ObjectFieldNode: + case $node instanceof ConstObjectFieldNode: $objectType = Type::getNamedType($this->getInputType()); $inputField = null; $inputFieldType = null; @@ -410,7 +414,9 @@ public function leave(Node $node): void \array_pop($this->inputTypeStack); break; case $node instanceof ListValueNode: + case $node instanceof ConstListValueNode: case $node instanceof ObjectFieldNode: + case $node instanceof ConstObjectFieldNode: \array_pop($this->defaultValueStack); \array_pop($this->inputTypeStack); break; diff --git a/src/Validator/Rules/UniqueInputFieldNames.php b/src/Validator/Rules/UniqueInputFieldNames.php index 88a50e22b..8f3ff5856 100644 --- a/src/Validator/Rules/UniqueInputFieldNames.php +++ b/src/Validator/Rules/UniqueInputFieldNames.php @@ -3,6 +3,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; +use GraphQL\Language\AST\ConstObjectFieldNode; use GraphQL\Language\AST\NameNode; use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\ObjectFieldNode; @@ -54,7 +55,8 @@ public function getASTVisitor(ValidationContext $context): array $this->knownNames = $knownNames; }, ], - NodeKind::OBJECT_FIELD => function (ObjectFieldNode $node) use ($context): VisitorOperation { + NodeKind::OBJECT_FIELD => function ($node) use ($context): VisitorOperation { + assert($node instanceof ObjectFieldNode || $node instanceof ConstObjectFieldNode); $fieldName = $node->name->value; if (isset($this->knownNames[$fieldName])) { diff --git a/src/Validator/Rules/ValuesOfCorrectType.php b/src/Validator/Rules/ValuesOfCorrectType.php index 4e83f3b3e..ea5cbd749 100644 --- a/src/Validator/Rules/ValuesOfCorrectType.php +++ b/src/Validator/Rules/ValuesOfCorrectType.php @@ -4,6 +4,9 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\BooleanValueNode; +use GraphQL\Language\AST\ConstListValueNode; +use GraphQL\Language\AST\ConstObjectFieldNode; +use GraphQL\Language\AST\ConstObjectValueNode; use GraphQL\Language\AST\EnumValueNode; use GraphQL\Language\AST\FloatValueNode; use GraphQL\Language\AST\IntValueNode; @@ -14,7 +17,6 @@ use GraphQL\Language\AST\ObjectValueNode; use GraphQL\Language\AST\StringValueNode; use GraphQL\Language\AST\ValueNode; -use GraphQL\Language\AST\VariableNode; use GraphQL\Language\Printer; use GraphQL\Language\Visitor; use GraphQL\Language\VisitorOperation; @@ -31,6 +33,8 @@ * * A GraphQL document is only valid if all value literals are of the type * expected at their position. + * + * @phpstan-import-type ValueNodeVariants from ValueNode */ class ValuesOfCorrectType extends ValidationRule { @@ -50,7 +54,8 @@ public function getVisitor(QueryValidationContext $context): array ); } }, - NodeKind::LST => function (ListValueNode $node) use ($context): ?VisitorOperation { + NodeKind::LST => function ($node) use ($context): ?VisitorOperation { + assert($node instanceof ListValueNode || $node instanceof ConstListValueNode); // Note: TypeInfo will traverse into a list's item type, so look to the // parent input type to check if it is a list. $parentType = $context->getParentInputType(); @@ -65,7 +70,8 @@ public function getVisitor(QueryValidationContext $context): array return null; }, - NodeKind::OBJECT => function (ObjectValueNode $node) use ($context): ?VisitorOperation { + NodeKind::OBJECT => function ($node) use ($context): ?VisitorOperation { + assert($node instanceof ObjectValueNode || $node instanceof ConstObjectValueNode); $type = Type::getNamedType($context->getInputType()); if (! $type instanceof InputObjectType) { $this->isValidValueNode($context, $node); @@ -95,7 +101,8 @@ public function getVisitor(QueryValidationContext $context): array return null; }, - NodeKind::OBJECT_FIELD => static function (ObjectFieldNode $node) use ($context): void { + NodeKind::OBJECT_FIELD => static function ($node) use ($context): void { + assert($node instanceof ObjectFieldNode || $node instanceof ConstObjectFieldNode); $parentType = Type::getNamedType($context->getParentInputType()); if (! $parentType instanceof InputObjectType) { return; @@ -139,7 +146,7 @@ public function getVisitor(QueryValidationContext $context): array } /** - * @param VariableNode|NullValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|EnumValueNode|ListValueNode|ObjectValueNode $node + * @param ValueNodeVariants $node */ protected function isValidValueNode(QueryValidationContext $context, ValueNode $node): void { diff --git a/src/Validator/Rules/VariablesInAllowedPosition.php b/src/Validator/Rules/VariablesInAllowedPosition.php index 2435e979d..606fa2387 100644 --- a/src/Validator/Rules/VariablesInAllowedPosition.php +++ b/src/Validator/Rules/VariablesInAllowedPosition.php @@ -3,10 +3,10 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; +use GraphQL\Language\AST\ConstValueNode; use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\NullValueNode; use GraphQL\Language\AST\OperationDefinitionNode; -use GraphQL\Language\AST\ValueNode; use GraphQL\Language\AST\VariableDefinitionNode; use GraphQL\Type\Definition\NonNull; use GraphQL\Type\Definition\Type; @@ -85,10 +85,9 @@ public static function badVarPosMessage(string $varName, string $varType, string * which includes considering if default values exist for either the variable * or the location at which it is located. * - * @param ValueNode|null $varDefaultValue - * @param mixed $locationDefaultValue + * @param mixed $locationDefaultValue */ - protected function allowedVariableUsage(Schema $schema, Type $varType, $varDefaultValue, Type $locationType, $locationDefaultValue): bool + protected function allowedVariableUsage(Schema $schema, Type $varType, ?ConstValueNode $varDefaultValue, Type $locationType, $locationDefaultValue): bool { if ($locationType instanceof NonNull && ! $varType instanceof NonNull) { $hasNonNullVariableDefaultValue = $varDefaultValue !== null && ! $varDefaultValue instanceof NullValueNode; diff --git a/tests/Executor/VariablesTest.php b/tests/Executor/VariablesTest.php index e62f1f555..590f516ed 100644 --- a/tests/Executor/VariablesTest.php +++ b/tests/Executor/VariablesTest.php @@ -214,6 +214,9 @@ private function fieldWithInputArg(array $inputArg): array ]; } + /** + * describe('using variables', () => { + */ public function testUsingVariables(): void { $doc = ' @@ -222,7 +225,7 @@ public function testUsingVariables(): void } '; - // executes with complex input: + // it('executes with complex input', () => { $params = ['input' => ['a' => 'foo', 'b' => ['bar'], 'c' => 'baz']]; $result = $this->executeQuery($doc, $params); From db654fd07b99bbb4c2b9478bc13b9f1256fad33e Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 8 Mar 2023 12:43:07 +0100 Subject: [PATCH 04/11] conflict --- src/Language/Parser.php | 1 + src/Language/Printer.php | 4 +++- src/Utils/AST.php | 9 +++++---- src/Validator/Rules/ValuesOfCorrectType.php | 7 +++++-- tests/Executor/VariablesTest.php | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Language/Parser.php b/src/Language/Parser.php index 5116701e8..f9deb9b79 100644 --- a/src/Language/Parser.php +++ b/src/Language/Parser.php @@ -970,6 +970,7 @@ private function parseObjectField(bool $isConst): Node $class = $isConst ? ConstObjectFieldNode::class : ObjectFieldNode::class; + return new $class([ 'name' => $name, 'value' => $this->parseValueLiteral($isConst), diff --git a/src/Language/Printer.php b/src/Language/Printer.php index 97ae99fd9..fdb3ee978 100644 --- a/src/Language/Printer.php +++ b/src/Language/Printer.php @@ -316,6 +316,7 @@ protected function p(?Node $node): string case $node instanceof ListValueNode: case $node instanceof ConstListValueNode: + // @phpstan-ignore-next-line weird generic issue return '[' . $this->printList($node->values, ', ') . ']'; case $node instanceof NameNode: @@ -360,6 +361,7 @@ protected function p(?Node $node): string case $node instanceof ObjectValueNode: case $node instanceof ConstObjectValueNode: + // @phpstan-ignore-next-line weird generic issue return "{ {$this->printList($node->fields, ', ')} }"; case $node instanceof OperationDefinitionNode: @@ -507,7 +509,7 @@ protected function printListBlock(NodeList $list): string protected function addDescription(?StringValueNode $description, string $body): string { - return $this->join([$this->p($description, true), $body], "\n"); + return $this->join([$this->p($description), $body], "\n"); } /** diff --git a/src/Utils/AST.php b/src/Utils/AST.php index 4619c99ad..40199be2d 100644 --- a/src/Utils/AST.php +++ b/src/Utils/AST.php @@ -7,6 +7,7 @@ use GraphQL\Language\AST\BooleanValueNode; use GraphQL\Language\AST\ConstListValueNode; use GraphQL\Language\AST\ConstObjectValueNode; +use GraphQL\Language\AST\ConstValueNode; use GraphQL\Language\AST\DefinitionNode; use GraphQL\Language\AST\DocumentNode; use GraphQL\Language\AST\EnumValueNode; @@ -292,7 +293,7 @@ public static function astFromValue($value, InputType $type): ?ValueNode * | Enum Value | Mixed | * | Null Value | null | * - * @param (ValueNode&Node)|null $valueNode + * @param (ValueNode&Node)|(ConstValueNode&Node)|null $valueNode * @param array|null $variables * * @throws \Exception @@ -301,7 +302,7 @@ public static function astFromValue($value, InputType $type): ?ValueNode * * @api */ - public static function valueFromAST(?ValueNode $valueNode, Type $type, ?array $variables = null) + public static function valueFromAST(?Node $valueNode, Type $type, ?array $variables = null) { $undefined = Utils::undefined(); @@ -448,10 +449,10 @@ public static function valueFromAST(?ValueNode $valueNode, Type $type, ?array $v * Returns true if the provided valueNode is a variable which is not defined * in the set of variables. * - * @param ValueNode&Node $valueNode + * @param (ValueNode&Node)|(ConstValueNode&Node) $valueNode * @param array|null $variables */ - private static function isMissingVariable(ValueNode $valueNode, ?array $variables): bool + private static function isMissingVariable(Node $valueNode, ?array $variables): bool { return $valueNode instanceof VariableNode && ($variables === null || ! \array_key_exists($valueNode->name->value, $variables)); diff --git a/src/Validator/Rules/ValuesOfCorrectType.php b/src/Validator/Rules/ValuesOfCorrectType.php index ea5cbd749..7f64fba74 100644 --- a/src/Validator/Rules/ValuesOfCorrectType.php +++ b/src/Validator/Rules/ValuesOfCorrectType.php @@ -7,10 +7,12 @@ use GraphQL\Language\AST\ConstListValueNode; use GraphQL\Language\AST\ConstObjectFieldNode; use GraphQL\Language\AST\ConstObjectValueNode; +use GraphQL\Language\AST\ConstValueNode; use GraphQL\Language\AST\EnumValueNode; use GraphQL\Language\AST\FloatValueNode; use GraphQL\Language\AST\IntValueNode; use GraphQL\Language\AST\ListValueNode; +use GraphQL\Language\AST\Node; use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\NullValueNode; use GraphQL\Language\AST\ObjectFieldNode; @@ -35,6 +37,7 @@ * expected at their position. * * @phpstan-import-type ValueNodeVariants from ValueNode + * @phpstan-import-type ConstValueNodeVariants from ConstValueNode */ class ValuesOfCorrectType extends ValidationRule { @@ -146,9 +149,9 @@ public function getVisitor(QueryValidationContext $context): array } /** - * @param ValueNodeVariants $node + * @param ValueNodeVariants|ConstValueNodeVariants $node */ - protected function isValidValueNode(QueryValidationContext $context, ValueNode $node): void + protected function isValidValueNode(QueryValidationContext $context, Node $node): void { // Report any error at the full type expected by the location. $locationType = $context->getInputType(); diff --git a/tests/Executor/VariablesTest.php b/tests/Executor/VariablesTest.php index 590f516ed..7c912257a 100644 --- a/tests/Executor/VariablesTest.php +++ b/tests/Executor/VariablesTest.php @@ -215,7 +215,7 @@ private function fieldWithInputArg(array $inputArg): array } /** - * describe('using variables', () => { + * describe('using variables', () => {. */ public function testUsingVariables(): void { From 78458a80b84e369a6fa19d9eea3f6f1b8813017a Mon Sep 17 00:00:00 2001 From: spawnia Date: Wed, 8 Mar 2023 11:44:05 +0000 Subject: [PATCH 05/11] Prettify docs --- docs/class-reference.md | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/class-reference.md b/docs/class-reference.md index 47e598e36..064c12315 100644 --- a/docs/class-reference.md +++ b/docs/class-reference.md @@ -833,6 +833,10 @@ allowLegacySDLImplementsInterfaces?: bool, experimentalFragmentVariables?: bool } +@phpstan-import-type ConstValueNodeVariants from ConstValueNode +@phpstan-import-type ValueNodeVariants from ValueNode +@phpstan-import-type TypeNodeVariants from TypeNode + noLocation: (By default, the parser creates AST nodes that know the location in the source that they correspond to. This configuration flag @@ -888,17 +892,17 @@ Those magic functions allow partial parsing: @method static FragmentSpreadNode|InlineFragmentNode fragment(Source|string $source, bool[] $options = []) @method static FragmentDefinitionNode fragmentDefinition(Source|string $source, bool[] $options = []) @method static NameNode fragmentName(Source|string $source, bool[] $options = []) -@method static BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|NullValueNode|ObjectValueNode|StringValueNode|VariableNode valueLiteral(Source|string $source, bool[] $options = []) -@method static BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|NullValueNode|ObjectValueNode|StringValueNode constValueLiteral(Source|string $source, bool[] $options = []) +@method static ValueNodeVariants valueLiteral(Source|string $source, bool[] $options = []) +@method static ConstValueNodeVariants constValueLiteral(Source|string $source, bool[] $options = []) @method static StringValueNode stringLiteral(Source|string $source, bool[] $options = []) -@method static BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|StringValueNode constValue(Source|string $source, bool[] $options = []) -@method static BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|ObjectValueNode|StringValueNode|VariableNode variableValue(Source|string $source, bool[] $options = []) +@method static ConstValueNodeVariants constValue(Source|string $source, bool[] $options = []) +@method static ValueNodeVariants variableValue(Source|string $source, bool[] $options = []) @method static ListValueNode array(Source|string $source, bool[] $options = []) -@method static ListValueNode constArray(Source|string $source, bool[] $options = []) +@method static ConstListValueNode constArray(Source|string $source, bool[] $options = []) @method static ObjectValueNode object(Source|string $source, bool[] $options = []) -@method static ObjectValueNode constObject(Source|string $source, bool[] $options = []) +@method static ConstObjectValueNode constObject(Source|string $source, bool[] $options = []) @method static ObjectFieldNode objectField(Source|string $source, bool[] $options = []) -@method static ObjectFieldNode constObjectField(Source|string $source, bool[] $options = []) +@method static ConstObjectFieldNode constObjectField(Source|string $source, bool[] $options = []) @method static NodeList directives(Source|string $source, bool[] $options = []) @method static NodeList constDirectives(Source|string $source, bool[] $options = []) @method static DirectiveNode directive(Source|string $source, bool[] $options = []) @@ -970,11 +974,11 @@ static function parse($source, array $options = []): GraphQL\Language\AST\Docume * * @phpstan-param ParserOptions $options * - * @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|NullValueNode|ObjectValueNode|StringValueNode|VariableNode + * @return ValueNodeVariants * * @api */ -static function parseValue($source, array $options = []) +static function parseValue($source, array $options = []): GraphQL\Language\AST\ValueNode ``` ```php @@ -992,11 +996,11 @@ static function parseValue($source, array $options = []) * * @phpstan-param ParserOptions $options * - * @return ListTypeNode|NamedTypeNode|NonNullTypeNode + * @return TypeNodeVariants * * @api */ -static function parseType($source, array $options = []) +static function parseType($source, array $options = []): GraphQL\Language\AST\TypeNode ``` ## GraphQL\Language\Printer @@ -2427,7 +2431,7 @@ static function astFromValue($value, GraphQL\Type\Definition\InputType $type): ? * | Enum Value | Mixed | * | Null Value | null | * - * @param (ValueNode&Node)|null $valueNode + * @param (ValueNode&Node)|(ConstValueNode&Node)|null $valueNode * @param array|null $variables * * @throws \Exception @@ -2437,7 +2441,7 @@ static function astFromValue($value, GraphQL\Type\Definition\InputType $type): ? * @api */ static function valueFromAST( - ?GraphQL\Language\AST\ValueNode $valueNode, + ?GraphQL\Language\AST\Node $valueNode, GraphQL\Type\Definition\Type $type, ?array $variables = null ) From ba2d7f75560ffec34aad0e27e1581cd8184c6951 Mon Sep 17 00:00:00 2001 From: spawnia Date: Wed, 8 Mar 2023 11:46:58 +0000 Subject: [PATCH 06/11] Apply php-cs-fixer changes --- src/Language/Parser.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Language/Parser.php b/src/Language/Parser.php index 7ed2dc5a7..5de5def95 100644 --- a/src/Language/Parser.php +++ b/src/Language/Parser.php @@ -1025,6 +1025,7 @@ private function parseVariableValue(): ValueNode /** * @throws \JsonException * @throws SyntaxError + * * @return ListValueNode|ConstListValueNode */ private function parseArray(bool $isConst): Node @@ -1046,6 +1047,7 @@ private function parseArray(bool $isConst): Node /** * @throws \JsonException * @throws SyntaxError + * * @return ObjectValueNode|ConstObjectValueNode */ private function parseObject(bool $isConst): Node @@ -1069,6 +1071,7 @@ private function parseObject(bool $isConst): Node /** * @throws \JsonException * @throws SyntaxError + * * @return ObjectFieldNode|ConstObjectFieldNode */ private function parseObjectField(bool $isConst): Node From b581c4d223b2132db61738ba71ef20f8ce5a211f Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 8 Mar 2023 14:35:42 +0100 Subject: [PATCH 07/11] unify leaf type treatment --- src/Utils/AST.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Utils/AST.php b/src/Utils/AST.php index 0e083937a..f4a04d3b4 100644 --- a/src/Utils/AST.php +++ b/src/Utils/AST.php @@ -433,7 +433,10 @@ public static function valueFromAST(?Node $valueNode, Type $type, ?array $variab return $type->parseValue($coercedObj); } - if ($type instanceof EnumType) { + // Scalars and Enums fulfill parsing a literal value via parseLiteral(). + // Invalid values represent a failure to parse correctly, in which case + // no value is returned. + if ($type instanceof LeafType) { try { return $type->parseLiteral($valueNode, $variables); } catch (\Throwable $error) { @@ -441,16 +444,8 @@ public static function valueFromAST(?Node $valueNode, Type $type, ?array $variab } } - assert($type instanceof ScalarType, 'only remaining option'); - - // Scalars fulfill parsing a literal value via parseLiteral(). - // Invalid values represent a failure to parse correctly, in which case - // no value is returned. - try { - return $type->parseLiteral($valueNode, $variables); - } catch (\Throwable $error) { - return $undefined; - } + $unexpectedInputType = Utils::printSafe($type); + throw new \Exception("Unexpected input type: {$unexpectedInputType}"); } /** From 7c044636c6fe40becb7b83d7d9b5c9e0c413e2da Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 8 Mar 2023 14:40:14 +0100 Subject: [PATCH 08/11] parseLiteral --- src/Type/Definition/CustomScalarType.php | 6 ++++-- src/Type/Definition/LeafType.php | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Type/Definition/CustomScalarType.php b/src/Type/Definition/CustomScalarType.php index 1c0c0b421..fdcfc9fa1 100644 --- a/src/Type/Definition/CustomScalarType.php +++ b/src/Type/Definition/CustomScalarType.php @@ -4,6 +4,7 @@ use GraphQL\Error\Error; use GraphQL\Error\InvariantViolation; +use GraphQL\Language\AST\ConstValueNode; use GraphQL\Language\AST\Node; use GraphQL\Language\AST\ScalarTypeDefinitionNode; use GraphQL\Language\AST\ScalarTypeExtensionNode; @@ -12,12 +13,13 @@ use GraphQL\Utils\Utils; /** + * @phpstan-type ParseLiteralFn callable((ValueNode&Node)|(ConstValueNode&Node), array|null): mixed * @phpstan-type InputCustomScalarConfig array{ * name?: string|null, * description?: string|null, * serialize?: callable(mixed): mixed, * parseValue: callable(mixed): mixed, - * parseLiteral: callable(ValueNode&Node, array|null): mixed, + * parseLiteral: ParseLiteralFn, * astNode?: ScalarTypeDefinitionNode|null, * extensionASTNodes?: array|null * } @@ -26,7 +28,7 @@ * description?: string|null, * serialize: callable(mixed): mixed, * parseValue?: callable(mixed): mixed, - * parseLiteral?: callable(ValueNode&Node, array|null): mixed, + * parseLiteral?: ParseLiteralFn, * astNode?: ScalarTypeDefinitionNode|null, * extensionASTNodes?: array|null * } diff --git a/src/Type/Definition/LeafType.php b/src/Type/Definition/LeafType.php index 330105e07..db48234cc 100644 --- a/src/Type/Definition/LeafType.php +++ b/src/Type/Definition/LeafType.php @@ -4,6 +4,7 @@ use GraphQL\Error\Error; use GraphQL\Error\SerializationError; +use GraphQL\Language\AST\ConstValueNode; use GraphQL\Language\AST\Node; use GraphQL\Language\AST\ValueNode; @@ -45,7 +46,7 @@ public function parseValue($value); * * Should throw an exception with a client friendly message on invalid value nodes, @see ClientAware. * - * @param ValueNode&Node $valueNode + * @param (ValueNode&Node)|(ConstValueNode&Node) $valueNode * @param array|null $variables * * @throws Error From 68d62ba240e5a5905a747799f392bda645bfdc2b Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 8 Mar 2023 14:40:17 +0100 Subject: [PATCH 09/11] parseLiteral --- src/Utils/AST.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Utils/AST.php b/src/Utils/AST.php index f4a04d3b4..7d87c9ade 100644 --- a/src/Utils/AST.php +++ b/src/Utils/AST.php @@ -38,7 +38,6 @@ use GraphQL\Type\Definition\ListOfType; use GraphQL\Type\Definition\NonNull; use GraphQL\Type\Definition\NullableType; -use GraphQL\Type\Definition\ScalarType; use GraphQL\Type\Definition\Type; /** From 940cf0113e8de05aec83242817fc6a1fe5e611a6 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 8 Mar 2023 14:41:07 +0100 Subject: [PATCH 10/11] cl --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2f87300f..080fa0b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ You can find and compare releases at the [GitHub release page](https://github.co ## Unreleased +### Changed + +- Differentiate between const and non-const AST nodes + ## v15.2.3 ### Fixed From e08ac5d9e952088a76ae54f651749d4e580a58e2 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 8 Mar 2023 14:44:53 +0100 Subject: [PATCH 11/11] cleanup --- src/Executor/Values.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Executor/Values.php b/src/Executor/Values.php index 10eead40e..2f254a80c 100644 --- a/src/Executor/Values.php +++ b/src/Executor/Values.php @@ -42,8 +42,6 @@ use GraphQL\Utils\Value; /** - * @see ValueNode - force IDE import - * * @phpstan-import-type ValueNodeVariants from ValueNode */ class Values