@@ -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(); |
@@ -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] |