@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | ) |
165 | 165 | ); |
166 | 166 | |
167 | - $this->_possibleTypeMap = array_reduce($possibleTypes, function (array $map, TypeInterface $type) { |
|
167 | + $this->_possibleTypeMap = array_reduce($possibleTypes, function(array $map, TypeInterface $type) { |
|
168 | 168 | $map[$type->getName()] = true; |
169 | 169 | return $map; |
170 | 170 | }); |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | if ($type instanceof ObjectType || $type instanceof InterfaceType) { |
377 | 377 | foreach ($type->getFields() as $field) { |
378 | 378 | if ($field->hasArguments()) { |
379 | - $fieldArgTypes = array_map(function (Argument $argument) { |
|
379 | + $fieldArgTypes = array_map(function(Argument $argument) { |
|
380 | 380 | return $argument->getType(); |
381 | 381 | }, $field->getArguments()); |
382 | 382 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | return $map; |
408 | 408 | } |
409 | 409 | |
410 | - return array_reduce($directive->getArguments(), function ($map, Argument $argument) { |
|
410 | + return array_reduce($directive->getArguments(), function($map, Argument $argument) { |
|
411 | 411 | return typeMapReducer($map, $argument->getType()); |
412 | 412 | }, $map); |
413 | 413 | } |
@@ -78,27 +78,27 @@ |
||
78 | 78 | |
79 | 79 | $this->definitionBuilder->setTypeDefinitionMap($nodeMap); |
80 | 80 | |
81 | - $types = array_map(function (TypeDefinitionNodeInterface $definition) { |
|
81 | + $types = array_map(function(TypeDefinitionNodeInterface $definition) { |
|
82 | 82 | return $this->definitionBuilder->buildType($definition); |
83 | 83 | }, $typeDefinitions); |
84 | 84 | |
85 | - $directives = array_map(function (DirectiveDefinitionNode $definition) { |
|
85 | + $directives = array_map(function(DirectiveDefinitionNode $definition) { |
|
86 | 86 | return $this->definitionBuilder->buildDirective($definition); |
87 | 87 | }, $directiveDefinitions); |
88 | 88 | |
89 | - if (!arraySome($directives, function (DirectiveInterface $directive) { |
|
89 | + if (!arraySome($directives, function(DirectiveInterface $directive) { |
|
90 | 90 | return $directive->getName() === 'skip'; |
91 | 91 | })) { |
92 | 92 | $directives[] = GraphQLSkipDirective(); |
93 | 93 | } |
94 | 94 | |
95 | - if (!arraySome($directives, function (DirectiveInterface $directive) { |
|
95 | + if (!arraySome($directives, function(DirectiveInterface $directive) { |
|
96 | 96 | return $directive->getName() === 'include'; |
97 | 97 | })) { |
98 | 98 | $directives[] = GraphQLIncludeDirective(); |
99 | 99 | } |
100 | 100 | |
101 | - if (!arraySome($directives, function (DirectiveInterface $directive) { |
|
101 | + if (!arraySome($directives, function(DirectiveInterface $directive) { |
|
102 | 102 | return $directive->getName() === 'deprecated'; |
103 | 103 | })) { |
104 | 104 | $directives[] = GraphQLDeprecatedDirective(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function arraySome(array $array, callable $fn) |
25 | 25 | { |
26 | - return array_reduce($array, function ($result, $value) use ($fn) { |
|
26 | + return array_reduce($array, function($result, $value) use ($fn) { |
|
27 | 27 | return $result || $fn($value); |
28 | 28 | }); |
29 | 29 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function keyMap(array $array, callable $keyFn): array |
37 | 37 | { |
38 | - return array_reduce($array, function ($map, $item) use ($keyFn) { |
|
38 | + return array_reduce($array, function($map, $item) use ($keyFn) { |
|
39 | 39 | $map[$keyFn($item)] = $item; |
40 | 40 | return $map; |
41 | 41 | }, []); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function keyValMap(array $array, callable $keyFn, callable $valFn): array |
51 | 51 | { |
52 | - return array_reduce($array, function ($map, $item) use ($keyFn, $valFn) { |
|
52 | + return array_reduce($array, function($map, $item) use ($keyFn, $valFn) { |
|
53 | 53 | $map[$keyFn($item)] = $valFn($item); |
54 | 54 | return $map; |
55 | 55 | }, []); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | $builtInTypes = keyMap( |
78 | 78 | array_merge(specifiedScalarTypes()/*, introspectionTypes()*/), |
79 | - function (NamedTypeInterface $type) { |
|
79 | + function(NamedTypeInterface $type) { |
|
80 | 80 | return $type->getName(); |
81 | 81 | } |
82 | 82 | ); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | return GraphQLDirective([ |
130 | 130 | 'name' => $node->getNameValue(), |
131 | 131 | 'description' => $node->getDescriptionValue(), |
132 | - 'locations' => array_map(function (NameNode $node) { |
|
132 | + 'locations' => array_map(function(NameNode $node) { |
|
133 | 133 | return $node->getValue(); |
134 | 134 | }, $node->getLocations()), |
135 | 135 | 'arguments' => $node->hasArguments() ? $this->buildArguments($node->getArguments()) : [], |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | { |
175 | 175 | return keyValMap( |
176 | 176 | $nodes, |
177 | - function (InputValueDefinitionNode $value) { |
|
177 | + function(InputValueDefinitionNode $value) { |
|
178 | 178 | return $value->getNameValue(); |
179 | 179 | }, |
180 | - function (InputValueDefinitionNode $value): array { |
|
180 | + function(InputValueDefinitionNode $value): array { |
|
181 | 181 | $type = $this->buildWrappedType($value->getType()); |
182 | 182 | return [ |
183 | 183 | 'type' => $type, |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | return GraphQLObjectType([ |
227 | 227 | 'name' => $node->getNameValue(), |
228 | 228 | 'description' => $node->getDescriptionValue(), |
229 | - 'fields' => function () use ($node) { |
|
229 | + 'fields' => function() use ($node) { |
|
230 | 230 | return $this->buildFields($node); |
231 | 231 | }, |
232 | - 'interfaces' => function () use ($node) { |
|
233 | - return $node->hasInterfaces() ? array_map(function (InterfaceTypeDefinitionNode $interface) { |
|
232 | + 'interfaces' => function() use ($node) { |
|
233 | + return $node->hasInterfaces() ? array_map(function(InterfaceTypeDefinitionNode $interface) { |
|
234 | 234 | return $this->buildType($interface); |
235 | 235 | }, $node->getInterfaces()) : []; |
236 | 236 | }, |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | { |
246 | 246 | return $node->hasFields() ? keyValMap( |
247 | 247 | $node->getFields(), |
248 | - function ($value) { |
|
248 | + function($value) { |
|
249 | 249 | return $value->getNameValue(); |
250 | 250 | }, |
251 | - function ($value) { |
|
251 | + function($value) { |
|
252 | 252 | return $this->buildField($value); |
253 | 253 | } |
254 | 254 | ) : []; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | return GraphQLInterfaceType([ |
264 | 264 | 'name' => $node->getNameValue(), |
265 | 265 | 'description' => $node->getDescriptionValue(), |
266 | - 'fields' => function () use ($node): array { |
|
266 | + 'fields' => function() use ($node): array { |
|
267 | 267 | return $this->buildFields($node); |
268 | 268 | }, |
269 | 269 | 'astNode' => $node, |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | 'description' => $node->getDescriptionValue(), |
282 | 282 | 'values' => $node->hasValues() ? keyValMap( |
283 | 283 | $node->getValues(), |
284 | - function (EnumValueDefinitionNode $value): string { |
|
284 | + function(EnumValueDefinitionNode $value): string { |
|
285 | 285 | return $value->getNameValue(); |
286 | 286 | }, |
287 | - function (EnumValueDefinitionNode $value): array { |
|
287 | + function(EnumValueDefinitionNode $value): array { |
|
288 | 288 | return [ |
289 | 289 | 'description' => $value->getDescriptionValue(), |
290 | 290 | 'deprecationReason' => getDeprecationReason($value), |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | return GraphQLUnionType([ |
302 | 302 | 'name' => $node->getNameValue(), |
303 | 303 | 'description' => $node->getDescriptionValue(), |
304 | - 'types' => $node->hasTypes() ? array_map(function (TypeNodeInterface $type) { |
|
304 | + 'types' => $node->hasTypes() ? array_map(function(TypeNodeInterface $type) { |
|
305 | 305 | return $this->buildType($type); |
306 | 306 | }, $node->getTypes()) : [], |
307 | 307 | 'astNode' => $node, |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | return GraphQLScalarType([ |
318 | 318 | 'name' => $node->getNameValue(), |
319 | 319 | 'description' => $node->getDescriptionValue(), |
320 | - 'serialize' => function ($value) { |
|
320 | + 'serialize' => function($value) { |
|
321 | 321 | return $value; |
322 | 322 | }, |
323 | 323 | 'astNode' => $node, |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | 'description' => $node->getDescriptionValue(), |
336 | 336 | 'fields' => $node->hasFields() ? keyValMap( |
337 | 337 | $node->getFields(), |
338 | - function (InputValueDefinitionNode $value): string { |
|
338 | + function(InputValueDefinitionNode $value): string { |
|
339 | 339 | return $value->getNameValue(); |
340 | 340 | }, |
341 | - function (InputValueDefinitionNode $value): array { |
|
341 | + function(InputValueDefinitionNode $value): array { |
|
342 | 342 | $type = $this->buildWrappedType($value->getType()); |
343 | 343 | return [ |
344 | 344 | 'type' => $type, |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | return $coercedValues; |
36 | 36 | } |
37 | 37 | |
38 | - $argumentNodeMap = keyMap($argumentNodes, function (ArgumentNode $value) { |
|
38 | + $argumentNodeMap = keyMap($argumentNodes, function(ArgumentNode $value) { |
|
39 | 39 | return $value->getNameValue(); |
40 | 40 | }); |
41 | 41 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | function getDirectiveValues(DirectiveInterface $directive, NodeInterface $node, array $variableValues = []): ?array |
106 | 106 | { |
107 | 107 | $directiveNode = $node->hasDirectives() |
108 | - ? find($node->getDirectives(), function (NamedTypeNode $value) use ($directive) { |
|
108 | + ? find($node->getDirectives(), function(NamedTypeNode $value) use ($directive) { |
|
109 | 109 | return $value->getNameValue() === $directive->getName(); |
110 | 110 | }) : null; |
111 | 111 |
@@ -101,7 +101,7 @@ |
||
101 | 101 | $coercedObject = []; |
102 | 102 | |
103 | 103 | /** @var ObjectFieldNode[] $fieldNodes */ |
104 | - $fieldNodes = keyMap($node->getFields(), function (FieldNode $value) { |
|
104 | + $fieldNodes = keyMap($node->getFields(), function(FieldNode $value) { |
|
105 | 105 | return $value->getNameValue(); |
106 | 106 | }); |
107 | 107 |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | */ |
232 | 232 | protected function registerParser() |
233 | 233 | { |
234 | - $this->shared(NodeBuilderInterface::class, function () { |
|
234 | + $this->shared(NodeBuilderInterface::class, function() { |
|
235 | 235 | return new NodeBuilder(self::getNodeBuilders()); |
236 | 236 | }); |
237 | 237 | |
238 | 238 | $this->shared(ParserInterface::class, Parser::class) |
239 | 239 | ->withArgument(NodeBuilderInterface::class); |
240 | 240 | |
241 | - $this->bind(LexerInterface::class, function () { |
|
241 | + $this->bind(LexerInterface::class, function() { |
|
242 | 242 | return new Lexer(self::getSourceReaders()); |
243 | 243 | }); |
244 | 244 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | { |
256 | 256 | $this->shared(DefinitionBuilderInterface::class, DefinitionBuilder::class) |
257 | 257 | ->withArguments([ |
258 | - function (NamedTypeNode $node) { |
|
258 | + function(NamedTypeNode $node) { |
|
259 | 259 | throw new \Exception(sprintf('Type "%s" not found in document.', $node->getNameValue())); |
260 | 260 | }, |
261 | 261 | CacheInterface::class, |
@@ -284,18 +284,18 @@ discard block |
||
284 | 284 | return (bool)$value; |
285 | 285 | } |
286 | 286 | |
287 | - $this->shared('GraphQLBoolean', function () { |
|
287 | + $this->shared('GraphQLBoolean', function() { |
|
288 | 288 | return GraphQLScalarType([ |
289 | 289 | 'name' => TypeNameEnum::BOOLEAN, |
290 | 290 | 'description' => 'The `Boolean` scalar type represents `true` or `false`.', |
291 | - 'serialize' => function ($value) { |
|
291 | + 'serialize' => function($value) { |
|
292 | 292 | return coerceBoolean($value); |
293 | 293 | }, |
294 | - 'parseValue' => function ($value) { |
|
294 | + 'parseValue' => function($value) { |
|
295 | 295 | return coerceBoolean($value); |
296 | 296 | }, |
297 | 297 | |
298 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
298 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
299 | 299 | /** @var BooleanValueNode $astNode */ |
300 | 300 | return $astNode->getKind() === NodeKindEnum::BOOLEAN ? $astNode->getValue() : null; |
301 | 301 | }, |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | throw new \TypeError(sprintf('Float cannot represent non numeric value: %s', $value)); |
321 | 321 | } |
322 | 322 | |
323 | - $this->shared('GraphQLFloat', function () { |
|
323 | + $this->shared('GraphQLFloat', function() { |
|
324 | 324 | return GraphQLScalarType([ |
325 | 325 | 'name' => TypeNameEnum::FLOAT, |
326 | 326 | 'description' => |
327 | 327 | 'The `Float` scalar type represents signed double-precision fractional ' . |
328 | 328 | 'values as specified by ' . |
329 | 329 | '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).', |
330 | - 'serialize' => function ($value) { |
|
330 | + 'serialize' => function($value) { |
|
331 | 331 | return coerceFloat($value); |
332 | 332 | }, |
333 | - 'parseValue' => function ($value) { |
|
333 | + 'parseValue' => function($value) { |
|
334 | 334 | return coerceFloat($value); |
335 | 335 | }, |
336 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
336 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
337 | 337 | /** @var FloatValueNode $astNode */ |
338 | 338 | return in_array($astNode->getKind(), [NodeKindEnum::FLOAT, NodeKindEnum::INT], true) |
339 | 339 | ? $astNode->getValue() |
@@ -371,19 +371,19 @@ discard block |
||
371 | 371 | return $intValue; |
372 | 372 | } |
373 | 373 | |
374 | - $this->shared('GraphQLInt', function () { |
|
374 | + $this->shared('GraphQLInt', function() { |
|
375 | 375 | return GraphQLScalarType([ |
376 | 376 | 'name' => TypeNameEnum::INT, |
377 | 377 | 'description' => |
378 | 378 | 'The `Int` scalar type represents non-fractional signed whole numeric ' . |
379 | 379 | 'values. Int can represent values between -(2^31) and 2^31 - 1.', |
380 | - 'serialize' => function ($value) { |
|
380 | + 'serialize' => function($value) { |
|
381 | 381 | return coerceInt($value); |
382 | 382 | }, |
383 | - 'parseValue' => function ($value) { |
|
383 | + 'parseValue' => function($value) { |
|
384 | 384 | return coerceInt($value); |
385 | 385 | }, |
386 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
386 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
387 | 387 | /** @var IntValueNode $astNode */ |
388 | 388 | return $astNode->getKind() === NodeKindEnum::INT ? $astNode->getValue() : null; |
389 | 389 | }, |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | return (string)$value; |
417 | 417 | } |
418 | 418 | |
419 | - $this->shared('GraphQLID', function () { |
|
419 | + $this->shared('GraphQLID', function() { |
|
420 | 420 | return GraphQLScalarType([ |
421 | 421 | 'name' => TypeNameEnum::ID, |
422 | 422 | 'description' => |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | 'response as a String; however, it is not intended to be human-readable. ' . |
426 | 426 | 'When expected as an input type, any string (such as `"4"`) or integer ' . |
427 | 427 | '(such as `4`) input value will be accepted as an ID.', |
428 | - 'serialize' => function ($value) { |
|
428 | + 'serialize' => function($value) { |
|
429 | 429 | return coerceString($value); |
430 | 430 | }, |
431 | - 'parseValue' => function ($value) { |
|
431 | + 'parseValue' => function($value) { |
|
432 | 432 | return coerceString($value); |
433 | 433 | }, |
434 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
434 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
435 | 435 | /** @var StringValueNode $astNode */ |
436 | 436 | return in_array($astNode->getKind(), [NodeKindEnum::STRING, NodeKindEnum::INT], true) |
437 | 437 | ? $astNode->getValue() |
@@ -440,20 +440,20 @@ discard block |
||
440 | 440 | ]); |
441 | 441 | }); |
442 | 442 | |
443 | - $this->shared('GraphQLString', function () { |
|
443 | + $this->shared('GraphQLString', function() { |
|
444 | 444 | return GraphQLScalarType([ |
445 | 445 | 'name' => TypeNameEnum::STRING, |
446 | 446 | 'description' => |
447 | 447 | 'The `String` scalar type represents textual data, represented as UTF-8 ' . |
448 | 448 | 'character sequences. The String type is most often used by GraphQL to ' . |
449 | 449 | 'represent free-form human-readable text.', |
450 | - 'serialize' => function ($value) { |
|
450 | + 'serialize' => function($value) { |
|
451 | 451 | return coerceString($value); |
452 | 452 | }, |
453 | - 'parseValue' => function ($value) { |
|
453 | + 'parseValue' => function($value) { |
|
454 | 454 | return coerceString($value); |
455 | 455 | }, |
456 | - 'parseLiteral' => function (NodeInterface $astNode) { |
|
456 | + 'parseLiteral' => function(NodeInterface $astNode) { |
|
457 | 457 | /** @var StringValueNode $astNode */ |
458 | 458 | return $astNode->getKind() === NodeKindEnum::STRING ? $astNode->getValue() : null; |
459 | 459 | }, |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | */ |
467 | 467 | protected function registerDirectives() |
468 | 468 | { |
469 | - $this->shared('GraphQLIncludeDirective', function () { |
|
469 | + $this->shared('GraphQLIncludeDirective', function() { |
|
470 | 470 | return GraphQLDirective([ |
471 | 471 | 'name' => 'include', |
472 | 472 | 'description' => |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | ]); |
487 | 487 | }); |
488 | 488 | |
489 | - $this->shared('GraphQLSkipDirective', function () { |
|
489 | + $this->shared('GraphQLSkipDirective', function() { |
|
490 | 490 | return GraphQLDirective([ |
491 | 491 | 'name' => 'skip', |
492 | 492 | 'description' => |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | ]); |
507 | 507 | }); |
508 | 508 | |
509 | - $this->shared('GraphQLDeprecatedDirective', function () { |
|
509 | + $this->shared('GraphQLDeprecatedDirective', function() { |
|
510 | 510 | return GraphQLDirective([ |
511 | 511 | 'name' => 'deprecated', |
512 | 512 | 'description' => 'Marks an element of a GraphQL schema as no longer supported.', |
@@ -59,7 +59,7 @@ |
||
59 | 59 | */ |
60 | 60 | public function getMultiple($keys, $default = null) |
61 | 61 | { |
62 | - return array_filter($this->cache, function ($key) use ($keys) { |
|
62 | + return array_filter($this->cache, function($key) use ($keys) { |
|
63 | 63 | return \in_array($key, $keys, true); |
64 | 64 | }, ARRAY_FILTER_USE_KEY); |
65 | 65 | } |