@@ -77,7 +77,7 @@ |
||
77 | 77 | ?TypeInterface $initialType = null |
78 | 78 | ) { |
79 | 79 | $this->schema = $schema; |
80 | - $this->getFieldDefinitionFunction = $getFieldDefinitionFunction ?? function ( |
|
80 | + $this->getFieldDefinitionFunction = $getFieldDefinitionFunction ?? function( |
|
81 | 81 | Schema $schema, |
82 | 82 | TypeInterface $parentType, |
83 | 83 | FieldNode $fieldNode |
@@ -74,7 +74,7 @@ |
||
74 | 74 | function printLines(array $lines): string |
75 | 75 | { |
76 | 76 | // Don't print empty lines |
77 | - $lines = \array_filter($lines, function (string $line) { |
|
77 | + $lines = \array_filter($lines, function(string $line) { |
|
78 | 78 | return $line !== ''; |
79 | 79 | }); |
80 | 80 |
@@ -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 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function getLocationsAsArray(): ?array |
154 | 154 | { |
155 | - return !empty($this->locations) ? \array_map(function (SourceLocation $location) { |
|
155 | + return !empty($this->locations) ? \array_map(function(SourceLocation $location) { |
|
156 | 156 | return $location->toArray(); |
157 | 157 | }, $this->locations) : null; |
158 | 158 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $nodes = [$nodes]; |
194 | 194 | } |
195 | 195 | |
196 | - $this->nodes = \array_filter($nodes, function ($node) { |
|
196 | + $this->nodes = \array_filter($nodes, function($node) { |
|
197 | 197 | return null !== $node; |
198 | 198 | }); |
199 | 199 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | protected function resolvePositions(?array $positions) |
225 | 225 | { |
226 | 226 | if (null === $positions && !empty($this->nodes)) { |
227 | - $positions = \array_reduce($this->nodes, function (array $list, ?NodeInterface $node) { |
|
227 | + $positions = \array_reduce($this->nodes, function(array $list, ?NodeInterface $node) { |
|
228 | 228 | if (null !== $node) { |
229 | 229 | $location = $node->getLocation(); |
230 | 230 | if (null !== $location) { |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | protected function resolveLocations(?array $positions, ?Source $source) |
253 | 253 | { |
254 | 254 | if (null !== $positions && null !== $source) { |
255 | - $locations = \array_map(function ($position) use ($source) { |
|
255 | + $locations = \array_map(function($position) use ($source) { |
|
256 | 256 | return SourceLocation::fromSource($source, $position); |
257 | 257 | }, $positions); |
258 | 258 | } elseif (!empty($this->nodes)) { |
259 | - $locations = \array_reduce($this->nodes, function (array $list, NodeInterface $node) { |
|
259 | + $locations = \array_reduce($this->nodes, function(array $list, NodeInterface $node) { |
|
260 | 260 | $location = $node->getLocation(); |
261 | 261 | if (null !== $location) { |
262 | 262 | $list[] = SourceLocation::fromSource($location->getSource(), $location->getStart()); |
@@ -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 [ |