@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | |
47 | 47 | return $this->printFilteredSchema( |
48 | 48 | $schema, |
49 | - function (Directive $directive): bool { |
|
49 | + function(Directive $directive): bool { |
|
50 | 50 | return !isSpecifiedDirective($directive); |
51 | 51 | }, |
52 | - function (NamedTypeInterface $type): bool { |
|
52 | + function(NamedTypeInterface $type): bool { |
|
53 | 53 | return !isSpecifiedScalarType($type) && !isIntrospectionType($type); |
54 | 54 | } |
55 | 55 | ); |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | |
67 | 67 | return $this->printFilteredSchema( |
68 | 68 | $schema, |
69 | - function (Directive $directive): bool { |
|
69 | + function(Directive $directive): bool { |
|
70 | 70 | return isSpecifiedDirective($directive); |
71 | 71 | }, |
72 | - function (NamedTypeInterface $type): bool { |
|
72 | + function(NamedTypeInterface $type): bool { |
|
73 | 73 | return isIntrospectionType($type); |
74 | 74 | } |
75 | 75 | ); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $types = \array_filter(\array_values($schema->getTypeMap()), $filter); |
142 | 142 | |
143 | - \usort($types, function (NamedTypeInterface $typeA, NamedTypeInterface $typeB) { |
|
143 | + \usort($types, function(NamedTypeInterface $typeA, NamedTypeInterface $typeB) { |
|
144 | 144 | return \strcasecmp($typeA->getName(), $typeB->getName()); |
145 | 145 | }); |
146 | 146 | |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | $description = $this->printDescription($type); |
284 | 284 | $name = $type->getName(); |
285 | 285 | $implements = $type->hasInterfaces() |
286 | - ? ' implements ' . printArray(' & ', \array_map(function (InterfaceType $interface) { |
|
286 | + ? ' implements ' . printArray(' & ', \array_map(function(InterfaceType $interface) { |
|
287 | 287 | return $interface->getName(); |
288 | 288 | }, $type->getInterfaces())) |
289 | 289 | : ''; |
290 | - $fields = $this->printFields($type->getFields()); |
|
290 | + $fields = $this->printFields($type->getFields()); |
|
291 | 291 | |
292 | 292 | return printLines([ |
293 | 293 | $description, |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | // This is important for getting the linebreaks correct between the items. |
360 | 360 | $firstInBlock = true; |
361 | 361 | |
362 | - return printLines(\array_map(function (EnumValue $value) use (&$firstInBlock): string { |
|
362 | + return printLines(\array_map(function(EnumValue $value) use (&$firstInBlock): string { |
|
363 | 363 | $description = $this->printDescription($value, ' ', $firstInBlock); |
364 | 364 | $name = $value->getName(); |
365 | 365 | $deprecated = $this->printDeprecated($value); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | protected function printInputObjectType(InputObjectType $type): string |
382 | 382 | { |
383 | 383 | $description = $this->printDescription($type); |
384 | - $fields = \array_map(function (InputField $field): string { |
|
384 | + $fields = \array_map(function(InputField $field): string { |
|
385 | 385 | $description = $this->printDescription($field, ' '); |
386 | 386 | $inputValue = $this->printInputValue($field); |
387 | 387 | return printLines([ |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | // This is important for getting the linebreaks correct between the items. |
430 | 430 | $firstInBlock = true; |
431 | 431 | |
432 | - return printLines(\array_map(function (Field $field) use (&$firstInBlock): string { |
|
432 | + return printLines(\array_map(function(Field $field) use (&$firstInBlock): string { |
|
433 | 433 | $description = $this->printDescription($field, ' ', $firstInBlock); |
434 | 434 | $name = $field->getName(); |
435 | 435 | $arguments = $this->printArguments($field->getArguments()); |
@@ -456,15 +456,15 @@ discard block |
||
456 | 456 | } |
457 | 457 | |
458 | 458 | // If every arg does not have a description, print them on one line. |
459 | - if (arrayEvery($arguments, function (Argument $argument): bool { |
|
459 | + if (arrayEvery($arguments, function(Argument $argument): bool { |
|
460 | 460 | return !$argument->hasDescription(); |
461 | 461 | })) { |
462 | - return printInputFields(\array_map(function (Argument $argument) { |
|
462 | + return printInputFields(\array_map(function(Argument $argument) { |
|
463 | 463 | return $this->printInputValue($argument); |
464 | 464 | }, $arguments)); |
465 | 465 | } |
466 | 466 | |
467 | - $args = \array_map(function (Argument $argument) use ($indentation) { |
|
467 | + $args = \array_map(function(Argument $argument) use ($indentation) { |
|
468 | 468 | $description = $this->printDescription($argument, ' '); |
469 | 469 | $inputValue = $this->printInputValue($argument); |
470 | 470 | return printLines([ |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | */ |
572 | 572 | protected function printMany(array $definitions): array |
573 | 573 | { |
574 | - return \array_map(function ($definition) { |
|
574 | + return \array_map(function($definition) { |
|
575 | 575 | return $this->print($definition); |
576 | 576 | }, $definitions); |
577 | 577 | } |
@@ -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, |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | }); |
214 | 214 | |
215 | 215 | $this->container |
216 | - ->share(GraphQL::TYPE_INTROSPECTION, function () { |
|
216 | + ->share(GraphQL::TYPE_INTROSPECTION, function() { |
|
217 | 217 | return newObjectType([ |
218 | 218 | 'name' => GraphQL::TYPE_INTROSPECTION, |
219 | 219 | 'isIntrospection' => true, |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | 'Enum types provide their values. Object and Interface types provide the fields ' . |
226 | 226 | 'they describe. Abstract types, Union and Interface, provide the Object types ' . |
227 | 227 | 'possible at runtime. List and NonNull types compose other types.', |
228 | - 'fields' => function () { |
|
228 | + 'fields' => function() { |
|
229 | 229 | return [ |
230 | 230 | 'kind' => [ |
231 | 231 | 'type' => newNonNull(__TypeKind()), |
232 | - 'resolve' => function (TypeInterface $type) { |
|
232 | + 'resolve' => function(TypeInterface $type) { |
|
233 | 233 | if ($type instanceof ScalarType) { |
234 | 234 | return TypeKindEnum::SCALAR; |
235 | 235 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | 'args' => [ |
266 | 266 | 'includeDeprecated' => ['type' => booleanType(), 'defaultValue' => false], |
267 | 267 | ], |
268 | - 'resolve' => function (TypeInterface $type, array $args): |
|
268 | + 'resolve' => function(TypeInterface $type, array $args): |
|
269 | 269 | ?array { |
270 | 270 | ['includeDeprecated' => $includeDeprecated] = $args; |
271 | 271 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $fields = \array_values($type->getFields()); |
274 | 274 | |
275 | 275 | if (!$includeDeprecated) { |
276 | - $fields = \array_filter($fields, function (Field $field) { |
|
276 | + $fields = \array_filter($fields, function(Field $field) { |
|
277 | 277 | return !$field->isDeprecated(); |
278 | 278 | }); |
279 | 279 | } |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | ], |
287 | 287 | 'interfaces' => [ |
288 | 288 | 'type' => newList(newNonNull(__Type())), |
289 | - 'resolve' => function (TypeInterface $type): ?array { |
|
289 | + 'resolve' => function(TypeInterface $type): ?array { |
|
290 | 290 | return $type instanceof ObjectType ? $type->getInterfaces() : null; |
291 | 291 | }, |
292 | 292 | ], |
293 | 293 | 'possibleTypes' => [ |
294 | 294 | 'type' => newList(newNonNull(__Type())), |
295 | - 'resolve' => function ( |
|
295 | + 'resolve' => function( |
|
296 | 296 | TypeInterface $type, |
297 | 297 | array $args, |
298 | 298 | array $context, |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | 'args' => [ |
311 | 311 | 'includeDeprecated' => ['type' => booleanType(), 'defaultValue' => false], |
312 | 312 | ], |
313 | - 'resolve' => function (TypeInterface $type, array $args): ?array { |
|
313 | + 'resolve' => function(TypeInterface $type, array $args): ?array { |
|
314 | 314 | ['includeDeprecated' => $includeDeprecated] = $args; |
315 | 315 | |
316 | 316 | if ($type instanceof EnumType) { |
317 | 317 | $values = \array_values($type->getValues()); |
318 | 318 | |
319 | 319 | if (!$includeDeprecated) { |
320 | - $values = \array_filter($values, function (Field $field) { |
|
320 | + $values = \array_filter($values, function(Field $field) { |
|
321 | 321 | return !$field->isDeprecated(); |
322 | 322 | }); |
323 | 323 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | ], |
331 | 331 | 'inputFields' => [ |
332 | 332 | 'type' => newList(newNonNull(__InputValue())), |
333 | - 'resolve' => function (TypeInterface $type): ?array { |
|
333 | + 'resolve' => function(TypeInterface $type): ?array { |
|
334 | 334 | return $type instanceof InputObjectType ? $type->getFields() : null; |
335 | 335 | }, |
336 | 336 | ], |
@@ -341,20 +341,20 @@ discard block |
||
341 | 341 | }); |
342 | 342 | |
343 | 343 | $this->container |
344 | - ->share(GraphQL::FIELD_INTROSPECTION, function () { |
|
344 | + ->share(GraphQL::FIELD_INTROSPECTION, function() { |
|
345 | 345 | return newObjectType([ |
346 | 346 | 'name' => GraphQL::FIELD_INTROSPECTION, |
347 | 347 | 'isIntrospection' => true, |
348 | 348 | 'description' => |
349 | 349 | 'Object and Interface types are described by a list of Fields, each of ' . |
350 | 350 | 'which has a name, potentially a list of arguments, and a return type.', |
351 | - 'fields' => function () { |
|
351 | + 'fields' => function() { |
|
352 | 352 | return [ |
353 | 353 | 'name' => ['type' => newNonNull(stringType())], |
354 | 354 | 'description' => ['type' => stringType()], |
355 | 355 | 'args' => [ |
356 | 356 | 'type' => newNonNull(newList(newNonNull(__InputValue()))), |
357 | - 'resolve' => function (ArgumentsAwareInterface $directive): array { |
|
357 | + 'resolve' => function(ArgumentsAwareInterface $directive): array { |
|
358 | 358 | return $directive->getArguments() ?? []; |
359 | 359 | }, |
360 | 360 | ], |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | }); |
368 | 368 | |
369 | 369 | $this->container |
370 | - ->share(GraphQL::INPUT_VALUE_INTROSPECTION, function () { |
|
370 | + ->share(GraphQL::INPUT_VALUE_INTROSPECTION, function() { |
|
371 | 371 | return newObjectType([ |
372 | 372 | 'name' => GraphQL::INPUT_VALUE_INTROSPECTION, |
373 | 373 | 'isIntrospection' => true, |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | 'Arguments provided to Fields or Directives and the input fields of an ' . |
376 | 376 | 'InputObject are represented as Input Values which describe their type ' . |
377 | 377 | 'and optionally a default value.', |
378 | - 'fields' => function () { |
|
378 | + 'fields' => function() { |
|
379 | 379 | return [ |
380 | 380 | 'name' => ['type' => newNonNull(stringType())], |
381 | 381 | 'description' => ['type' => stringType()], |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | 'description' => |
386 | 386 | 'A GraphQL-formatted string representing the default value for this ' . |
387 | 387 | 'input value.', |
388 | - 'resolve' => function (/*$inputValue*/) { |
|
388 | + 'resolve' => function(/*$inputValue*/) { |
|
389 | 389 | // TODO: Implement this when we have support for printing AST. |
390 | 390 | return null; |
391 | 391 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | }); |
397 | 397 | |
398 | 398 | $this->container |
399 | - ->share(GraphQL::ENUM_VALUE_INTROSPECTION, function () { |
|
399 | + ->share(GraphQL::ENUM_VALUE_INTROSPECTION, function() { |
|
400 | 400 | return newObjectType([ |
401 | 401 | 'name' => GraphQL::ENUM_VALUE_INTROSPECTION, |
402 | 402 | 'isIntrospection' => true, |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | 'One possible value for a given Enum. Enum values are unique values, not ' . |
405 | 405 | 'a placeholder for a string or numeric value. However an Enum value is ' . |
406 | 406 | 'returned in a JSON response as a string.', |
407 | - 'fields' => function () { |
|
407 | + 'fields' => function() { |
|
408 | 408 | return [ |
409 | 409 | 'name' => ['type' => newNonNull(stringType())], |
410 | 410 | 'description' => ['type' => stringType()], |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | }); |
417 | 417 | |
418 | 418 | $this->container |
419 | - ->share(GraphQL::TYPE_KIND_INTROSPECTION, function () { |
|
419 | + ->share(GraphQL::TYPE_KIND_INTROSPECTION, function() { |
|
420 | 420 | return newEnumType([ |
421 | 421 | 'name' => GraphQL::TYPE_KIND_INTROSPECTION, |
422 | 422 | 'isIntrospection' => true, |
@@ -457,12 +457,12 @@ discard block |
||
457 | 457 | protected function registerMetaFields() |
458 | 458 | { |
459 | 459 | $this->container |
460 | - ->share(GraphQL::SCHEMA_META_FIELD_DEFINITION, function ($__Schema) { |
|
460 | + ->share(GraphQL::SCHEMA_META_FIELD_DEFINITION, function($__Schema) { |
|
461 | 461 | return newField([ |
462 | 462 | 'name' => '__schema', |
463 | 463 | 'description' => 'Access the current type schema of this server.', |
464 | 464 | 'type' => newNonNull($__Schema), |
465 | - 'resolve' => function ($source, $args, $context, ResolveInfo $info): Schema { |
|
465 | + 'resolve' => function($source, $args, $context, ResolveInfo $info): Schema { |
|
466 | 466 | return $info->getSchema(); |
467 | 467 | }, |
468 | 468 | ]); |
@@ -470,13 +470,13 @@ discard block |
||
470 | 470 | ->addArgument(GraphQL::SCHEMA_INTROSPECTION); |
471 | 471 | |
472 | 472 | $this->container |
473 | - ->share(GraphQL::TYPE_META_FIELD_DEFINITION, function ($__Type) { |
|
473 | + ->share(GraphQL::TYPE_META_FIELD_DEFINITION, function($__Type) { |
|
474 | 474 | return newField([ |
475 | 475 | 'name' => '__type', |
476 | 476 | 'description' => 'Request the type information of a single type.', |
477 | 477 | 'type' => $__Type, |
478 | 478 | 'args' => ['name' => ['type' => newNonNull(stringType())]], |
479 | - 'resolve' => function ($source, $args, $context, ResolveInfo $info): ?TypeInterface { |
|
479 | + 'resolve' => function($source, $args, $context, ResolveInfo $info): ?TypeInterface { |
|
480 | 480 | ['name' => $name] = $args; |
481 | 481 | return $info->getSchema()->getType($name); |
482 | 482 | }, |
@@ -485,12 +485,12 @@ discard block |
||
485 | 485 | ->addArgument(GraphQL::TYPE_INTROSPECTION); |
486 | 486 | |
487 | 487 | $this->container |
488 | - ->share(GraphQL::TYPE_NAME_META_FIELD_DEFINITION, function () { |
|
488 | + ->share(GraphQL::TYPE_NAME_META_FIELD_DEFINITION, function() { |
|
489 | 489 | return newField([ |
490 | 490 | 'name' => '__typename', |
491 | 491 | 'description' => 'The name of the current Object type at runtime.', |
492 | 492 | 'type' => newNonNull(stringType()), |
493 | - 'resolve' => function ($source, $args, $context, ResolveInfo $info): string { |
|
493 | + 'resolve' => function($source, $args, $context, ResolveInfo $info): string { |
|
494 | 494 | return $info->getParentType()->getName(); |
495 | 495 | }, |
496 | 496 | ]); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | function descriptionLines(string $description, int $maxLength): array |
11 | 11 | { |
12 | 12 | // Map over the description lines and merge them into a flat array. |
13 | - return \array_merge(...\array_map(function (string $line) use ($maxLength) { |
|
13 | + return \array_merge(...\array_map(function(string $line) use ($maxLength) { |
|
14 | 14 | if (\strlen($line) < ($maxLength + 5)) { |
15 | 15 | return [$line]; |
16 | 16 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function printLines(array $lines): string |
58 | 58 | { |
59 | 59 | // Don't print empty lines |
60 | - $lines = \array_filter($lines, function (string $line) { |
|
60 | + $lines = \array_filter($lines, function(string $line) { |
|
61 | 61 | return $line !== ''; |
62 | 62 | }); |
63 | 63 |