@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public static function fromArray(array $node) : Node |
90 | 90 | { |
91 | - if (! isset($node['kind']) || ! isset(NodeKind::$classMap[$node['kind']])) { |
|
91 | + if (!isset($node['kind']) || !isset(NodeKind::$classMap[$node['kind']])) { |
|
92 | 92 | throw new InvariantViolation('Unexpected node structure: ' . Utils::printSafeJson($node)); |
93 | 93 | } |
94 | 94 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $valuesNodes = []; |
177 | 177 | foreach ($value as $item) { |
178 | 178 | $itemNode = self::astFromValue($item, $itemType); |
179 | - if (! $itemNode) { |
|
179 | + if (!$itemNode) { |
|
180 | 180 | continue; |
181 | 181 | } |
182 | 182 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | if ($type instanceof InputObjectType) { |
195 | 195 | $isArray = is_array($value); |
196 | 196 | $isArrayLike = $isArray || $value instanceof ArrayAccess; |
197 | - if ($value === null || (! $isArrayLike && ! is_object($value))) { |
|
197 | + if ($value === null || (!$isArrayLike && !is_object($value))) { |
|
198 | 198 | return null; |
199 | 199 | } |
200 | 200 | $fields = $type->getFields(); |
@@ -218,13 +218,13 @@ discard block |
||
218 | 218 | $fieldExists = property_exists($value, $fieldName); |
219 | 219 | } |
220 | 220 | |
221 | - if (! $fieldExists) { |
|
221 | + if (!$fieldExists) { |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $fieldNode = self::astFromValue($fieldValue, $field->getType()); |
226 | 226 | |
227 | - if (! $fieldNode) { |
|
227 | + if (!$fieldNode) { |
|
228 | 228 | continue; |
229 | 229 | } |
230 | 230 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | if ($valueNode instanceof VariableNode) { |
344 | 344 | $variableName = $valueNode->name->value; |
345 | 345 | |
346 | - if (! $variables || ! array_key_exists($variableName, $variables)) { |
|
346 | + if (!$variables || !array_key_exists($variableName, $variables)) { |
|
347 | 347 | // No valid return value. |
348 | 348 | return $undefined; |
349 | 349 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | if ($type instanceof InputObjectType) { |
399 | - if (! $valueNode instanceof ObjectValueNode) { |
|
399 | + if (!$valueNode instanceof ObjectValueNode) { |
|
400 | 400 | // Invalid: intentionally return no value. |
401 | 401 | return $undefined; |
402 | 402 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $fields = $type->getFields(); |
406 | 406 | $fieldNodes = Utils::keyMap( |
407 | 407 | $valueNode->fields, |
408 | - static function ($field) { |
|
408 | + static function($field) { |
|
409 | 409 | return $field->name->value; |
410 | 410 | } |
411 | 411 | ); |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | } |
442 | 442 | |
443 | 443 | if ($type instanceof EnumType) { |
444 | - if (! $valueNode instanceof EnumValueNode) { |
|
444 | + if (!$valueNode instanceof EnumValueNode) { |
|
445 | 445 | return $undefined; |
446 | 446 | } |
447 | 447 | $enumValue = $type->getValue($valueNode->value); |
448 | - if (! $enumValue) { |
|
448 | + if (!$enumValue) { |
|
449 | 449 | return $undefined; |
450 | 450 | } |
451 | 451 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | private static function isMissingVariable(ValueNode $valueNode, $variables) |
479 | 479 | { |
480 | 480 | return $valueNode instanceof VariableNode && |
481 | - (count($variables) === 0 || ! array_key_exists($valueNode->name->value, $variables)); |
|
481 | + (count($variables) === 0 || !array_key_exists($valueNode->name->value, $variables)); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | return $valueNode->value; |
522 | 522 | case $valueNode instanceof ListValueNode: |
523 | 523 | return array_map( |
524 | - static function ($node) use ($variables) { |
|
524 | + static function($node) use ($variables) { |
|
525 | 525 | return self::valueFromASTUntyped($node, $variables); |
526 | 526 | }, |
527 | 527 | iterator_to_array($valueNode->values) |
@@ -529,13 +529,13 @@ discard block |
||
529 | 529 | case $valueNode instanceof ObjectValueNode: |
530 | 530 | return array_combine( |
531 | 531 | array_map( |
532 | - static function ($field) { |
|
532 | + static function($field) { |
|
533 | 533 | return $field->name->value; |
534 | 534 | }, |
535 | 535 | iterator_to_array($valueNode->fields) |
536 | 536 | ), |
537 | 537 | array_map( |
538 | - static function ($field) use ($variables) { |
|
538 | + static function($field) use ($variables) { |
|
539 | 539 | return self::valueFromASTUntyped($field->value, $variables); |
540 | 540 | }, |
541 | 541 | iterator_to_array($valueNode->fields) |
@@ -595,11 +595,11 @@ discard block |
||
595 | 595 | { |
596 | 596 | if ($document->definitions) { |
597 | 597 | foreach ($document->definitions as $def) { |
598 | - if (! ($def instanceof OperationDefinitionNode)) { |
|
598 | + if (!($def instanceof OperationDefinitionNode)) { |
|
599 | 599 | continue; |
600 | 600 | } |
601 | 601 | |
602 | - if (! $operationName || (isset($def->name->value) && $def->name->value === $operationName)) { |
|
602 | + if (!$operationName || (isset($def->name->value) && $def->name->value === $operationName)) { |
|
603 | 603 | return $def->operation; |
604 | 604 | } |
605 | 605 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'description' => $this->getDescription($directiveNode), |
82 | 82 | 'locations' => Utils::map( |
83 | 83 | $directiveNode->locations, |
84 | - static function ($node) { |
|
84 | + static function($node) { |
|
85 | 85 | return $node->value; |
86 | 86 | } |
87 | 87 | ), |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | private function getLeadingCommentBlock($node) |
112 | 112 | { |
113 | 113 | $loc = $node->loc; |
114 | - if (! $loc || ! $loc->startToken) { |
|
114 | + if (!$loc || !$loc->startToken) { |
|
115 | 115 | return null; |
116 | 116 | } |
117 | 117 | $comments = []; |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | { |
135 | 135 | return Utils::keyValMap( |
136 | 136 | $values, |
137 | - static function ($value) { |
|
137 | + static function($value) { |
|
138 | 138 | return $value->name->value; |
139 | 139 | }, |
140 | - function ($value) { |
|
140 | + function($value) { |
|
141 | 141 | // Note: While this could make assertions to get the correctly typed |
142 | 142 | // value, that would throw immediately while type system validation |
143 | 143 | // with validateSchema() will produce more actionable results. |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | private function internalBuildType($typeName, $typeNode = null) |
203 | 203 | { |
204 | - if (! isset($this->cache[$typeName])) { |
|
204 | + if (!isset($this->cache[$typeName])) { |
|
205 | 205 | if (isset($this->typeDefinitionsMap[$typeName])) { |
206 | 206 | $type = $this->makeSchemaDef($this->typeDefinitionsMap[$typeName]); |
207 | 207 | if ($this->typeConfigDecorator) { |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $e |
220 | 220 | ); |
221 | 221 | } |
222 | - if (! is_array($config) || isset($config[0])) { |
|
222 | + if (!is_array($config) || isset($config[0])) { |
|
223 | 223 | throw new Error( |
224 | 224 | sprintf( |
225 | 225 | 'Type config decorator passed to %s is expected to return an array, but got %s', |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | return new ObjectType([ |
275 | 275 | 'name' => $typeName, |
276 | 276 | 'description' => $this->getDescription($def), |
277 | - 'fields' => function () use ($def) { |
|
277 | + 'fields' => function() use ($def) { |
|
278 | 278 | return $this->makeFieldDefMap($def); |
279 | 279 | }, |
280 | - 'interfaces' => function () use ($def) { |
|
280 | + 'interfaces' => function() use ($def) { |
|
281 | 281 | return $this->makeImplementedInterfaces($def); |
282 | 282 | }, |
283 | 283 | 'astNode' => $def, |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | return $def->fields |
290 | 290 | ? Utils::keyValMap( |
291 | 291 | $def->fields, |
292 | - static function ($field) { |
|
292 | + static function($field) { |
|
293 | 293 | return $field->name->value; |
294 | 294 | }, |
295 | - function ($field) { |
|
295 | + function($field) { |
|
296 | 296 | return $this->buildField($field); |
297 | 297 | } |
298 | 298 | ) |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | // validation with validateSchema() will produce more actionable results. |
337 | 337 | return Utils::map( |
338 | 338 | $def->interfaces, |
339 | - function ($iface) { |
|
339 | + function($iface) { |
|
340 | 340 | return $this->buildType($iface); |
341 | 341 | } |
342 | 342 | ); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | return new InterfaceType([ |
353 | 353 | 'name' => $typeName, |
354 | 354 | 'description' => $this->getDescription($def), |
355 | - 'fields' => function () use ($def) { |
|
355 | + 'fields' => function() use ($def) { |
|
356 | 356 | return $this->makeFieldDefMap($def); |
357 | 357 | }, |
358 | 358 | 'astNode' => $def, |
@@ -367,10 +367,10 @@ discard block |
||
367 | 367 | 'values' => $def->values |
368 | 368 | ? Utils::keyValMap( |
369 | 369 | $def->values, |
370 | - static function ($enumValue) { |
|
370 | + static function($enumValue) { |
|
371 | 371 | return $enumValue->name->value; |
372 | 372 | }, |
373 | - function ($enumValue) { |
|
373 | + function($enumValue) { |
|
374 | 374 | return [ |
375 | 375 | 'description' => $this->getDescription($enumValue), |
376 | 376 | 'deprecationReason' => $this->getDeprecationReason($enumValue), |
@@ -392,10 +392,10 @@ discard block |
||
392 | 392 | // values below, that would throw immediately while type system |
393 | 393 | // validation with validateSchema() will produce more actionable results. |
394 | 394 | 'types' => $def->types |
395 | - ? function () use ($def) { |
|
395 | + ? function() use ($def) { |
|
396 | 396 | return Utils::map( |
397 | 397 | $def->types, |
398 | - function ($typeNode) { |
|
398 | + function($typeNode) { |
|
399 | 399 | return $this->buildType($typeNode); |
400 | 400 | } |
401 | 401 | ); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | 'name' => $def->name->value, |
412 | 412 | 'description' => $this->getDescription($def), |
413 | 413 | 'astNode' => $def, |
414 | - 'serialize' => static function ($value) { |
|
414 | + 'serialize' => static function($value) { |
|
415 | 415 | return $value; |
416 | 416 | }, |
417 | 417 | ]); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | return new InputObjectType([ |
423 | 423 | 'name' => $def->name->value, |
424 | 424 | 'description' => $this->getDescription($def), |
425 | - 'fields' => function () use ($def) { |
|
425 | + 'fields' => function() use ($def) { |
|
426 | 426 | return $def->fields |
427 | 427 | ? $this->makeInputValues($def->fields) |
428 | 428 | : []; |
@@ -22,10 +22,10 @@ |
||
22 | 22 | $this->knownFragmentNames = []; |
23 | 23 | |
24 | 24 | return [ |
25 | - NodeKind::OPERATION_DEFINITION => static function () { |
|
25 | + NodeKind::OPERATION_DEFINITION => static function() { |
|
26 | 26 | return Visitor::skipNode(); |
27 | 27 | }, |
28 | - NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) { |
|
28 | + NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) use ($context) { |
|
29 | 29 | $fragmentName = $node->name->value; |
30 | 30 | if (empty($this->knownFragmentNames[$fragmentName])) { |
31 | 31 | $this->knownFragmentNames[$fragmentName] = $node->name; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $context, |
32 | 32 | [ |
33 | 33 | NodeKind::OPERATION_DEFINITION => [ |
34 | - 'leave' => function (OperationDefinitionNode $operationDefinition) use ($context) { |
|
34 | + 'leave' => function(OperationDefinitionNode $operationDefinition) use ($context) { |
|
35 | 35 | $maxDepth = $this->fieldDepth($operationDefinition); |
36 | 36 | |
37 | 37 | if ($maxDepth <= $this->getMaxQueryDepth()) { |
@@ -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(); |