Completed
Pull Request — master (#129)
by Christoffer
02:14
created
src/Error/GraphQLException.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
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
     }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             ? (!empty($nodes) ? $nodes : [])
192 192
             : (null !== $nodes ? [$nodes] : []);
193 193
 
194
-        $this->nodes = \array_filter($nodes, function ($node) {
194
+        $this->nodes = \array_filter($nodes, function($node) {
195 195
             return null !== $node;
196 196
         });
197 197
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     protected function resolvePositions(?array $positions)
223 223
     {
224 224
         if (null === $positions && !empty($this->nodes)) {
225
-            $positions = array_reduce($this->nodes, function (array $list, ?NodeInterface $node) {
225
+            $positions = array_reduce($this->nodes, function(array $list, ?NodeInterface $node) {
226 226
                 if (null !== $node) {
227 227
                     $location = $node->getLocation();
228 228
                     if (null !== $location) {
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
     protected function resolveLocations(?array $positions, ?Source $source)
251 251
     {
252 252
         if (null !== $positions && null !== $source) {
253
-            $locations = array_map(function ($position) use ($source) {
253
+            $locations = array_map(function($position) use ($source) {
254 254
                 return SourceLocation::fromSource($source, $position);
255 255
             }, $positions);
256 256
         } elseif (!empty($this->nodes)) {
257
-            $locations = array_reduce($this->nodes, function (array $list, NodeInterface $node) {
257
+            $locations = array_reduce($this->nodes, function(array $list, NodeInterface $node) {
258 258
                 $location = $node->getLocation();
259 259
                 if (null !== $location) {
260 260
                     $list[] = SourceLocation::fromSource($location->getSource(), $location->getStart());
Please login to merge, or discard this patch.
src/SchemaValidator/Rule/TypesRule.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             // Assert each interface field arg is implemented.
309 309
             foreach ($interfaceField->getArguments() as $interfaceArgument) {
310 310
                 $argumentName   = $interfaceArgument->getName();
311
-                $objectArgument = find($objectField->getArguments(), function (Argument $argument) use ($argumentName) {
311
+                $objectArgument = find($objectField->getArguments(), function(Argument $argument) use ($argumentName) {
312 312
                     return $argument->getName() === $argumentName;
313 313
                 });
314 314
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                 foreach ($objectFields as $objectArgument) {
367 367
                     $argumentName      = $objectArgument->getName();
368 368
                     $interfaceArgument = find($interfaceField->getArguments(),
369
-                        function (Argument $argument) use ($argumentName) {
369
+                        function(Argument $argument) use ($argumentName) {
370 370
                             return $argument->getName() === $argumentName;
371 371
                         });
372 372
 
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
             return null;
702 702
         }
703 703
 
704
-        return \array_filter($node->getTypes(), function (NamedTypeNode $type) use ($memberTypeName) {
704
+        return \array_filter($node->getTypes(), function(NamedTypeNode $type) use ($memberTypeName) {
705 705
             return $type->getNameValue() === $memberTypeName;
706 706
         });
707 707
     }
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
             return null;
721 721
         }
722 722
 
723
-        return \array_filter($node->getValues(), function (NameAwareInterface $type) use ($valueName) {
723
+        return \array_filter($node->getValues(), function(NameAwareInterface $type) use ($valueName) {
724 724
             return $type->getNameValue() === $valueName;
725 725
         });
726 726
     }
Please login to merge, or discard this patch.
src/SchemaBuilder/SchemaBuilder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,27 +78,27 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/Execution/ValuesResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             return $coercedValues;
63 63
         }
64 64
 
65
-        $argumentNodeMap = keyMap($argumentNodes, function (ArgumentNode $value) {
65
+        $argumentNodeMap = keyMap($argumentNodes, function(ArgumentNode $value) {
66 66
             return $value->getNameValue();
67 67
         });
68 68
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         array $variableValues = []
134 134
     ): ?array {
135 135
         $directiveNode = $node->hasDirectives()
136
-            ? find($node->getDirectives(), function (NameAwareInterface $value) use ($directive) {
136
+            ? find($node->getDirectives(), function(NameAwareInterface $value) use ($directive) {
137 137
                 return $value->getNameValue() === $directive->getName();
138 138
             }) : null;
139 139
 
Please login to merge, or discard this patch.
src/SchemaBuilder/DefinitionBuilder.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
         $builtInTypes = keyMap(
99 99
             \array_merge(specifiedScalarTypes(), introspectionTypes()),
100
-            function (NamedTypeInterface $type) {
100
+            function(NamedTypeInterface $type) {
101 101
                 return $type->getName();
102 102
             }
103 103
         );
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         return GraphQLDirective([
160 160
             'name'        => $node->getNameValue(),
161 161
             'description' => $node->getDescriptionValue(),
162
-            'locations'   => \array_map(function (NameNode $node) {
162
+            'locations'   => \array_map(function(NameNode $node) {
163 163
                 return $node->getValue();
164 164
             }, $node->getLocations()),
165 165
             'arguments'   => $node->hasArguments() ? $this->buildArguments($node->getArguments()) : [],
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
     {
209 209
         return keyValMap(
210 210
             $nodes,
211
-            function (InputValueDefinitionNode $value) {
211
+            function(InputValueDefinitionNode $value) {
212 212
                 return $value->getNameValue();
213 213
             },
214
-            function (InputValueDefinitionNode $value): array {
214
+            function(InputValueDefinitionNode $value): array {
215 215
                 $type         = $this->buildWrappedType($value->getType());
216 216
                 $defaultValue = $value->getDefaultValue();
217 217
                 return [
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
         return GraphQLObjectType([
264 264
             'name'        => $node->getNameValue(),
265 265
             'description' => $node->getDescriptionValue(),
266
-            'fields'      => function () use ($node) {
266
+            'fields'      => function() use ($node) {
267 267
                 return $this->buildFields($node);
268 268
             },
269
-            'interfaces'  => function () use ($node) {
270
-                return $node->hasInterfaces() ? \array_map(function (NodeInterface $interface) {
269
+            'interfaces'  => function() use ($node) {
270
+                return $node->hasInterfaces() ? \array_map(function(NodeInterface $interface) {
271 271
                     return $this->buildType($interface);
272 272
                 }, $node->getInterfaces()) : [];
273 273
             },
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 
285 285
         return $node->hasFields() ? keyValMap(
286 286
             $node->getFields(),
287
-            function ($value) {
287
+            function($value) {
288 288
                 /** @noinspection PhpUndefinedMethodInspection */
289 289
                 return $value->getNameValue();
290 290
             },
291
-            function ($value) use ($resolverMap) {
291
+            function($value) use ($resolverMap) {
292 292
                 return $this->buildField($value, $resolverMap);
293 293
             }
294 294
         ) : [];
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
         return GraphQLInterfaceType([
304 304
             'name'        => $node->getNameValue(),
305 305
             'description' => $node->getDescriptionValue(),
306
-            'fields'      => function () use ($node): array {
306
+            'fields'      => function() use ($node): array {
307 307
                 return $this->buildFields($node);
308 308
             },
309 309
             'astNode'     => $node,
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
             'description' => $node->getDescriptionValue(),
322 322
             'values'      => $node->hasValues() ? keyValMap(
323 323
                 $node->getValues(),
324
-                function (EnumValueDefinitionNode $value): string {
324
+                function(EnumValueDefinitionNode $value): string {
325 325
                     return $value->getNameValue();
326 326
                 },
327
-                function (EnumValueDefinitionNode $value): array {
327
+                function(EnumValueDefinitionNode $value): array {
328 328
                     return [
329 329
                         'description'       => $value->getDescriptionValue(),
330 330
                         'deprecationReason' => $this->getDeprecationReason($value),
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         return GraphQLUnionType([
346 346
             'name'        => $node->getNameValue(),
347 347
             'description' => $node->getDescriptionValue(),
348
-            'types'       => $node->hasTypes() ? \array_map(function (TypeNodeInterface $type) {
348
+            'types'       => $node->hasTypes() ? \array_map(function(TypeNodeInterface $type) {
349 349
                 return $this->buildType($type);
350 350
             }, $node->getTypes()) : [],
351 351
             'astNode'     => $node,
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
         return GraphQLScalarType([
362 362
             'name'        => $node->getNameValue(),
363 363
             'description' => $node->getDescriptionValue(),
364
-            'serialize'   => function ($value) {
364
+            'serialize'   => function($value) {
365 365
                 return $value;
366 366
             },
367 367
             'astNode'     => $node,
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
         return GraphQLInputObjectType([
378 378
             'name'        => $node->getNameValue(),
379 379
             'description' => $node->getDescriptionValue(),
380
-            'fields'      => $node->hasFields() ? function () use ($node) {
380
+            'fields'      => $node->hasFields() ? function() use ($node) {
381 381
                 return keyValMap(
382 382
                     $node->getFields(),
383
-                    function (InputValueDefinitionNode $value): string {
383
+                    function(InputValueDefinitionNode $value): string {
384 384
                         return $value->getNameValue();
385 385
                     },
386
-                    function (InputValueDefinitionNode $value): array {
386
+                    function(InputValueDefinitionNode $value): array {
387 387
                         $type = $this->buildWrappedType($value->getType());
388 388
                         return [
389 389
                             'type'         => $type,
Please login to merge, or discard this patch.
src/Type/ScalarTypesProvider.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function register()
35 35
     {
36
-        $this->container->add(GraphQL::BOOLEAN, function () {
36
+        $this->container->add(GraphQL::BOOLEAN, function() {
37 37
             return GraphQLScalarType([
38 38
                 'name'        => TypeNameEnum::BOOLEAN,
39 39
                 'description' => 'The `Boolean` scalar type represents `true` or `false`.',
40
-                'serialize'   => function ($value) {
40
+                'serialize'   => function($value) {
41 41
                     return coerceBoolean($value);
42 42
                 },
43
-                'parseValue'  => function ($value) {
43
+                'parseValue'  => function($value) {
44 44
                     return coerceBoolean($value);
45 45
                 },
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
                     }
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
             ]);
54 54
         }, true/* $shared */);
55 55
 
56
-        $this->container->add(GraphQL::FLOAT, function () {
56
+        $this->container->add(GraphQL::FLOAT, function() {
57 57
             return GraphQLScalarType([
58 58
                 'name'         => TypeNameEnum::FLOAT,
59 59
                 'description'  =>
60 60
                     'The `Float` scalar type represents signed double-precision fractional ' .
61 61
                     'values as specified by ' .
62 62
                     '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).',
63
-                'serialize'    => function ($value) {
63
+                'serialize'    => function($value) {
64 64
                     return coerceFloat($value);
65 65
                 },
66
-                'parseValue'   => function ($value) {
66
+                'parseValue'   => function($value) {
67 67
                     return coerceFloat($value);
68 68
                 },
69
-                'parseLiteral' => function (NodeInterface $node) {
69
+                'parseLiteral' => function(NodeInterface $node) {
70 70
                     if ($node instanceof FloatValueNode || $node instanceof IntValueNode) {
71 71
                         return $node->getValue();
72 72
                     }
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
             ]);
76 76
         }, true/* $shared */);
77 77
 
78
-        $this->container->add(GraphQL::INT, function () {
78
+        $this->container->add(GraphQL::INT, function() {
79 79
             return GraphQLScalarType([
80 80
                 'name'         => TypeNameEnum::INT,
81 81
                 'description'  =>
82 82
                     'The `Int` scalar type represents non-fractional signed whole numeric ' .
83 83
                     'values. Int can represent values between -(2^31) and 2^31 - 1.',
84
-                'serialize'    => function ($value) {
84
+                'serialize'    => function($value) {
85 85
                     return coerceInt($value);
86 86
                 },
87
-                'parseValue'   => function ($value) {
87
+                'parseValue'   => function($value) {
88 88
                     return coerceInt($value);
89 89
                 },
90
-                'parseLiteral' => function (NodeInterface $node) {
90
+                'parseLiteral' => function(NodeInterface $node) {
91 91
                     if ($node instanceof IntValueNode) {
92 92
                         $value = (int)$node->getValue();
93 93
                         if ((string)$node->getValue() === (string)$value &&
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             ]);
101 101
         }, true/* $shared */);
102 102
 
103
-        $this->container->add(GraphQL::ID, function () {
103
+        $this->container->add(GraphQL::ID, function() {
104 104
             return GraphQLScalarType([
105 105
                 'name'         => TypeNameEnum::ID,
106 106
                 'description'  =>
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
                     'response as a String; however, it is not intended to be human-readable. ' .
110 110
                     'When expected as an input type, any string (such as `"4"`) or integer ' .
111 111
                     '(such as `4`) input value will be accepted as an ID.',
112
-                'serialize'    => function ($value) {
112
+                'serialize'    => function($value) {
113 113
                     return coerceString($value);
114 114
                 },
115
-                'parseValue'   => function ($value) {
115
+                'parseValue'   => function($value) {
116 116
                     return coerceString($value);
117 117
                 },
118
-                'parseLiteral' => function (NodeInterface $node) {
118
+                'parseLiteral' => function(NodeInterface $node) {
119 119
                     if ($node instanceof StringValueNode || $node instanceof IntValueNode) {
120 120
                         return $node->getValue();
121 121
                     }
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
             ]);
125 125
         }, true/* $shared */);
126 126
 
127
-        $this->container->add(GraphQL::STRING, function () {
127
+        $this->container->add(GraphQL::STRING, function() {
128 128
             return GraphQLScalarType([
129 129
                 'name'         => TypeNameEnum::STRING,
130 130
                 'description'  =>
131 131
                     'The `String` scalar type represents textual data, represented as UTF-8 ' .
132 132
                     'character sequences. The String type is most often used by GraphQL to ' .
133 133
                     'represent free-form human-readable text.',
134
-                'serialize'    => function ($value) {
134
+                'serialize'    => function($value) {
135 135
                     return coerceString($value);
136 136
                 },
137
-                'parseValue'   => function ($value) {
137
+                'parseValue'   => function($value) {
138 138
                     return coerceString($value);
139 139
                 },
140
-                'parseLiteral' => function (NodeInterface $node) {
140
+                'parseLiteral' => function(NodeInterface $node) {
141 141
                     if ($node instanceof StringValueNode) {
142 142
                         return $node->getValue();
143 143
                     }
Please login to merge, or discard this patch.
src/Util/ValueNodeCoercer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@
 block discarded – undo
168 168
         $coercedValues = [];
169 169
 
170 170
         /** @var ObjectFieldNode[] $fieldNodes */
171
-        $fieldNodes = keyMap($node->getFields(), function (ObjectFieldNode $value) {
171
+        $fieldNodes = keyMap($node->getFields(), function(ObjectFieldNode $value) {
172 172
             return $value->getNameValue();
173 173
         });
174 174
 
Please login to merge, or discard this patch.