Passed
Pull Request — master (#351)
by Kirill
02:55
created
src/Schema/utils.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/api.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
     $data = null;
157 157
 
158
-    $resultPromise->then(function (ExecutionResult $result) use (&$data) {
158
+    $resultPromise->then(function(ExecutionResult $result) use (&$data) {
159 159
         $data = $result;
160 160
     });
161 161
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 
251 251
     $data = null;
252 252
 
253
-    $resultPromise->then(function (ExecutionResult $result) use (&$data) {
253
+    $resultPromise->then(function(ExecutionResult $result) use (&$data) {
254 254
         $data = $result;
255 255
     });
256 256
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $errorHandler
302 302
     );
303 303
 
304
-    return $resultPromise->then(function (ExecutionResult $result) {
304
+    return $resultPromise->then(function(ExecutionResult $result) {
305 305
         return $result->toArray();
306 306
     });
307 307
 }
Please login to merge, or discard this patch.
src/Validation/Rule/ProvidedRequiredArgumentsRule.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         }
35 35
 
36 36
         $argumentNodes   = $node->getArguments();
37
-        $argumentNodeMap = keyMap($argumentNodes, function (ArgumentNode $argument) {
37
+        $argumentNodeMap = keyMap($argumentNodes, function(ArgumentNode $argument) {
38 38
             return $argument->getNameValue();
39 39
         });
40 40
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         }
72 72
 
73 73
         $argumentNodes   = $node->getArguments();
74
-        $argumentNodeMap = keyMap($argumentNodes, function (ArgumentNode $argument) {
74
+        $argumentNodeMap = keyMap($argumentNodes, function(ArgumentNode $argument) {
75 75
             return $argument->getNameValue();
76 76
         });
77 77
 
Please login to merge, or discard this patch.
src/Execution/Execution.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $data = $this->executeOperation($operationName, $context, $fieldCollector);
54 54
 
55 55
         if ($data instanceof PromiseInterface) {
56
-            return $data->then(function ($resolvedData) use ($context) {
56
+            return $data->then(function($resolvedData) use ($context) {
57 57
                 return new ExecutionResult($resolvedData, $context->getErrors());
58 58
             });
59 59
         }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         }
96 96
 
97 97
         if ($result instanceof PromiseInterface) {
98
-            return $result->then(null, function (ExecutionException $exception) use ($context) {
98
+            return $result->then(null, function(ExecutionException $exception) use ($context) {
99 99
                 $context->addError($exception);
100 100
                 return resolve(null);
101 101
             });
Please login to merge, or discard this patch.
src/Execution/ValuesResolver.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         }
63 63
 
64 64
         /** @var ArgumentNode[] $argumentNodeMap */
65
-        $argumentNodeMap = keyMap($argumentNodes, function (ArgumentNode $value) {
65
+        $argumentNodeMap = keyMap($argumentNodes, function(ArgumentNode $value) {
66 66
             return $value->getNameValue();
67 67
         });
68 68
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         array $variableValues = []
185 185
     ): ?array {
186 186
         $directiveNode = $node->hasDirectives()
187
-            ? find($node->getDirectives(), function (NameAwareInterface $value) use ($directive) {
187
+            ? find($node->getDirectives(), function(NameAwareInterface $value) use ($directive) {
188 188
                 return $value->getNameValue() === $directive->getName();
189 189
             }) : null;
190 190
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
                 ]);
402 402
             }
403 403
             return new CoercedValue($parseResult);
404
-        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (InvalidTypeException|CoercingException $ex) {
404
+        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (InvalidTypeException | CoercingException $ex) {
405 405
             return new CoercedValue(null, [
406 406
                 static::buildCoerceException(
407 407
                     \sprintf('Expected type %s', (string)$type),
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
             return new CoercedValue($enumValue);
433 433
         }
434 434
 
435
-        $suggestions = suggestionList((string)$value, \array_map(function (EnumValue $enumValue) {
435
+        $suggestions = suggestionList((string)$value, \array_map(function(EnumValue $enumValue) {
436 436
             return $enumValue->getName();
437 437
         }, $type->getValues()));
438 438
 
Please login to merge, or discard this patch.
src/Type/IntrospectionProvider.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
133 133
                             ],
134 134
                             'args'        => [
135 135
                                 'type'    => newNonNull(newList(newNonNull(__InputValue()))),
136
-                                'resolve' => static function (Directive $directive): iterable {
136
+                                'resolve' => static function(Directive $directive): iterable {
137 137
                                     return $directive->getArguments() ?: [];
138 138
                                 },
139 139
                             ],
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                 ]);
Please login to merge, or discard this patch.
src/Schema/Schema.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function getDirective(string $name): ?DirectiveInterface
170 170
     {
171
-        return find($this->directives, static function (Directive $directive) use ($name) {
171
+        return find($this->directives, static function(Directive $directive) use ($name) {
172 172
             return $directive->getName() === $name;
173 173
         });
174 174
     }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
             $this->possibleTypesMap[$abstractTypeName] = \array_reduce(
226 226
                 $possibleTypes,
227
-                static function (array $map, NamedTypeInterface $type) {
227
+                static function(array $map, NamedTypeInterface $type) {
228 228
                     $map[$type->getName()] = true;
229 229
 
230 230
                     return $map;
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
             if ($type instanceof ObjectType || $type instanceof InterfaceType) {
365 365
                 foreach ($type->getFields() as $field) {
366 366
                     if ($field->hasArguments()) {
367
-                        $fieldArgTypes = \array_map(function (Argument $argument) {
367
+                        $fieldArgTypes = \array_map(function(Argument $argument) {
368 368
                             return $argument->getNullableType();
369 369
                         }, $field->getArguments());
370 370
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
             return $map;
399 399
         }
400 400
 
401
-        return \array_reduce($directive->getArguments(), function ($map, Argument $argument) {
401
+        return \array_reduce($directive->getArguments(), function($map, Argument $argument) {
402 402
             return $this->typeMapReducer($map, $argument->getNullableType());
403 403
         }, $map);
404 404
     }
Please login to merge, or discard this patch.