@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | public function getVisitor(ValidationContext $context) |
24 | 24 | { |
25 | 25 | return [ |
26 | - NodeKind::FIELD => function (FieldNode $node) use ($context) { |
|
26 | + NodeKind::FIELD => function(FieldNode $node) use ($context) { |
|
27 | 27 | $type = $context->getParentType(); |
28 | - if (! $type) { |
|
28 | + if (!$type) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | |
86 | 86 | foreach ($schema->getPossibleTypes($type) as $possibleType) { |
87 | 87 | $fields = $possibleType->getFields(); |
88 | - if (! isset($fields[$fieldName])) { |
|
88 | + if (!isset($fields[$fieldName])) { |
|
89 | 89 | continue; |
90 | 90 | } |
91 | 91 | // This object type defines this field. |
92 | 92 | $suggestedObjectTypes[] = $possibleType->name; |
93 | 93 | foreach ($possibleType->getInterfaces() as $possibleInterface) { |
94 | 94 | $fields = $possibleInterface->getFields(); |
95 | - if (! isset($fields[$fieldName])) { |
|
95 | + if (!isset($fields[$fieldName])) { |
|
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | // This interface type defines this field. |
99 | 99 | $interfaceUsageCount[$possibleInterface->name] = |
100 | - ! isset($interfaceUsageCount[$possibleInterface->name]) |
|
100 | + !isset($interfaceUsageCount[$possibleInterface->name]) |
|
101 | 101 | ? 0 |
102 | 102 | : $interfaceUsageCount[$possibleInterface->name] + 1; |
103 | 103 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $suggestions = Utils::quotedOrList($suggestedTypeNames); |
157 | 157 | |
158 | 158 | $message .= sprintf(' Did you mean to use an inline fragment on %s?', $suggestions); |
159 | - } elseif (! empty($suggestedFieldNames)) { |
|
159 | + } elseif (!empty($suggestedFieldNames)) { |
|
160 | 160 | $suggestions = Utils::quotedOrList($suggestedFieldNames); |
161 | 161 | |
162 | 162 | $message .= sprintf(' Did you mean %s?', $suggestions); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | return $this->invokeIfNeeded( |
32 | 32 | $context, |
33 | 33 | [ |
34 | - NodeKind::FIELD => static function (FieldNode $node) use ($context) { |
|
34 | + NodeKind::FIELD => static function(FieldNode $node) use ($context) { |
|
35 | 35 | if ($node->name->value !== '__type' && $node->name->value !== '__schema') { |
36 | 36 | return; |
37 | 37 | } |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | $this->fragmentDefs = []; |
27 | 27 | |
28 | 28 | return [ |
29 | - NodeKind::OPERATION_DEFINITION => function ($node) { |
|
29 | + NodeKind::OPERATION_DEFINITION => function($node) { |
|
30 | 30 | $this->operationDefs[] = $node; |
31 | 31 | |
32 | 32 | return Visitor::skipNode(); |
33 | 33 | }, |
34 | - NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $def) { |
|
34 | + NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $def) { |
|
35 | 35 | $this->fragmentDefs[] = $def; |
36 | 36 | |
37 | 37 | return Visitor::skipNode(); |
38 | 38 | }, |
39 | 39 | NodeKind::DOCUMENT => [ |
40 | - 'leave' => function () use ($context) { |
|
40 | + 'leave' => function() use ($context) { |
|
41 | 41 | $fragmentNameUsed = []; |
42 | 42 | |
43 | 43 | foreach ($this->operationDefs as $operation) { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | foreach ($this->fragmentDefs as $fragmentDef) { |
50 | 50 | $fragName = $fragmentDef->name->value; |
51 | - if (! empty($fragmentNameUsed[$fragName])) { |
|
51 | + if (!empty($fragmentNameUsed[$fragName])) { |
|
52 | 52 | continue; |
53 | 53 | } |
54 | 54 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | foreach ($definedDirectives as $directive) { |
40 | 40 | $directiveArgs[$directive->name] = array_map( |
41 | - static function (FieldArgument $arg) : string { |
|
41 | + static function(FieldArgument $arg) : string { |
|
42 | 42 | return $arg->name; |
43 | 43 | }, |
44 | 44 | $directive->args |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $astDefinitions = $context->getDocument()->definitions; |
49 | 49 | foreach ($astDefinitions as $def) { |
50 | - if (! ($def instanceof DirectiveDefinitionNode)) { |
|
50 | + if (!($def instanceof DirectiveDefinitionNode)) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $arguments = iterator_to_array($arguments->getIterator()); |
60 | 60 | } |
61 | 61 | |
62 | - $directiveArgs[$name] = array_map(static function (InputValueDefinitionNode $arg) : string { |
|
62 | + $directiveArgs[$name] = array_map(static function(InputValueDefinitionNode $arg) : string { |
|
63 | 63 | return $arg->name->value; |
64 | 64 | }, $arguments); |
65 | 65 | } else { |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | return [ |
71 | - NodeKind::DIRECTIVE => static function (DirectiveNode $directiveNode) use ($directiveArgs, $context) { |
|
71 | + NodeKind::DIRECTIVE => static function(DirectiveNode $directiveNode) use ($directiveArgs, $context) { |
|
72 | 72 | $directiveName = $directiveNode->name->value; |
73 | 73 | $knownArgs = $directiveArgs[$directiveName] ?? null; |
74 | 74 | |
75 | - if ($directiveNode->arguments === null || ! $knownArgs) { |
|
75 | + if ($directiveNode->arguments === null || !$knownArgs) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | { |
33 | 33 | return [ |
34 | 34 | NodeKind::OPERATION_DEFINITION => [ |
35 | - 'enter' => function () { |
|
35 | + 'enter' => function() { |
|
36 | 36 | $this->varDefMap = []; |
37 | 37 | }, |
38 | - 'leave' => function (OperationDefinitionNode $operation) use ($context) { |
|
38 | + 'leave' => function(OperationDefinitionNode $operation) use ($context) { |
|
39 | 39 | $usages = $context->getRecursiveVariableUsages($operation); |
40 | 40 | |
41 | 41 | foreach ($usages as $usage) { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $schema = $context->getSchema(); |
58 | 58 | $varType = TypeInfo::typeFromAST($schema, $varDef->type); |
59 | 59 | |
60 | - if (! $varType || $this->allowedVariableUsage($schema, $varType, $varDef->defaultValue, $type, $defaultValue)) { |
|
60 | + if (!$varType || $this->allowedVariableUsage($schema, $varType, $varDef->defaultValue, $type, $defaultValue)) { |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | }, |
70 | 70 | ], |
71 | - NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $varDefNode) { |
|
71 | + NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $varDefNode) { |
|
72 | 72 | $this->varDefMap[$varDefNode->variable->name->value] = $varDefNode; |
73 | 73 | }, |
74 | 74 | ]; |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | */ |
101 | 101 | private function allowedVariableUsage(Schema $schema, Type $varType, $varDefaultValue, Type $locationType, $locationDefaultValue) : bool |
102 | 102 | { |
103 | - if ($locationType instanceof NonNull && ! $varType instanceof NonNull) { |
|
104 | - $hasNonNullVariableDefaultValue = $varDefaultValue && ! $varDefaultValue instanceof NullValueNode; |
|
105 | - $hasLocationDefaultValue = ! Utils::isInvalid($locationDefaultValue); |
|
106 | - if (! $hasNonNullVariableDefaultValue && ! $hasLocationDefaultValue) { |
|
103 | + if ($locationType instanceof NonNull && !$varType instanceof NonNull) { |
|
104 | + $hasNonNullVariableDefaultValue = $varDefaultValue && !$varDefaultValue instanceof NullValueNode; |
|
105 | + $hasLocationDefaultValue = !Utils::isInvalid($locationDefaultValue); |
|
106 | + if (!$hasNonNullVariableDefaultValue && !$hasLocationDefaultValue) { |
|
107 | 107 | return false; |
108 | 108 | } |
109 | 109 | $nullableLocationType = $locationType->getWrappedType(); |
@@ -40,18 +40,18 @@ |
||
40 | 40 | |
41 | 41 | return [ |
42 | 42 | NodeKind::OBJECT => [ |
43 | - 'enter' => function () { |
|
43 | + 'enter' => function() { |
|
44 | 44 | $this->knownNameStack[] = $this->knownNames; |
45 | 45 | $this->knownNames = []; |
46 | 46 | }, |
47 | - 'leave' => function () { |
|
47 | + 'leave' => function() { |
|
48 | 48 | $this->knownNames = array_pop($this->knownNameStack); |
49 | 49 | }, |
50 | 50 | ], |
51 | - NodeKind::OBJECT_FIELD => function (ObjectFieldNode $node) use ($context) { |
|
51 | + NodeKind::OBJECT_FIELD => function(ObjectFieldNode $node) use ($context) { |
|
52 | 52 | $fieldName = $node->name->value; |
53 | 53 | |
54 | - if (! empty($this->knownNames[$fieldName])) { |
|
54 | + if (!empty($this->knownNames[$fieldName])) { |
|
55 | 55 | $context->reportError(new Error( |
56 | 56 | self::duplicateInputFieldMessage($fieldName), |
57 | 57 | [$this->knownNames[$fieldName], $node->name] |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $this->knownOperationNames = []; |
23 | 23 | |
24 | 24 | return [ |
25 | - NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use ($context) { |
|
25 | + NodeKind::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) { |
|
26 | 26 | $operationName = $node->name; |
27 | 27 | |
28 | 28 | if ($operationName) { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | return Visitor::skipNode(); |
40 | 40 | }, |
41 | - NodeKind::FRAGMENT_DEFINITION => static function () { |
|
41 | + NodeKind::FRAGMENT_DEFINITION => static function() { |
|
42 | 42 | return Visitor::skipNode(); |
43 | 43 | }, |
44 | 44 | ]; |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | $astDefinition = $context->getDocument()->definitions; |
73 | 73 | |
74 | 74 | foreach ($astDefinition as $def) { |
75 | - if (! ($def instanceof DirectiveDefinitionNode)) { |
|
75 | + if (!($def instanceof DirectiveDefinitionNode)) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $locationsMap[$def->name->value] = array_map( |
80 | - static function ($name) { |
|
80 | + static function($name) { |
|
81 | 81 | return $name->value; |
82 | 82 | }, |
83 | 83 | $def->locations |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | return [ |
88 | - NodeKind::DIRECTIVE => function ( |
|
88 | + NodeKind::DIRECTIVE => function( |
|
89 | 89 | DirectiveNode $node, |
90 | 90 | $key, |
91 | 91 | $parent, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $name = $node->name->value; |
99 | 99 | $locations = $locationsMap[$name] ?? null; |
100 | 100 | |
101 | - if (! $locations) { |
|
101 | + if (!$locations) { |
|
102 | 102 | $context->reportError(new Error( |
103 | 103 | self::unknownDirectiveMessage($name), |
104 | 104 | [$node] |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | $candidateLocation = $this->getDirectiveLocationForASTPath($ancestors); |
111 | 111 | |
112 | - if (! $candidateLocation || in_array($candidateLocation, $locations, true)) { |
|
112 | + if (!$candidateLocation || in_array($candidateLocation, $locations, true)) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | 115 | $context->reportError( |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | |
52 | 52 | return [ |
53 | 53 | NodeKind::FIELD => [ |
54 | - 'enter' => static function (FieldNode $node) use (&$fieldName) { |
|
54 | + 'enter' => static function(FieldNode $node) use (&$fieldName) { |
|
55 | 55 | $fieldName = $node->name->value; |
56 | 56 | }, |
57 | 57 | ], |
58 | - NodeKind::NULL => static function (NullValueNode $node) use ($context, &$fieldName) { |
|
58 | + NodeKind::NULL => static function(NullValueNode $node) use ($context, &$fieldName) { |
|
59 | 59 | $type = $context->getInputType(); |
60 | - if (! ($type instanceof NonNull)) { |
|
60 | + if (!($type instanceof NonNull)) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | }, |
71 | - NodeKind::LST => function (ListValueNode $node) use ($context, &$fieldName) { |
|
71 | + NodeKind::LST => function(ListValueNode $node) use ($context, &$fieldName) { |
|
72 | 72 | // Note: TypeInfo will traverse into a list's item type, so look to the |
73 | 73 | // parent input type to check if it is a list. |
74 | 74 | $type = Type::getNullableType($context->getParentInputType()); |
75 | - if (! $type instanceof ListOfType) { |
|
75 | + if (!$type instanceof ListOfType) { |
|
76 | 76 | $this->isValidScalar($context, $node, $fieldName); |
77 | 77 | |
78 | 78 | return Visitor::skipNode(); |
79 | 79 | } |
80 | 80 | }, |
81 | - NodeKind::OBJECT => function (ObjectValueNode $node) use ($context, &$fieldName) { |
|
81 | + NodeKind::OBJECT => function(ObjectValueNode $node) use ($context, &$fieldName) { |
|
82 | 82 | // Note: TypeInfo will traverse into a list's item type, so look to the |
83 | 83 | // parent input type to check if it is a list. |
84 | 84 | $type = Type::getNamedType($context->getInputType()); |
85 | - if (! $type instanceof InputObjectType) { |
|
85 | + if (!$type instanceof InputObjectType) { |
|
86 | 86 | $this->isValidScalar($context, $node, $fieldName); |
87 | 87 | |
88 | 88 | return Visitor::skipNode(); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $nodeFields = iterator_to_array($node->fields); |
94 | 94 | $fieldNodeMap = array_combine( |
95 | 95 | array_map( |
96 | - static function ($field) { |
|
96 | + static function($field) { |
|
97 | 97 | return $field->name->value; |
98 | 98 | }, |
99 | 99 | $nodeFields |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ); |
103 | 103 | foreach ($inputFields as $fieldName => $fieldDef) { |
104 | 104 | $fieldType = $fieldDef->getType(); |
105 | - if (isset($fieldNodeMap[$fieldName]) || ! ($fieldType instanceof NonNull) || ($fieldDef->defaultValueExists())) { |
|
105 | + if (isset($fieldNodeMap[$fieldName]) || !($fieldType instanceof NonNull) || ($fieldDef->defaultValueExists())) { |
|
106 | 106 | continue; |
107 | 107 | } |
108 | 108 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | ); |
115 | 115 | } |
116 | 116 | }, |
117 | - NodeKind::OBJECT_FIELD => static function (ObjectFieldNode $node) use ($context) { |
|
117 | + NodeKind::OBJECT_FIELD => static function(ObjectFieldNode $node) use ($context) { |
|
118 | 118 | $parentType = Type::getNamedType($context->getParentInputType()); |
119 | 119 | /** @var ScalarType|EnumType|InputObjectType|ListOfType|NonNull $fieldType */ |
120 | 120 | $fieldType = $context->getInputType(); |
121 | - if ($fieldType || ! ($parentType instanceof InputObjectType)) { |
|
121 | + if ($fieldType || !($parentType instanceof InputObjectType)) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $node->name->value, |
127 | 127 | array_keys($parentType->getFields()) |
128 | 128 | ); |
129 | - $didYouMean = $suggestions |
|
129 | + $didYouMean = $suggestions |
|
130 | 130 | ? 'Did you mean ' . Utils::orList($suggestions) . '?' |
131 | 131 | : null; |
132 | 132 | |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | ) |
138 | 138 | ); |
139 | 139 | }, |
140 | - NodeKind::ENUM => function (EnumValueNode $node) use ($context, &$fieldName) { |
|
140 | + NodeKind::ENUM => function(EnumValueNode $node) use ($context, &$fieldName) { |
|
141 | 141 | $type = Type::getNamedType($context->getInputType()); |
142 | - if (! $type instanceof EnumType) { |
|
142 | + if (!$type instanceof EnumType) { |
|
143 | 143 | $this->isValidScalar($context, $node, $fieldName); |
144 | - } elseif (! $type->getValue($node->value)) { |
|
144 | + } elseif (!$type->getValue($node->value)) { |
|
145 | 145 | $context->reportError( |
146 | 146 | new Error( |
147 | 147 | self::getBadValueMessage( |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | ); |
157 | 157 | } |
158 | 158 | }, |
159 | - NodeKind::INT => function (IntValueNode $node) use ($context, &$fieldName) { |
|
159 | + NodeKind::INT => function(IntValueNode $node) use ($context, &$fieldName) { |
|
160 | 160 | $this->isValidScalar($context, $node, $fieldName); |
161 | 161 | }, |
162 | - NodeKind::FLOAT => function (FloatValueNode $node) use ($context, &$fieldName) { |
|
162 | + NodeKind::FLOAT => function(FloatValueNode $node) use ($context, &$fieldName) { |
|
163 | 163 | $this->isValidScalar($context, $node, $fieldName); |
164 | 164 | }, |
165 | - NodeKind::STRING => function (StringValueNode $node) use ($context, &$fieldName) { |
|
165 | + NodeKind::STRING => function(StringValueNode $node) use ($context, &$fieldName) { |
|
166 | 166 | $this->isValidScalar($context, $node, $fieldName); |
167 | 167 | }, |
168 | - NodeKind::BOOLEAN => function (BooleanValueNode $node) use ($context, &$fieldName) { |
|
168 | + NodeKind::BOOLEAN => function(BooleanValueNode $node) use ($context, &$fieldName) { |
|
169 | 169 | $this->isValidScalar($context, $node, $fieldName); |
170 | 170 | }, |
171 | 171 | ]; |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | /** @var ScalarType|EnumType|InputObjectType|ListOfType|NonNull $locationType */ |
187 | 187 | $locationType = $context->getInputType(); |
188 | 188 | |
189 | - if (! $locationType) { |
|
189 | + if (!$locationType) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | 193 | $type = Type::getNamedType($locationType); |
194 | 194 | |
195 | - if (! $type instanceof ScalarType) { |
|
195 | + if (!$type instanceof ScalarType) { |
|
196 | 196 | $context->reportError( |
197 | 197 | new Error( |
198 | 198 | self::getBadValueMessage( |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $suggestions = Utils::suggestionList( |
240 | 240 | Printer::doPrint($node), |
241 | 241 | array_map( |
242 | - static function (EnumValueDefinition $value) { |
|
242 | + static function(EnumValueDefinition $value) { |
|
243 | 243 | return $value->name; |
244 | 244 | }, |
245 | 245 | $type->getValues() |