@@ -127,7 +127,7 @@ |
||
127 | 127 | // If both types are abstract, then determine if there is any intersection |
128 | 128 | // between possible concrete types of each. |
129 | 129 | return arraySome($schema->getPossibleTypes($typeA), |
130 | - function (NamedTypeInterface $type) use ($schema, $typeB) { |
|
130 | + function(NamedTypeInterface $type) use ($schema, $typeB) { |
|
131 | 131 | return $schema->isPossibleType($typeB, $type); |
132 | 132 | }); |
133 | 133 | } |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | |
46 | 46 | return $this->printFilteredSchema( |
47 | 47 | $schema, |
48 | - function (Directive $directive): bool { |
|
48 | + function(Directive $directive): bool { |
|
49 | 49 | return !isSpecifiedDirective($directive); |
50 | 50 | }, |
51 | - function (NamedTypeInterface $type): bool { |
|
51 | + function(NamedTypeInterface $type): bool { |
|
52 | 52 | return !isSpecifiedScalarType($type) && !isIntrospectionType($type); |
53 | 53 | } |
54 | 54 | ); |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | return $this->printFilteredSchema( |
67 | 67 | $schema, |
68 | - function (Directive $directive): bool { |
|
68 | + function(Directive $directive): bool { |
|
69 | 69 | return isSpecifiedDirective($directive); |
70 | 70 | }, |
71 | - function (NamedTypeInterface $type): bool { |
|
71 | + function(NamedTypeInterface $type): bool { |
|
72 | 72 | return isIntrospectionType($type); |
73 | 73 | } |
74 | 74 | ); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | { |
136 | 136 | $types = \array_filter(\array_values($schema->getTypeMap()), $filter); |
137 | 137 | |
138 | - \usort($types, function (NamedTypeInterface $typeA, NamedTypeInterface $typeB) { |
|
138 | + \usort($types, function(NamedTypeInterface $typeA, NamedTypeInterface $typeB) { |
|
139 | 139 | return \strcasecmp($typeA->getName(), $typeB->getName()); |
140 | 140 | }); |
141 | 141 | |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | $description = $this->printDescription($type); |
262 | 262 | $name = $type->getName(); |
263 | 263 | $implements = $type->hasInterfaces() |
264 | - ? ' implements ' . printArray(' & ', \array_map(function (InterfaceType $interface) { |
|
264 | + ? ' implements ' . printArray(' & ', \array_map(function(InterfaceType $interface) { |
|
265 | 265 | return $interface->getName(); |
266 | 266 | }, $type->getInterfaces())) |
267 | 267 | : ''; |
268 | - $fields = $this->printFields($type->getFields()); |
|
268 | + $fields = $this->printFields($type->getFields()); |
|
269 | 269 | |
270 | 270 | return printLines([ |
271 | 271 | $description, |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | protected function printEnumValues(array $values): string |
331 | 331 | { |
332 | - return printLines(\array_map(function (EnumValue $value): string { |
|
332 | + return printLines(\array_map(function(EnumValue $value): string { |
|
333 | 333 | $description = $this->printDescription($value, ' '); |
334 | 334 | $name = $value->getName(); |
335 | 335 | $deprecated = $this->printDeprecated($value); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | protected function printInputObjectType(InputObjectType $type): string |
351 | 351 | { |
352 | 352 | $description = $this->printDescription($type); |
353 | - $fields = \array_map(function (InputField $field): string { |
|
353 | + $fields = \array_map(function(InputField $field): string { |
|
354 | 354 | $description = $this->printDescription($field, ' '); |
355 | 355 | $inputValue = $this->printInputValue($field); |
356 | 356 | return printLines([ |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | protected function printFields(array $fields): string |
393 | 393 | { |
394 | - return printLines(\array_map(function (Field $field): string { |
|
394 | + return printLines(\array_map(function(Field $field): string { |
|
395 | 395 | $description = $this->printDescription($field); |
396 | 396 | $name = $field->getName(); |
397 | 397 | $arguments = $this->printArguments($field->getArguments()); |
@@ -411,15 +411,15 @@ discard block |
||
411 | 411 | } |
412 | 412 | |
413 | 413 | // If every arg does not have a description, print them on one line. |
414 | - if (arrayEvery($arguments, function (Argument $argument): bool { |
|
414 | + if (arrayEvery($arguments, function(Argument $argument): bool { |
|
415 | 415 | return !$argument->hasDescription(); |
416 | 416 | })) { |
417 | - return printInputFields(\array_map(function (Argument $argument) { |
|
417 | + return printInputFields(\array_map(function(Argument $argument) { |
|
418 | 418 | return $this->printInputValue($argument); |
419 | 419 | }, $arguments)); |
420 | 420 | } |
421 | 421 | |
422 | - $args = \array_map(function (Argument $argument) use ($indentation) { |
|
422 | + $args = \array_map(function(Argument $argument) use ($indentation) { |
|
423 | 423 | $description = $this->printDescription($argument); |
424 | 424 | $inputValue = $this->printInputValue($argument); |
425 | 425 | return printLines([ |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | */ |
548 | 548 | protected function printMany(array $definitions): array |
549 | 549 | { |
550 | - return \array_map(function ($definition) { |
|
550 | + return \array_map(function($definition) { |
|
551 | 551 | return $this->print($definition); |
552 | 552 | }, $definitions); |
553 | 553 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | if (null !== $fieldDefinition && null !== $parentType) { |
56 | 56 | /** @noinspection PhpUnhandledExceptionInspection */ |
57 | - $options = \array_map(function (Argument $argument) { |
|
57 | + $options = \array_map(function(Argument $argument) { |
|
58 | 58 | return $argument->getName(); |
59 | 59 | }, $fieldDefinition->getArguments()); |
60 | 60 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | if (null !== $directive) { |
88 | 88 | /** @noinspection PhpUnhandledExceptionInspection */ |
89 | - $options = \array_map(function (Argument $argument) { |
|
89 | + $options = \array_map(function(Argument $argument) { |
|
90 | 90 | return $argument->getName(); |
91 | 91 | }, $directive->getArguments()); |
92 | 92 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | */ |
42 | 42 | public function getOperationTypesAST(): array |
43 | 43 | { |
44 | - return \array_map(function (OperationTypeDefinitionNode $node) { |
|
44 | + return \array_map(function(OperationTypeDefinitionNode $node) { |
|
45 | 45 | return $node->toAST(); |
46 | 46 | }, $this->operationTypes); |
47 | 47 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | /** |
323 | 323 | * @return TypeNodeInterface |
324 | 324 | */ |
325 | - $parseType = function (): TypeNodeInterface { |
|
325 | + $parseType = function(): TypeNodeInterface { |
|
326 | 326 | $this->expect(TokenKindEnum::COLON); |
327 | 327 | return $this->lexType(); |
328 | 328 | }; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | /** |
434 | 434 | * @return ArgumentNode |
435 | 435 | */ |
436 | - $parseFunction = function () use ($isConst): ArgumentNode { |
|
436 | + $parseFunction = function() use ($isConst) : ArgumentNode { |
|
437 | 437 | return $this->lexArgument($isConst); |
438 | 438 | }; |
439 | 439 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | /** |
461 | 461 | * @return NodeInterface|TypeNodeInterface|ValueNodeInterface |
462 | 462 | */ |
463 | - $parseValue = function () use ($isConst): NodeInterface { |
|
463 | + $parseValue = function() use ($isConst): NodeInterface { |
|
464 | 464 | $this->expect(TokenKindEnum::COLON); |
465 | 465 | return $this->lexValue($isConst); |
466 | 466 | }; |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | |
530 | 530 | $this->expectKeyword(KeywordEnum::FRAGMENT); |
531 | 531 | |
532 | - $parseTypeCondition = function () { |
|
532 | + $parseTypeCondition = function() { |
|
533 | 533 | $this->expectKeyword(KeywordEnum::ON); |
534 | 534 | return $this->lexNamedType(); |
535 | 535 | }; |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | { |
660 | 660 | $start = $this->lexer->getToken(); |
661 | 661 | |
662 | - $parseFunction = function () use ($isConst) { |
|
662 | + $parseFunction = function() use ($isConst) { |
|
663 | 663 | return $this->lexValue($isConst); |
664 | 664 | }; |
665 | 665 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @param bool $isConst |
713 | 713 | * @return NodeInterface|TypeNodeInterface|ValueNodeInterface |
714 | 714 | */ |
715 | - $parseValue = function (bool $isConst): NodeInterface { |
|
715 | + $parseValue = function(bool $isConst): NodeInterface { |
|
716 | 716 | $this->expect(TokenKindEnum::COLON); |
717 | 717 | return $this->lexValue($isConst); |
718 | 718 | }; |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | */ |
1054 | 1054 | protected function lexArgumentsDefinition(): array |
1055 | 1055 | { |
1056 | - $parseFunction = function (): InputValueDefinitionNode { |
|
1056 | + $parseFunction = function(): InputValueDefinitionNode { |
|
1057 | 1057 | return $this->lexInputValueDefinition(); |
1058 | 1058 | }; |
1059 | 1059 | |
@@ -1259,7 +1259,7 @@ discard block |
||
1259 | 1259 | */ |
1260 | 1260 | protected function lexInputFieldsDefinition(): array |
1261 | 1261 | { |
1262 | - $parseFunction = function (): InputValueDefinitionNode { |
|
1262 | + $parseFunction = function(): InputValueDefinitionNode { |
|
1263 | 1263 | return $this->lexInputValueDefinition(); |
1264 | 1264 | }; |
1265 | 1265 | |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | |
1328 | 1328 | $directives = $this->lexDirectives(true); |
1329 | 1329 | |
1330 | - $parseFunction = function (): OperationTypeDefinitionNode { |
|
1330 | + $parseFunction = function(): OperationTypeDefinitionNode { |
|
1331 | 1331 | return $this->lexOperationTypeDefinition(); |
1332 | 1332 | }; |
1333 | 1333 | |
@@ -1601,7 +1601,7 @@ discard block |
||
1601 | 1601 | |
1602 | 1602 | $name = $this->lexName(); |
1603 | 1603 | |
1604 | - if (arraySome(DirectiveLocationEnum::values(), function ($value) use ($name) { |
|
1604 | + if (arraySome(DirectiveLocationEnum::values(), function($value) use ($name) { |
|
1605 | 1605 | return $name->getValue() === $value; |
1606 | 1606 | })) { |
1607 | 1607 | return $name; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function buildTypes(array $nodes): array |
109 | 109 | { |
110 | - return \array_map(function (NamedTypeNodeInterface $node) { |
|
110 | + return \array_map(function(NamedTypeNodeInterface $node) { |
|
111 | 111 | return $this->buildType($node); |
112 | 112 | }, $nodes); |
113 | 113 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $directive = newDirective([ |
154 | 154 | 'name' => $node->getNameValue(), |
155 | 155 | 'description' => $node->getDescriptionValue(), |
156 | - 'locations' => \array_map(function (NameNode $node) { |
|
156 | + 'locations' => \array_map(function(NameNode $node) { |
|
157 | 157 | return $node->getValue(); |
158 | 158 | }, $node->getLocations()), |
159 | 159 | 'args' => $node->hasArguments() ? $this->buildArguments($node->getArguments()) : [], |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | { |
222 | 222 | $typesMap = keyMap( |
223 | 223 | \array_merge($customTypes, specifiedScalarTypes(), introspectionTypes()), |
224 | - function (NamedTypeInterface $type) { |
|
224 | + function(NamedTypeInterface $type) { |
|
225 | 225 | return $type->getName(); |
226 | 226 | } |
227 | 227 | ); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | { |
239 | 239 | $directivesMap = keyMap( |
240 | 240 | \array_merge($customDirectives, specifiedDirectives()), |
241 | - function (Directive $directive) { |
|
241 | + function(Directive $directive) { |
|
242 | 242 | return $directive->getName(); |
243 | 243 | } |
244 | 244 | ); |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | { |
258 | 258 | return keyValueMap( |
259 | 259 | $nodes, |
260 | - function (InputValueDefinitionNode $value) { |
|
260 | + function(InputValueDefinitionNode $value) { |
|
261 | 261 | return $value->getNameValue(); |
262 | 262 | }, |
263 | - function (InputValueDefinitionNode $value): array { |
|
263 | + function(InputValueDefinitionNode $value): array { |
|
264 | 264 | $type = $this->buildWrappedType($value->getType()); |
265 | 265 | $defaultValue = $value->getDefaultValue(); |
266 | 266 | return [ |
@@ -314,14 +314,14 @@ discard block |
||
314 | 314 | return newObjectType([ |
315 | 315 | 'name' => $node->getNameValue(), |
316 | 316 | 'description' => $node->getDescriptionValue(), |
317 | - 'fields' => $node->hasFields() ? function () use ($node) { |
|
317 | + 'fields' => $node->hasFields() ? function() use ($node) { |
|
318 | 318 | return $this->buildFields($node); |
319 | 319 | } : [], |
320 | 320 | // Note: While this could make early assertions to get the correctly |
321 | 321 | // typed values, that would throw immediately while type system |
322 | 322 | // validation with validateSchema() will produce more actionable results. |
323 | - 'interfaces' => function () use ($node) { |
|
324 | - return $node->hasInterfaces() ? \array_map(function (NamedTypeNodeInterface $interface) { |
|
323 | + 'interfaces' => function() use ($node) { |
|
324 | + return $node->hasInterfaces() ? \array_map(function(NamedTypeNodeInterface $interface) { |
|
325 | 325 | return $this->buildType($interface); |
326 | 326 | }, $node->getInterfaces()) : []; |
327 | 327 | }, |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | { |
338 | 338 | return keyValueMap( |
339 | 339 | $node->getFields(), |
340 | - function ($value) { |
|
340 | + function($value) { |
|
341 | 341 | /** @var FieldDefinitionNode|InputValueDefinitionNode $value */ |
342 | 342 | return $value->getNameValue(); |
343 | 343 | }, |
344 | - function ($value) use ($node) { |
|
344 | + function($value) use ($node) { |
|
345 | 345 | /** @var FieldDefinitionNode|InputValueDefinitionNode $value */ |
346 | 346 | return $this->buildField($value, |
347 | 347 | $this->getFieldResolver($node->getNameValue(), $value->getNameValue())); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | return newInterfaceType([ |
372 | 372 | 'name' => $node->getNameValue(), |
373 | 373 | 'description' => $node->getDescriptionValue(), |
374 | - 'fields' => $node->hasFields() ? function () use ($node): array { |
|
374 | + 'fields' => $node->hasFields() ? function() use ($node) : array { |
|
375 | 375 | return $this->buildFields($node); |
376 | 376 | } : [], |
377 | 377 | 'resolveType' => $this->getTypeResolver($node->getNameValue()), |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | 'description' => $node->getDescriptionValue(), |
392 | 392 | 'values' => $node->hasValues() ? keyValueMap( |
393 | 393 | $node->getValues(), |
394 | - function (EnumValueDefinitionNode $value): ?string { |
|
394 | + function(EnumValueDefinitionNode $value): ?string { |
|
395 | 395 | return $value->getNameValue(); |
396 | 396 | }, |
397 | - function (EnumValueDefinitionNode $value): array { |
|
397 | + function(EnumValueDefinitionNode $value): array { |
|
398 | 398 | return [ |
399 | 399 | 'description' => $value->getDescriptionValue(), |
400 | 400 | 'deprecationReason' => $this->getDeprecationReason($value), |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | return newUnionType([ |
417 | 417 | 'name' => $node->getNameValue(), |
418 | 418 | 'description' => $node->getDescriptionValue(), |
419 | - 'types' => $node->hasTypes() ? \array_map(function (NamedTypeNodeInterface $type) { |
|
419 | + 'types' => $node->hasTypes() ? \array_map(function(NamedTypeNodeInterface $type) { |
|
420 | 420 | return $this->buildType($type); |
421 | 421 | }, $node->getTypes()) : [], |
422 | 422 | 'resolveType' => $this->getTypeResolver($node->getNameValue()), |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | return newScalarType([ |
446 | 446 | 'name' => $node->getNameValue(), |
447 | 447 | 'description' => $node->getDescriptionValue(), |
448 | - 'serialize' => function ($value) { |
|
448 | + 'serialize' => function($value) { |
|
449 | 449 | return $value; |
450 | 450 | }, |
451 | 451 | 'astNode' => $node, |
@@ -462,13 +462,13 @@ discard block |
||
462 | 462 | return newInputObjectType([ |
463 | 463 | 'name' => $node->getNameValue(), |
464 | 464 | 'description' => $node->getDescriptionValue(), |
465 | - 'fields' => $node->hasFields() ? function () use ($node) { |
|
465 | + 'fields' => $node->hasFields() ? function() use ($node) { |
|
466 | 466 | return keyValueMap( |
467 | 467 | $node->getFields(), |
468 | - function (InputValueDefinitionNode $value): ?string { |
|
468 | + function(InputValueDefinitionNode $value): ?string { |
|
469 | 469 | return $value->getNameValue(); |
470 | 470 | }, |
471 | - function (InputValueDefinitionNode $value): array { |
|
471 | + function(InputValueDefinitionNode $value): array { |
|
472 | 472 | $type = $this->buildWrappedType($value->getType()); |
473 | 473 | $defaultValue = $value->getDefaultValue(); |
474 | 474 | return [ |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function buildTypes(): array |
79 | 79 | { |
80 | - return \array_map(function (NamedTypeNodeInterface $definition) { |
|
80 | + return \array_map(function(NamedTypeNodeInterface $definition) { |
|
81 | 81 | return $this->definitionBuilder->buildType($definition); |
82 | 82 | }, \array_values($this->info->getTypeDefinitionMap())); |
83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function buildDirectives(): array |
89 | 89 | { |
90 | - $directives = \array_map(function (DirectiveDefinitionNode $definition) { |
|
90 | + $directives = \array_map(function(DirectiveDefinitionNode $definition) { |
|
91 | 91 | return $this->definitionBuilder->buildDirective($definition); |
92 | 92 | }, $this->info->getDirectiveDefinitions()); |
93 | 93 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ]; |
99 | 99 | |
100 | 100 | foreach ($specifiedDirectivesMap as $name => $directive) { |
101 | - if (!arraySome($directives, function (Directive $directive) use ($name) { |
|
101 | + if (!arraySome($directives, function(Directive $directive) use ($name) { |
|
102 | 102 | return $directive->getName() === $name; |
103 | 103 | })) { |
104 | 104 | $directives[] = $directive; |
@@ -34,17 +34,17 @@ discard block |
||
34 | 34 | public function register() |
35 | 35 | { |
36 | 36 | $this->container |
37 | - ->share(GraphQL::BOOLEAN, function (BooleanCoercer $coercer) { |
|
37 | + ->share(GraphQL::BOOLEAN, function(BooleanCoercer $coercer) { |
|
38 | 38 | return newScalarType([ |
39 | 39 | 'name' => TypeNameEnum::BOOLEAN, |
40 | 40 | 'description' => 'The `Boolean` scalar type represents `true` or `false`.', |
41 | - 'serialize' => function ($value) use ($coercer) { |
|
41 | + 'serialize' => function($value) use ($coercer) { |
|
42 | 42 | return $coercer->coerce($value); |
43 | 43 | }, |
44 | - 'parseValue' => function ($value) use ($coercer) { |
|
44 | + 'parseValue' => function($value) use ($coercer) { |
|
45 | 45 | return $coercer->coerce($value); |
46 | 46 | }, |
47 | - 'parseLiteral' => function (NodeInterface $node) { |
|
47 | + 'parseLiteral' => function(NodeInterface $node) { |
|
48 | 48 | if ($node instanceof BooleanValueNode) { |
49 | 49 | return $node->getValue(); |
50 | 50 | } |
@@ -55,20 +55,20 @@ discard block |
||
55 | 55 | ->addArgument(BooleanCoercer::class); |
56 | 56 | |
57 | 57 | $this->container |
58 | - ->share(GraphQL::FLOAT, function (FloatCoercer $coercer) { |
|
58 | + ->share(GraphQL::FLOAT, function(FloatCoercer $coercer) { |
|
59 | 59 | return newScalarType([ |
60 | 60 | 'name' => TypeNameEnum::FLOAT, |
61 | 61 | 'description' => |
62 | 62 | 'The `Float` scalar type represents signed double-precision fractional ' . |
63 | 63 | 'values as specified by ' . |
64 | 64 | '[IEEE 754](https://en.wikipedia.org/wiki/IEEE_754).', |
65 | - 'serialize' => function ($value) use ($coercer) { |
|
65 | + 'serialize' => function($value) use ($coercer) { |
|
66 | 66 | return $coercer->coerce($value); |
67 | 67 | }, |
68 | - 'parseValue' => function ($value) use ($coercer) { |
|
68 | + 'parseValue' => function($value) use ($coercer) { |
|
69 | 69 | return $coercer->coerce($value); |
70 | 70 | }, |
71 | - 'parseLiteral' => function (NodeInterface $node) { |
|
71 | + 'parseLiteral' => function(NodeInterface $node) { |
|
72 | 72 | if ($node instanceof FloatValueNode || $node instanceof IntValueNode) { |
73 | 73 | return $node->getValue(); |
74 | 74 | } |
@@ -79,19 +79,19 @@ discard block |
||
79 | 79 | ->addArgument(FloatCoercer::class); |
80 | 80 | |
81 | 81 | $this->container |
82 | - ->share(GraphQL::INT, function (IntCoercer $coercer) { |
|
82 | + ->share(GraphQL::INT, function(IntCoercer $coercer) { |
|
83 | 83 | return newScalarType([ |
84 | 84 | 'name' => TypeNameEnum::INT, |
85 | 85 | 'description' => |
86 | 86 | 'The `Int` scalar type represents non-fractional signed whole numeric ' . |
87 | 87 | 'values. Int can represent values between -(2^31) and 2^31 - 1.', |
88 | - 'serialize' => function ($value) use ($coercer) { |
|
88 | + 'serialize' => function($value) use ($coercer) { |
|
89 | 89 | return $coercer->coerce($value); |
90 | 90 | }, |
91 | - 'parseValue' => function ($value) use ($coercer) { |
|
91 | + 'parseValue' => function($value) use ($coercer) { |
|
92 | 92 | return $coercer->coerce($value); |
93 | 93 | }, |
94 | - 'parseLiteral' => function (NodeInterface $node) { |
|
94 | + 'parseLiteral' => function(NodeInterface $node) { |
|
95 | 95 | if ($node instanceof IntValueNode) { |
96 | 96 | $value = (int)$node->getValue(); |
97 | 97 | if ((string)$node->getValue() === (string)$value && |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ->addArgument(IntCoercer::class); |
107 | 107 | |
108 | 108 | $this->container |
109 | - ->share(GraphQL::ID, function (StringCoercer $coercer) { |
|
109 | + ->share(GraphQL::ID, function(StringCoercer $coercer) { |
|
110 | 110 | return newScalarType([ |
111 | 111 | 'name' => TypeNameEnum::ID, |
112 | 112 | 'description' => |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | 'response as a String; however, it is not intended to be human-readable. ' . |
116 | 116 | 'When expected as an input type, any string (such as `"4"`) or integer ' . |
117 | 117 | '(such as `4`) input value will be accepted as an ID.', |
118 | - 'serialize' => function ($value) use ($coercer) { |
|
118 | + 'serialize' => function($value) use ($coercer) { |
|
119 | 119 | return $coercer->coerce($value); |
120 | 120 | }, |
121 | - 'parseValue' => function ($value) use ($coercer) { |
|
121 | + 'parseValue' => function($value) use ($coercer) { |
|
122 | 122 | return $coercer->coerce($value); |
123 | 123 | }, |
124 | - 'parseLiteral' => function (NodeInterface $node) { |
|
124 | + 'parseLiteral' => function(NodeInterface $node) { |
|
125 | 125 | if ($node instanceof StringValueNode || $node instanceof IntValueNode) { |
126 | 126 | return $node->getValue(); |
127 | 127 | } |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | ->addArgument(StringCoercer::class); |
133 | 133 | |
134 | 134 | $this->container |
135 | - ->share(GraphQL::STRING, function (StringCoercer $coercer) { |
|
135 | + ->share(GraphQL::STRING, function(StringCoercer $coercer) { |
|
136 | 136 | return newScalarType([ |
137 | 137 | 'name' => TypeNameEnum::STRING, |
138 | 138 | 'description' => |
139 | 139 | 'The `String` scalar type represents textual data, represented as UTF-8 ' . |
140 | 140 | 'character sequences. The String type is most often used by GraphQL to ' . |
141 | 141 | 'represent free-form human-readable text.', |
142 | - 'serialize' => function ($value) use ($coercer) { |
|
142 | + 'serialize' => function($value) use ($coercer) { |
|
143 | 143 | return $coercer->coerce($value); |
144 | 144 | }, |
145 | - 'parseValue' => function ($value) use ($coercer) { |
|
145 | + 'parseValue' => function($value) use ($coercer) { |
|
146 | 146 | return $coercer->coerce($value); |
147 | 147 | }, |
148 | - 'parseLiteral' => function (NodeInterface $node) { |
|
148 | + 'parseLiteral' => function(NodeInterface $node) { |
|
149 | 149 | if ($node instanceof StringValueNode) { |
150 | 150 | return $node->getValue(); |
151 | 151 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | protected function registerIntrospectionTypes() |
59 | 59 | { |
60 | 60 | $this->container |
61 | - ->share(GraphQL::SCHEMA_INTROSPECTION, function () { |
|
61 | + ->share(GraphQL::SCHEMA_INTROSPECTION, function() { |
|
62 | 62 | return newObjectType([ |
63 | 63 | 'name' => GraphQL::SCHEMA_INTROSPECTION, |
64 | 64 | 'isIntrospection' => true, |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | 'A GraphQL Schema defines the capabilities of a GraphQL server. It ' . |
67 | 67 | 'exposes all available types and directives on the server, as well as ' . |
68 | 68 | 'the entry points for query, mutation, and subscription operations.', |
69 | - 'fields' => function () { |
|
69 | + 'fields' => function() { |
|
70 | 70 | return [ |
71 | 71 | 'types' => [ |
72 | 72 | 'description' => 'A list of all types supported by this server.', |
73 | 73 | 'type' => newNonNull(newList(newNonNull(__Type()))), |
74 | - 'resolve' => function (Schema $schema): array { |
|
74 | + 'resolve' => function(Schema $schema): array { |
|
75 | 75 | return \array_values($schema->getTypeMap()); |
76 | 76 | }, |
77 | 77 | ], |
78 | 78 | 'queryType' => [ |
79 | 79 | 'description' => 'The type that query operations will be rooted at.', |
80 | 80 | 'type' => newNonNull(__Type()), |
81 | - 'resolve' => function (Schema $schema): ?TypeInterface { |
|
81 | + 'resolve' => function(Schema $schema): ?TypeInterface { |
|
82 | 82 | return $schema->getQueryType(); |
83 | 83 | }, |
84 | 84 | ], |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | 'If this server supports mutation, the type that ' . |
88 | 88 | 'mutation operations will be rooted at.', |
89 | 89 | 'type' => __Type(), |
90 | - 'resolve' => function (Schema $schema): ?TypeInterface { |
|
90 | + 'resolve' => function(Schema $schema): ?TypeInterface { |
|
91 | 91 | return $schema->getMutationType(); |
92 | 92 | }, |
93 | 93 | ], |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | 'If this server support subscription, the type that ' . |
97 | 97 | 'subscription operations will be rooted at.', |
98 | 98 | 'type' => __Type(), |
99 | - 'resolve' => function (Schema $schema): ?TypeInterface { |
|
99 | + 'resolve' => function(Schema $schema): ?TypeInterface { |
|
100 | 100 | return $schema->getSubscriptionType(); |
101 | 101 | }, |
102 | 102 | ], |
103 | 103 | 'directives' => [ |
104 | 104 | 'description' => 'A list of all directives supported by this server.', |
105 | 105 | 'type' => newNonNull(newList(newNonNull(__Directive()))), |
106 | - 'resolve' => function (Schema $schema): array { |
|
106 | + 'resolve' => function(Schema $schema): array { |
|
107 | 107 | return $schema->getDirectives(); |
108 | 108 | }, |
109 | 109 | ], |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | }); |
114 | 114 | |
115 | 115 | $this->container |
116 | - ->share(GraphQL::DIRECTIVE_INTROSPECTION, function () { |
|
116 | + ->share(GraphQL::DIRECTIVE_INTROSPECTION, function() { |
|
117 | 117 | return newObjectType([ |
118 | 118 | 'name' => GraphQL::DIRECTIVE_INTROSPECTION, |
119 | 119 | 'isIntrospection' => true, |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'execution behavior in ways field arguments will not suffice, such as ' . |
125 | 125 | 'conditionally including or skipping a field. Directives provide this by ' . |
126 | 126 | 'describing additional information to the executor.', |
127 | - 'fields' => function () { |
|
127 | + 'fields' => function() { |
|
128 | 128 | return [ |
129 | 129 | 'name' => ['type' => newNonNull(stringType())], |
130 | 130 | 'description' => ['type' => stringType()], |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ], |
134 | 134 | 'args' => [ |
135 | 135 | 'type' => newNonNull(newList(newNonNull(__InputValue()))), |
136 | - 'resolve' => function (Directive $directive): array { |
|
136 | + 'resolve' => function(Directive $directive): array { |
|
137 | 137 | return $directive->getArguments() ?: []; |
138 | 138 | }, |
139 | 139 | ], |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | }); |
144 | 144 | |
145 | 145 | $this->container |
146 | - ->share(GraphQL::DIRECTIVE_LOCATION_INTROSPECTION, function () { |
|
146 | + ->share(GraphQL::DIRECTIVE_LOCATION_INTROSPECTION, function() { |
|
147 | 147 | return newEnumType([ |
148 | 148 | 'name' => GraphQL::DIRECTIVE_LOCATION_INTROSPECTION, |
149 | 149 | 'isIntrospection' => true, |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | }); |
211 | 211 | |
212 | 212 | $this->container |
213 | - ->share(GraphQL::TYPE_INTROSPECTION, function () { |
|
213 | + ->share(GraphQL::TYPE_INTROSPECTION, function() { |
|
214 | 214 | return newObjectType([ |
215 | 215 | 'name' => GraphQL::TYPE_INTROSPECTION, |
216 | 216 | 'isIntrospection' => true, |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | 'Object and Interface types provide the fields they describe. Abstract ' . |
224 | 224 | 'types, Union and Interface, provide the Object types possible ' . |
225 | 225 | 'at runtime. List and NonNull types compose other types.', |
226 | - 'fields' => function () { |
|
226 | + 'fields' => function() { |
|
227 | 227 | return [ |
228 | 228 | 'kind' => [ |
229 | 229 | 'type' => newNonNull(__TypeKind()), |
230 | - 'resolve' => function (TypeInterface $type) { |
|
230 | + 'resolve' => function(TypeInterface $type) { |
|
231 | 231 | if ($type instanceof ScalarType) { |
232 | 232 | return TypeKindEnum::SCALAR; |
233 | 233 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | 'args' => [ |
264 | 264 | 'includeDeprecated' => ['type' => booleanType(), 'defaultValue' => false], |
265 | 265 | ], |
266 | - 'resolve' => function (TypeInterface $type, array $args): |
|
266 | + 'resolve' => function(TypeInterface $type, array $args): |
|
267 | 267 | ?array { |
268 | 268 | ['includeDeprecated' => $includeDeprecated] = $args; |
269 | 269 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $fields = \array_values($type->getFields()); |
272 | 272 | |
273 | 273 | if (!$includeDeprecated) { |
274 | - $fields = \array_filter($fields, function (Field $field) { |
|
274 | + $fields = \array_filter($fields, function(Field $field) { |
|
275 | 275 | return !$field->isDeprecated(); |
276 | 276 | }); |
277 | 277 | } |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | ], |
285 | 285 | 'interfaces' => [ |
286 | 286 | 'type' => newList(newNonNull(__Type())), |
287 | - 'resolve' => function (TypeInterface $type): ?array { |
|
287 | + 'resolve' => function(TypeInterface $type): ?array { |
|
288 | 288 | return $type instanceof ObjectType ? $type->getInterfaces() : null; |
289 | 289 | }, |
290 | 290 | ], |
291 | 291 | 'possibleTypes' => [ |
292 | 292 | 'type' => newList(newNonNull(__Type())), |
293 | - 'resolve' => function ( |
|
293 | + 'resolve' => function( |
|
294 | 294 | TypeInterface $type, |
295 | 295 | array $args, |
296 | 296 | array $context, |
@@ -308,14 +308,14 @@ discard block |
||
308 | 308 | 'args' => [ |
309 | 309 | 'includeDeprecated' => ['type' => booleanType(), 'defaultValue' => false], |
310 | 310 | ], |
311 | - 'resolve' => function (TypeInterface $type, array $args): ?array { |
|
311 | + 'resolve' => function(TypeInterface $type, array $args): ?array { |
|
312 | 312 | ['includeDeprecated' => $includeDeprecated] = $args; |
313 | 313 | |
314 | 314 | if ($type instanceof EnumType) { |
315 | 315 | $values = \array_values($type->getValues()); |
316 | 316 | |
317 | 317 | if (!$includeDeprecated) { |
318 | - $values = \array_filter($values, function (Field $field) { |
|
318 | + $values = \array_filter($values, function(Field $field) { |
|
319 | 319 | return !$field->isDeprecated(); |
320 | 320 | }); |
321 | 321 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | ], |
329 | 329 | 'inputFields' => [ |
330 | 330 | 'type' => newList(newNonNull(__InputValue())), |
331 | - 'resolve' => function (TypeInterface $type): ?array { |
|
331 | + 'resolve' => function(TypeInterface $type): ?array { |
|
332 | 332 | return $type instanceof InputObjectType ? $type->getFields() : null; |
333 | 333 | }, |
334 | 334 | ], |
@@ -339,20 +339,20 @@ discard block |
||
339 | 339 | }); |
340 | 340 | |
341 | 341 | $this->container |
342 | - ->share(GraphQL::FIELD_INTROSPECTION, function () { |
|
342 | + ->share(GraphQL::FIELD_INTROSPECTION, function() { |
|
343 | 343 | return newObjectType([ |
344 | 344 | 'name' => GraphQL::FIELD_INTROSPECTION, |
345 | 345 | 'isIntrospection' => true, |
346 | 346 | 'description' => |
347 | 347 | 'Object and Interface types are described by a list of Fields, each of ' . |
348 | 348 | 'which has a name, potentially a list of arguments, and a return type.', |
349 | - 'fields' => function () { |
|
349 | + 'fields' => function() { |
|
350 | 350 | return [ |
351 | 351 | 'name' => ['type' => newNonNull(stringType())], |
352 | 352 | 'description' => ['type' => stringType()], |
353 | 353 | 'args' => [ |
354 | 354 | 'type' => newNonNull(newList(newNonNull(__InputValue()))), |
355 | - 'resolve' => function (ArgumentsAwareInterface $directive): array { |
|
355 | + 'resolve' => function(ArgumentsAwareInterface $directive): array { |
|
356 | 356 | return $directive->getArguments() ?? []; |
357 | 357 | }, |
358 | 358 | ], |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | }); |
366 | 366 | |
367 | 367 | $this->container |
368 | - ->share(GraphQL::INPUT_VALUE_INTROSPECTION, function () { |
|
368 | + ->share(GraphQL::INPUT_VALUE_INTROSPECTION, function() { |
|
369 | 369 | return newObjectType([ |
370 | 370 | 'name' => GraphQL::INPUT_VALUE_INTROSPECTION, |
371 | 371 | 'isIntrospection' => true, |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | 'Arguments provided to Fields or Directives and the input fields of an ' . |
374 | 374 | 'InputObject are represented as Input Values which describe their type ' . |
375 | 375 | 'and optionally a default value.', |
376 | - 'fields' => function () { |
|
376 | + 'fields' => function() { |
|
377 | 377 | return [ |
378 | 378 | 'name' => ['type' => newNonNull(stringType())], |
379 | 379 | 'description' => ['type' => stringType()], |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | 'description' => |
384 | 384 | 'A GraphQL-formatted string representing the default value for this ' . |
385 | 385 | 'input value.', |
386 | - 'resolve' => function (/*$inputValue*/) { |
|
386 | + 'resolve' => function(/*$inputValue*/) { |
|
387 | 387 | // TODO: Implement this when we have support for printing AST. |
388 | 388 | return null; |
389 | 389 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | }); |
395 | 395 | |
396 | 396 | $this->container |
397 | - ->share(GraphQL::ENUM_VALUE_INTROSPECTION, function () { |
|
397 | + ->share(GraphQL::ENUM_VALUE_INTROSPECTION, function() { |
|
398 | 398 | return newObjectType([ |
399 | 399 | 'name' => GraphQL::ENUM_VALUE_INTROSPECTION, |
400 | 400 | 'isIntrospection' => true, |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | 'One possible value for a given Enum. Enum values are unique values, not ' . |
403 | 403 | 'a placeholder for a string or numeric value. However an Enum value is ' . |
404 | 404 | 'returned in a JSON response as a string.', |
405 | - 'fields' => function () { |
|
405 | + 'fields' => function() { |
|
406 | 406 | return [ |
407 | 407 | 'name' => ['type' => newNonNull(stringType())], |
408 | 408 | 'description' => ['type' => stringType()], |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | }); |
415 | 415 | |
416 | 416 | $this->container |
417 | - ->share(GraphQL::TYPE_KIND_INTROSPECTION, function () { |
|
417 | + ->share(GraphQL::TYPE_KIND_INTROSPECTION, function() { |
|
418 | 418 | return newEnumType([ |
419 | 419 | 'name' => GraphQL::TYPE_KIND_INTROSPECTION, |
420 | 420 | 'isIntrospection' => true, |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | protected function registerMetaFields() |
456 | 456 | { |
457 | 457 | $this->container |
458 | - ->share(GraphQL::SCHEMA_META_FIELD_DEFINITION, function ($__Schema) { |
|
458 | + ->share(GraphQL::SCHEMA_META_FIELD_DEFINITION, function($__Schema) { |
|
459 | 459 | return newField([ |
460 | 460 | 'name' => '__schema', |
461 | 461 | 'description' => 'Access the current type schema of this server.', |
462 | 462 | 'type' => newNonNull($__Schema), |
463 | - 'resolve' => function ($source, $args, $context, ResolveInfo $info): Schema { |
|
463 | + 'resolve' => function($source, $args, $context, ResolveInfo $info): Schema { |
|
464 | 464 | return $info->getSchema(); |
465 | 465 | }, |
466 | 466 | ]); |
@@ -468,13 +468,13 @@ discard block |
||
468 | 468 | ->addArgument(GraphQL::SCHEMA_INTROSPECTION); |
469 | 469 | |
470 | 470 | $this->container |
471 | - ->share(GraphQL::TYPE_META_FIELD_DEFINITION, function ($__Type) { |
|
471 | + ->share(GraphQL::TYPE_META_FIELD_DEFINITION, function($__Type) { |
|
472 | 472 | return newField([ |
473 | 473 | 'name' => '__type', |
474 | 474 | 'description' => 'Request the type information of a single type.', |
475 | 475 | 'type' => $__Type, |
476 | 476 | 'args' => ['name' => ['type' => newNonNull(stringType())]], |
477 | - 'resolve' => function ($source, $args, $context, ResolveInfo $info): ?TypeInterface { |
|
477 | + 'resolve' => function($source, $args, $context, ResolveInfo $info): ?TypeInterface { |
|
478 | 478 | ['name' => $name] = $args; |
479 | 479 | return $info->getSchema()->getType($name); |
480 | 480 | }, |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | ->addArgument(GraphQL::TYPE_INTROSPECTION); |
484 | 484 | |
485 | 485 | $this->container |
486 | - ->share(GraphQL::TYPE_NAME_META_FIELD_DEFINITION, function () { |
|
486 | + ->share(GraphQL::TYPE_NAME_META_FIELD_DEFINITION, function() { |
|
487 | 487 | return newField([ |
488 | 488 | 'name' => '__typename', |
489 | 489 | 'description' => 'The name of the current Object type at runtime.', |
490 | 490 | 'type' => newNonNull(stringType()), |
491 | - 'resolve' => function ($source, $args, $context, ResolveInfo $info): string { |
|
491 | + 'resolve' => function($source, $args, $context, ResolveInfo $info): string { |
|
492 | 492 | return $info->getParentType()->getName(); |
493 | 493 | }, |
494 | 494 | ]); |