Passed
Pull Request — master (#190)
by Sebastian
03:03
created
src/Util/helpers.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
  * @return bool
50 50
  */
51 51
 function isTypeSubtypeOf(
52
-  SchemaInterface $schema,
53
-  TypeInterface $maybeSubtype,
54
-  TypeInterface $superType
52
+    SchemaInterface $schema,
53
+    TypeInterface $maybeSubtype,
54
+    TypeInterface $superType
55 55
 ): bool {
56 56
     return GraphQL::make(TypeHelper::class)
57
-      ->isTypeSubtypeOf($schema, $maybeSubtype, $superType);
57
+        ->isTypeSubtypeOf($schema, $maybeSubtype, $superType);
58 58
 }
59 59
 
60 60
 /**
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
  * @return bool
66 66
  */
67 67
 function doTypesOverlap(
68
-  SchemaInterface $schema,
69
-  TypeInterface $typeA,
70
-  TypeInterface $typeB
68
+    SchemaInterface $schema,
69
+    TypeInterface $typeA,
70
+    TypeInterface $typeB
71 71
 ): bool {
72 72
     return GraphQL::make(TypeHelper::class)
73
-      ->doTypesOverlap($schema, $typeA, $typeB);
73
+        ->doTypesOverlap($schema, $typeA, $typeB);
74 74
 }
75 75
 
76 76
 /**
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
  * @return TypeInterface|null
81 81
  */
82 82
 function typeFromAST(
83
-  SchemaInterface $schema,
84
-  TypeNodeInterface $typeNode
83
+    SchemaInterface $schema,
84
+    TypeNodeInterface $typeNode
85 85
 ): ?TypeInterface
86 86
 {
87 87
     return GraphQL::make(TypeHelper::class)->fromAST($schema, $typeNode);
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
  */
97 97
 function valueFromAST(
98 98
   ?NodeInterface $node,
99
-  TypeInterface $type,
100
-  array $variables = []
99
+    TypeInterface $type,
100
+    array $variables = []
101 101
 ) {
102 102
     return GraphQL::make(ValueHelper::class)->fromAST($node, $type, $variables);
103 103
 }
Please login to merge, or discard this patch.
src/Util/UtilityProvider.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
      * @var array
12 12
      */
13 13
     protected $provides = [
14
-      NameHelper::class,
15
-      TypeHelper::class,
16
-      ValueHelper::class,
14
+        NameHelper::class,
15
+        TypeHelper::class,
16
+        ValueHelper::class,
17 17
     ];
18 18
 
19 19
     /**
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
     public function register()
23 23
     {
24 24
         $this->container->add(NameHelper::class, NameHelper::class,
25
-          true/* $shared */);
25
+            true/* $shared */);
26 26
         $this->container->add(TypeHelper::class, TypeHelper::class,
27
-          true/* $shared */);
27
+            true/* $shared */);
28 28
         $this->container->add(ValueHelper::class, ValueHelper::class,
29
-          true/* $shared */);
29
+            true/* $shared */);
30 30
     }
31 31
 }
Please login to merge, or discard this patch.
src/Util/utils.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
     return $count === 1
39 39
       ? $selected[0]
40 40
       : \array_reduce($selected, function ($list, $item) use ($count, &$index) {
41
-          $list .= ($index > 0 && $index < ($count - 1) ? ', ' : '') . ($index === ($count - 1) ? ' or ' : '') .
41
+            $list .= ($index > 0 && $index < ($count - 1) ? ', ' : '') . ($index === ($count - 1) ? ' or ' : '') .
42 42
             $item;
43
-          $index++;
44
-          return $list;
45
-      }, '');
43
+            $index++;
44
+            return $list;
45
+        }, '');
46 46
 }
47 47
 
48 48
 /**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     for ($i = 0; $i < $oLength; $i++) {
65 65
         // Comparison must be case-insenstive.
66 66
         $distance = \levenshtein(\strtolower($input),
67
-          \strtolower($options[$i]));
67
+            \strtolower($options[$i]));
68 68
         $threshold = \max($inputThreshold, \strlen($options[$i]) / 2, 1);
69 69
         if ($distance <= $threshold) {
70 70
             $optionsByDistance[$options[$i]] = $distance;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     return $count === 1
39 39
       ? $selected[0]
40
-      : \array_reduce($selected, function ($list, $item) use ($count, &$index) {
40
+      : \array_reduce($selected, function($list, $item) use ($count, &$index) {
41 41
           $list .= ($index > 0 && $index < ($count - 1) ? ', ' : '') . ($index === ($count - 1) ? ' or ' : '') .
42 42
             $item;
43 43
           $index++;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
     $result = \array_keys($optionsByDistance);
75 75
 
76
-    \usort($result, function ($a, $b) use ($optionsByDistance) {
76
+    \usort($result, function($a, $b) use ($optionsByDistance) {
77 77
         return $optionsByDistance[$a] - $optionsByDistance[$b];
78 78
     });
79 79
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
  */
90 90
 function quotedOrList(array $items): string
91 91
 {
92
-    return orList(array_map(function ($item) {
92
+    return orList(array_map(function($item) {
93 93
         return '"' . $item . '"';
94 94
     }, $items));
95 95
 }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
  */
104 104
 function arrayEvery(array $array, callable $fn): bool
105 105
 {
106
-    return array_reduce($array, function ($result, $value) use ($fn) {
106
+    return array_reduce($array, function($result, $value) use ($fn) {
107 107
         return $result && $fn($value);
108 108
     }, true);
109 109
 }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
  */
117 117
 function arraySome(array $array, callable $fn)
118 118
 {
119
-    return array_reduce($array, function ($result, $value) use ($fn) {
119
+    return array_reduce($array, function($result, $value) use ($fn) {
120 120
         return $result || $fn($value);
121 121
     });
122 122
 }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
  */
147 147
 function keyMap(array $array, callable $keyFn): array
148 148
 {
149
-    return array_reduce($array, function ($map, $item) use ($keyFn) {
149
+    return array_reduce($array, function($map, $item) use ($keyFn) {
150 150
         $map[$keyFn($item)] = $item;
151 151
         return $map;
152 152
     }, []);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
  */
162 162
 function keyValueMap(array $array, callable $keyFn, callable $valFn): array
163 163
 {
164
-    return array_reduce($array, function ($map, $item) use ($keyFn, $valFn) {
164
+    return array_reduce($array, function($map, $item) use ($keyFn, $valFn) {
165 165
         $map[$keyFn($item)] = $valFn($item);
166 166
         return $map;
167 167
     }, []);
Please login to merge, or discard this patch.
src/Execution/ExecutionContext.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
      * @param array $errors
64 64
      */
65 65
     public function __construct(
66
-      Schema $schema,
67
-      array $fragments,
68
-      $rootValue,
69
-      $contextValue,
70
-      $variableValues,
71
-      $fieldResolver,
72
-      OperationDefinitionNode $operation,
73
-      array $errors
66
+        Schema $schema,
67
+        array $fragments,
68
+        $rootValue,
69
+        $contextValue,
70
+        $variableValues,
71
+        $fieldResolver,
72
+        OperationDefinitionNode $operation,
73
+        array $errors
74 74
     ) {
75 75
         $this->schema = $schema;
76 76
         $this->fragments = $fragments;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     {
193 193
         //We can probably return different strategy in the future e.g:AsyncExecutionStrategy
194 194
         return new ExecutorExecutionStrategy($this, $this->operation,
195
-          $this->rootValue);
195
+            $this->rootValue);
196 196
     }
197 197
 
198 198
     /**
Please login to merge, or discard this patch.
src/Execution/ExecutionContextBuilder.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
      * @throws \Exception
31 31
      */
32 32
     public function buildContext(
33
-      Schema $schema,
34
-      DocumentNode $documentNode,
35
-      $rootValue,
36
-      $contextValue,
37
-      $rawVariableValues,
38
-      $operationName = null,
39
-      callable $fieldResolver = null
33
+        Schema $schema,
34
+        DocumentNode $documentNode,
35
+        $rootValue,
36
+        $contextValue,
37
+        $rawVariableValues,
38
+        $operationName = null,
39
+        callable $fieldResolver = null
40 40
     ): ExecutionContext {
41 41
         //@TODO validate $rawVariableValues?
42 42
 
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
                 case NodeKindEnum::OPERATION_DEFINITION:
50 50
                     if (!$operationName && $operation) {
51 51
                         throw new ExecutionException(
52
-                          'Must provide operation name if query contains multiple operations.'
52
+                            'Must provide operation name if query contains multiple operations.'
53 53
                         );
54 54
                     }
55 55
 
56 56
                     if (!$operationName || (!empty($definition->getName()) && $definition->getName()
57
-                          ->getValue() === $operationName)) {
57
+                            ->getValue() === $operationName)) {
58 58
                         $operation = $definition;
59 59
                     }
60 60
                     break;
61 61
                 case NodeKindEnum::FRAGMENT_DEFINITION:
62 62
                 case NodeKindEnum::FRAGMENT_SPREAD:
63 63
                     $fragments[$definition->getName()
64
-                      ->getValue()] = $definition;
64
+                        ->getValue()] = $definition;
65 65
                     break;
66 66
             }
67 67
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         if (null === $operation) {
70 70
             if ($operationName !== null) {
71 71
                 throw new ExecutionException(sprintf('Unknown operation named "%s".',
72
-                  $operationName));
72
+                    $operationName));
73 73
             }
74 74
 
75 75
             throw new ExecutionException('Must provide an operation.');
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         /** @var OperationDefinitionNode $operation */
81 81
         if ($operation) {
82 82
             $coercedVariableValues = coerceVariableValues(
83
-              $schema,
84
-              $operation->getVariableDefinitions(),
85
-              $rawVariableValues
83
+                $schema,
84
+                $operation->getVariableDefinitions(),
85
+                $rawVariableValues
86 86
             );
87 87
 
88 88
             $variableValues = $coercedVariableValues->getValue();
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
         }
94 94
 
95 95
         $executionContext = new ExecutionContext(
96
-          $schema,
97
-          $fragments,
98
-          $rootValue,
99
-          $contextValue,
100
-          $variableValues,
101
-          $fieldResolver,
102
-          $operation,
103
-          $errors
96
+            $schema,
97
+            $fragments,
98
+            $rootValue,
99
+            $contextValue,
100
+            $variableValues,
101
+            $fieldResolver,
102
+            $operation,
103
+            $errors
104 104
         );
105 105
 
106 106
         return $executionContext;
Please login to merge, or discard this patch.
src/Execution/ValuesHelper.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
      * @throws InvariantException
51 51
      */
52 52
     public function coerceDirectiveValues(
53
-      Directive $directive,
54
-      $node,
55
-      array $variableValues = []
53
+        Directive $directive,
54
+        $node,
55
+        array $variableValues = []
56 56
     ): ?array
57 57
     {
58 58
         $directiveNode = $node->hasDirectives()
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
         if (null !== $directiveNode) {
65 65
             return $this->coerceArgumentValues($directive, $directiveNode,
66
-              $variableValues);
66
+                $variableValues);
67 67
         }
68 68
 
69 69
         return null;
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      * @throws InvariantException
86 86
      */
87 87
     public function coerceArgumentValues(
88
-      $definition,
89
-      ArgumentsAwareInterface $node,
90
-      array $variableValues = []
88
+        $definition,
89
+        ArgumentsAwareInterface $node,
90
+        array $variableValues = []
91 91
     ): array {
92 92
         $coercedValues = [];
93 93
         $argumentDefinitions = $definition->getArguments();
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
         }
99 99
 
100 100
         $argumentNodeMap = keyMap($argumentNodes,
101
-          function (ArgumentNode $value) {
102
-              return $value->getNameValue();
103
-          });
101
+            function (ArgumentNode $value) {
102
+                return $value->getNameValue();
103
+            });
104 104
 
105 105
         foreach ($argumentDefinitions as $argumentDefinition) {
106 106
             $argumentName = $argumentDefinition->getName();
@@ -114,36 +114,36 @@  discard block
 block discarded – undo
114 114
                     $coercedValues[$argumentName] = $defaultValue;
115 115
                 } elseif ($argumentType instanceof NonNullType) {
116 116
                     throw new ExecutionException(
117
-                      sprintf('Argument "%s" of required type "%s" was not provided.',
117
+                        sprintf('Argument "%s" of required type "%s" was not provided.',
118 118
                         $argumentName,
119 119
                         $argumentType),
120
-                      [$node]
120
+                        [$node]
121 121
                     );
122 122
                 }
123 123
             } elseif ($argumentNode->getValue() instanceof VariableNode) {
124 124
                 $coercedValues[$argumentName] = $this->coerceValueForVariableNode(
125
-                  $argumentNode->getValue(),
126
-                  $argumentType,
127
-                  $argumentName,
128
-                  $variableValues,
129
-                  $defaultValue
125
+                    $argumentNode->getValue(),
126
+                    $argumentType,
127
+                    $argumentName,
128
+                    $variableValues,
129
+                    $defaultValue
130 130
                 );
131 131
             } else {
132 132
                 $coercedValue = null;
133 133
 
134 134
                 try {
135 135
                     $coercedValue = valueFromAST($argumentNode->getValue(),
136
-                      $argumentType, $variableValues);
136
+                        $argumentType, $variableValues);
137 137
                 } catch (\Exception $ex) {
138 138
                     // Value nodes that cannot be resolved should be treated as invalid values
139 139
                     // because there is no undefined value in PHP so that we throw an exception
140 140
 
141 141
                     throw new ExecutionException(
142
-                      sprintf('Argument "%s" has invalid value %s.',
142
+                        sprintf('Argument "%s" has invalid value %s.',
143 143
                         $argumentName,
144 144
                         (string)$argumentNode->getValue()),
145
-                      [$argumentNode->getValue()],
146
-                      null, null, null, $ex
145
+                        [$argumentNode->getValue()],
146
+                        null, null, null, $ex
147 147
                     );
148 148
                 }
149 149
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
      * @throws ExecutionException
166 166
      */
167 167
     protected function coerceValueForVariableNode(
168
-      VariableNode $variableNode,
169
-      TypeInterface $argumentType,
170
-      string $argumentName,
171
-      array $variableValues,
172
-      $defaultValue
168
+        VariableNode $variableNode,
169
+        TypeInterface $argumentType,
170
+        string $argumentName,
171
+        array $variableValues,
172
+        $defaultValue
173 173
     ) {
174 174
         $variableName = $variableNode->getNameValue();
175 175
 
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
 
187 187
         if ($argumentType instanceof NonNullType) {
188 188
             throw new ExecutionException(
189
-              \sprintf(
189
+                \sprintf(
190 190
                 'Argument "%s" of required type "%s" was provided the variable "$%s" which was not provided a runtime value.',
191 191
                 $argumentName,
192 192
                 $argumentType,
193 193
                 $variableName
194
-              ),
195
-              [$variableNode]
194
+                ),
195
+                [$variableNode]
196 196
             );
197 197
         }
198 198
     }
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
      * @throws \Exception
211 211
      */
212 212
     public function coerceVariableValues(
213
-      Schema $schema,
214
-      array $variableDefinitionNodes,
215
-      array $inputs
213
+        Schema $schema,
214
+        array $variableDefinitionNodes,
215
+        array $inputs
216 216
     ): CoercedValue {
217 217
         $coercedValues = [];
218 218
         $errors = [];
219 219
 
220 220
         foreach ($variableDefinitionNodes as $variableDefinitionNode) {
221 221
             $variableName = $variableDefinitionNode->getVariable()
222
-              ->getNameValue();
222
+                ->getNameValue();
223 223
             $variableType = typeFromAST($schema,
224
-              $variableDefinitionNode->getType());
224
+                $variableDefinitionNode->getType());
225 225
 
226 226
             if (!$this->isInputType($variableType)) {
227 227
                 $variableTypeName = (string)$variableType;
@@ -231,48 +231,48 @@  discard block
 block discarded – undo
231 231
                 }
232 232
 
233 233
                 $errors[] = $this->buildCoerceException(
234
-                  sprintf(
234
+                    sprintf(
235 235
                     'Variable "$%s" expected value of type "%s" which cannot be used as an input type',
236 236
                     $variableName,
237 237
                     $variableTypeName
238
-                  ),
239
-                  $variableDefinitionNode,
240
-                  null
238
+                    ),
239
+                    $variableDefinitionNode,
240
+                    null
241 241
                 );
242 242
             } else {
243 243
                 if (!array_key_exists($variableName, $inputs)) {
244 244
                     if ($variableType instanceof NonNullType) {
245 245
                         $errors[] = $this->buildCoerceException(
246
-                          sprintf(
246
+                            sprintf(
247 247
                             'Variable "$%s" of required type "%s" was not provided',
248 248
                             $variableName,
249 249
                             (string)$variableType
250
-                          ),
251
-                          $variableDefinitionNode,
252
-                          null
250
+                            ),
251
+                            $variableDefinitionNode,
252
+                            null
253 253
                         );
254 254
                     } elseif ($variableDefinitionNode->getDefaultValue() !== null) {
255 255
                         $coercedValues[$variableName] = valueFromAST(
256
-                          $variableDefinitionNode->getDefaultValue(),
257
-                          $variableType
256
+                            $variableDefinitionNode->getDefaultValue(),
257
+                            $variableType
258 258
                         );
259 259
                     }
260 260
                 } else {
261 261
                     $value = $inputs[$variableName];
262 262
                     $coercedValue = $this->coerceValue($value, $variableType,
263
-                      $variableDefinitionNode);
263
+                        $variableDefinitionNode);
264 264
                     if ($coercedValue->hasErrors()) {
265 265
                         $messagePrelude = sprintf(
266
-                          'Variable "$%s" got invalid value %s',
267
-                          $variableName, json_encode($value)
266
+                            'Variable "$%s" got invalid value %s',
267
+                            $variableName, json_encode($value)
268 268
                         );
269 269
                         foreach ($coercedValue->getErrors() as $error) {
270 270
                             $errors[] = $this->buildCoerceException(
271
-                              $messagePrelude,
272
-                              $variableDefinitionNode,
273
-                              null,
274
-                              $error->getMessage(),
275
-                              $error
271
+                                $messagePrelude,
272
+                                $variableDefinitionNode,
273
+                                null,
274
+                                $error->getMessage(),
275
+                                $error
276 276
                             );
277 277
                         }
278 278
                     } else {
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
      * @return GraphQLException
309 309
      */
310 310
     protected function buildCoerceException(
311
-      string $message,
312
-      NodeInterface $blameNode,
311
+        string $message,
312
+        NodeInterface $blameNode,
313 313
       ?Path $path,
314 314
       ?string $subMessage = null,
315 315
       ?GraphQLException $originalException = null
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
         $stringPath = $this->printPath($path);
318 318
 
319 319
         return new CoercingException(
320
-          $message .
321
-          (($stringPath !== '') ? ' at ' . $stringPath : $stringPath) .
322
-          (($subMessage !== null) ? '; ' . $subMessage : '.'),
323
-          [$blameNode],
324
-          null,
325
-          null,
326
-          [],
327
-          $originalException
320
+            $message .
321
+            (($stringPath !== '') ? ' at ' . $stringPath : $stringPath) .
322
+            (($subMessage !== null) ? '; ' . $subMessage : '.'),
323
+            [$blameNode],
324
+            null,
325
+            null,
326
+            [],
327
+            $originalException
328 328
         );
329 329
     }
330 330
 
@@ -365,14 +365,14 @@  discard block
 block discarded – undo
365 365
      * @throws GraphQLException
366 366
      */
367 367
     private function coerceValue(
368
-      $value,
369
-      $type,
370
-      $blameNode,
368
+        $value,
369
+        $type,
370
+        $blameNode,
371 371
       ?Path $path = null
372 372
     ): CoercedValue {
373 373
         if ($type instanceof NonNullType) {
374 374
             return $this->coerceValueForNonNullType($value, $type, $blameNode,
375
-              $path);
375
+                $path);
376 376
         }
377 377
 
378 378
         if (empty($value)) {
@@ -381,22 +381,22 @@  discard block
 block discarded – undo
381 381
 
382 382
         if ($type instanceof ScalarType) {
383 383
             return $this->coerceValueForScalarType($value, $type, $blameNode,
384
-              $path);
384
+                $path);
385 385
         }
386 386
 
387 387
         if ($type instanceof EnumType) {
388 388
             return $this->coerceValueForEnumType($value, $type, $blameNode,
389
-              $path);
389
+                $path);
390 390
         }
391 391
 
392 392
         if ($type instanceof ListType) {
393 393
             return $this->coerceValueForListType($value, $type, $blameNode,
394
-              $path);
394
+                $path);
395 395
         }
396 396
 
397 397
         if ($type instanceof InputObjectType) {
398 398
             return $this->coerceValueForInputObjectType($value, $type,
399
-              $blameNode, $path);
399
+                $blameNode, $path);
400 400
         }
401 401
 
402 402
         throw new GraphQLException('Unexpected type.');
@@ -413,23 +413,23 @@  discard block
 block discarded – undo
413 413
      * @throws InvariantException
414 414
      */
415 415
     protected function coerceValueForNonNullType(
416
-      $value,
417
-      NonNullType $type,
418
-      NodeInterface $blameNode,
416
+        $value,
417
+        NonNullType $type,
418
+        NodeInterface $blameNode,
419 419
       ?Path $path
420 420
     ): CoercedValue {
421 421
         if (empty($value)) {
422 422
             return new CoercedValue(null, [
423
-              $this->buildCoerceException(
423
+                $this->buildCoerceException(
424 424
                 sprintf('Expected non-nullable type %s not to be null',
425
-                  (string)$type),
425
+                    (string)$type),
426 426
                 $blameNode,
427 427
                 $path
428
-              ),
428
+                ),
429 429
             ]);
430 430
         }
431 431
         return $this->coerceValue($value, $type->getOfType(), $blameNode,
432
-          $path);
432
+            $path);
433 433
     }
434 434
 
435 435
     /**
@@ -445,29 +445,29 @@  discard block
 block discarded – undo
445 445
      * @return CoercedValue
446 446
      */
447 447
     protected function coerceValueForScalarType(
448
-      $value,
449
-      ScalarType $type,
450
-      NodeInterface $blameNode,
448
+        $value,
449
+        ScalarType $type,
450
+        NodeInterface $blameNode,
451 451
       ?Path $path
452 452
     ): CoercedValue {
453 453
         try {
454 454
             $parseResult = $type->parseValue($value);
455 455
             if (empty($parseResult)) {
456 456
                 return new CoercedValue(null, [
457
-                  new GraphQLException(sprintf('Expected type %s',
457
+                    new GraphQLException(sprintf('Expected type %s',
458 458
                     (string)$type)),
459 459
                 ]);
460 460
             }
461 461
             return new CoercedValue($parseResult, null);
462 462
         } catch (InvalidTypeException|CoercingException $ex) {
463 463
             return new CoercedValue(null, [
464
-              $this->buildCoerceException(
464
+                $this->buildCoerceException(
465 465
                 sprintf('Expected type %s', (string)$type),
466 466
                 $blameNode,
467 467
                 $path,
468 468
                 $ex->getMessage(),
469 469
                 $ex
470
-              ),
470
+                ),
471 471
             ]);
472 472
         }
473 473
     }
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
      * @throws InvariantException
483 483
      */
484 484
     protected function coerceValueForEnumType(
485
-      $value,
486
-      EnumType $type,
487
-      NodeInterface $blameNode,
485
+        $value,
486
+        EnumType $type,
487
+        NodeInterface $blameNode,
488 488
       ?Path $path
489 489
     ): CoercedValue {
490 490
         if (is_string($value)) {
@@ -495,16 +495,16 @@  discard block
 block discarded – undo
495 495
         }
496 496
 
497 497
         $suggestions = suggestionList((string)$value,
498
-          array_map(function (EnumValue $enumValue) {
499
-              return $enumValue->getName();
500
-          }, $type->getValues()));
498
+            array_map(function (EnumValue $enumValue) {
499
+                return $enumValue->getName();
500
+            }, $type->getValues()));
501 501
 
502 502
         $didYouMean = (!empty($suggestions))
503 503
           ? 'did you mean' . implode(',', $suggestions)
504 504
           : null;
505 505
 
506 506
         return new CoercedValue(null, [
507
-          $this->buildCoerceException(sprintf('Expected type %s',
507
+            $this->buildCoerceException(sprintf('Expected type %s',
508 508
             $type->getName()), $blameNode, $path, $didYouMean),
509 509
         ]);
510 510
     }
@@ -518,9 +518,9 @@  discard block
 block discarded – undo
518 518
      * @throws InvariantException
519 519
      */
520 520
     protected function coerceValueForListType(
521
-      $value,
522
-      ListType $type,
523
-      NodeInterface $blameNode,
521
+        $value,
522
+        ListType $type,
523
+        NodeInterface $blameNode,
524 524
       ?Path $path
525 525
     ): CoercedValue {
526 526
         $itemType = $type->getOfType();
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
             $coercedValues = [];
531 531
             foreach ($value as $index => $itemValue) {
532 532
                 $coercedValue = $this->coerceValue($itemValue, $itemType,
533
-                  $blameNode, new Path($path, $index));
533
+                    $blameNode, new Path($path, $index));
534 534
 
535 535
                 if ($coercedValue->hasErrors()) {
536 536
                     $errors = array_merge($errors, $coercedValue->getErrors());
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
         $coercedValue = $this->coerceValue($value, $itemType, $blameNode);
547 547
 
548 548
         return new CoercedValue([$coercedValue->getValue()],
549
-          $coercedValue->getErrors());
549
+            $coercedValue->getErrors());
550 550
     }
551 551
 
552 552
     /**
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
      * @throws InvariantException
561 561
      */
562 562
     protected function coerceValueForInputObjectType(
563
-      $value,
564
-      InputObjectType $type,
565
-      NodeInterface $blameNode,
563
+        $value,
564
+        InputObjectType $type,
565
+        NodeInterface $blameNode,
566 566
       ?Path $path
567 567
     ): CoercedValue {
568 568
         $errors = [];
@@ -576,20 +576,20 @@  discard block
 block discarded – undo
576 576
                     $coercedValue[$field->getName()] = $field->getDefaultValue();
577 577
                 } elseif ($field->getType() instanceof NonNullType) {
578 578
                     $errors[] = new GraphQLException(
579
-                      sprintf(
579
+                        sprintf(
580 580
                         "Field %s of required type %s! was not provided.",
581 581
                         $this->printPath(new Path($path, $field->getName())),
582 582
                         $field->getType()->getOfType()
583
-                      )
583
+                        )
584 584
                     );
585 585
                 }
586 586
             } else {
587 587
                 $fieldValue = $value[$field->getName()];
588 588
                 $coercedValue = $this->coerceValue(
589
-                  $fieldValue,
590
-                  $field->getType(),
591
-                  $blameNode,
592
-                  new Path($path, $field->getName())
589
+                    $fieldValue,
590
+                    $field->getType(),
591
+                    $blameNode,
592
+                    new Path($path, $field->getName())
593 593
                 );
594 594
 
595 595
                 if ($coercedValue->hasErrors()) {
@@ -609,11 +609,11 @@  discard block
 block discarded – undo
609 609
                   : null;
610 610
 
611 611
                 $errors[] = $this->buildCoerceException(
612
-                  sprintf('Field "%s" is not defined by type %s', $fieldName,
612
+                    sprintf('Field "%s" is not defined by type %s', $fieldName,
613 613
                     $type->getName()),
614
-                  $blameNode,
615
-                  $path,
616
-                  $didYouMean
614
+                    $blameNode,
615
+                    $path,
616
+                    $didYouMean
617 617
                 );
618 618
             }
619 619
         }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $directiveNode = $node->hasDirectives()
59 59
           ? find($node->getDirectives(),
60
-            function (NameAwareInterface $value) use ($directive) {
60
+            function(NameAwareInterface $value) use ($directive) {
61 61
                 return $value->getNameValue() === $directive->getName();
62 62
             }) : null;
63 63
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         }
99 99
 
100 100
         $argumentNodeMap = keyMap($argumentNodes,
101
-          function (ArgumentNode $value) {
101
+          function(ArgumentNode $value) {
102 102
               return $value->getNameValue();
103 103
           });
104 104
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                 ]);
460 460
             }
461 461
             return new CoercedValue($parseResult, null);
462
-        } catch (InvalidTypeException|CoercingException $ex) {
462
+        } catch (InvalidTypeException | CoercingException $ex) {
463 463
             return new CoercedValue(null, [
464 464
               $this->buildCoerceException(
465 465
                 sprintf('Expected type %s', (string)$type),
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
         }
496 496
 
497 497
         $suggestions = suggestionList((string)$value,
498
-          array_map(function (EnumValue $enumValue) {
498
+          array_map(function(EnumValue $enumValue) {
499 499
               return $enumValue->getName();
500 500
           }, $type->getValues()));
501 501
 
Please login to merge, or discard this patch.
src/Execution/values.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
  * @return array
19 19
  */
20 20
 function coerceVariableValues(
21
-  SchemaInterface $schema,
22
-  array $nodes,
23
-  array $inputs
21
+    SchemaInterface $schema,
22
+    array $nodes,
23
+    array $inputs
24 24
 ): CoercedValue {
25 25
     return GraphQL::make(ValuesHelper::class)
26
-      ->coerceVariableValues($schema, $nodes, $inputs);
26
+        ->coerceVariableValues($schema, $nodes, $inputs);
27 27
 }
28 28
 
29 29
 /**
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
  * @return array
35 35
  */
36 36
 function coerceArgumentValues(
37
-  $definition,
38
-  ArgumentsAwareInterface $node,
39
-  array $variableValues = []
37
+    $definition,
38
+    ArgumentsAwareInterface $node,
39
+    array $variableValues = []
40 40
 ): array {
41 41
     return GraphQL::make(ValuesHelper::class)
42
-      ->coerceArgumentValues($definition, $node, $variableValues);
42
+        ->coerceArgumentValues($definition, $node, $variableValues);
43 43
 }
44 44
 
45 45
 /**
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
  * @return array|null
51 51
  */
52 52
 function coerceDirectiveValues(
53
-  Directive $directive,
54
-  $node,
55
-  array $variableValues = []
53
+    Directive $directive,
54
+    $node,
55
+    array $variableValues = []
56 56
 ): ?array
57 57
 {
58 58
     return GraphQL::make(ValuesHelper::class)
59
-      ->coerceDirectiveValues($directive, $node, $variableValues);
59
+        ->coerceDirectiveValues($directive, $node, $variableValues);
60 60
 }
Please login to merge, or discard this patch.
src/Execution/ResolveInfo.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -77,16 +77,16 @@
 block discarded – undo
77 77
      * @param array $variableValues
78 78
      */
79 79
     public function __construct(
80
-      string $fieldName,
80
+        string $fieldName,
81 81
       ?array $fieldNodes,
82
-      TypeInterface $returnType,
83
-      ObjectType $parentType,
82
+        TypeInterface $returnType,
83
+        ObjectType $parentType,
84 84
       ?array $path,
85
-      SchemaInterface $schema,
86
-      array $fragments,
87
-      $rootValue,
88
-      OperationDefinitionNode $operation,
89
-      array $variableValues
85
+        SchemaInterface $schema,
86
+        array $fragments,
87
+        $rootValue,
88
+        OperationDefinitionNode $operation,
89
+        array $variableValues
90 90
     ) {
91 91
         $this->fieldName = $fieldName;
92 92
         $this->fieldNodes = $fieldNodes;
Please login to merge, or discard this patch.
src/Execution/ExecutionStrategy.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
      * @var array
44 44
      */
45 45
     protected static $defaultFieldResolver = [
46
-      __CLASS__,
47
-      'defaultFieldResolver',
46
+        __CLASS__,
47
+        'defaultFieldResolver',
48 48
     ];
49 49
 
50 50
     /**
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
      * @param OperationDefinitionNode $operation
76 76
      */
77 77
     public function __construct(
78
-      ExecutionContext $context,
79
-      OperationDefinitionNode $operation,
80
-      $rootValue
78
+        ExecutionContext $context,
79
+        OperationDefinitionNode $operation,
80
+        $rootValue
81 81
     ) {
82 82
         $this->context = $context;
83 83
         $this->operation = $operation;
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
      * @return mixed|null
96 96
      */
97 97
     public static function defaultFieldResolver(
98
-      $rootValue,
99
-      $args,
100
-      $context,
101
-      ResolveInfo $info
98
+        $rootValue,
99
+        $args,
100
+        $context,
101
+        ResolveInfo $info
102 102
     ) {
103 103
         $fieldName = $info->getFieldName();
104 104
         $property = null;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 
120 120
         return $property instanceof \Closure ? $property($rootValue, $args,
121
-          $context, $info) : $property;
121
+            $context, $info) : $property;
122 122
     }
123 123
 
124 124
     /**
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
      * @throws \Throwable
143 143
      */
144 144
     public function executeFieldsSerially(
145
-      ObjectType $objectType,
146
-      $rootValue,
147
-      $path,
148
-      $fields
145
+        ObjectType $objectType,
146
+        $rootValue,
147
+        $path,
148
+        $fields
149 149
     ) {
150 150
 
151 151
         $finalResults = [];
@@ -153,18 +153,18 @@  discard block
 block discarded – undo
153 153
         $promise = new \React\Promise\FulfilledPromise([]);
154 154
 
155 155
         $resolve = function (
156
-          $results,
157
-          $fieldName,
158
-          $path,
159
-          $objectType,
160
-          $rootValue,
161
-          $fieldNodes
156
+            $results,
157
+            $fieldName,
158
+            $path,
159
+            $objectType,
160
+            $rootValue,
161
+            $fieldNodes
162 162
         ) {
163 163
             $fieldPath = $path;
164 164
             $fieldPath[] = $fieldName;
165 165
             try {
166 166
                 $result = $this->resolveField($objectType, $rootValue,
167
-                  $fieldNodes, $fieldPath);
167
+                    $fieldNodes, $fieldPath);
168 168
             } catch (UndefinedException $ex) {
169 169
                 return null;
170 170
             }
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
             if ($this->isPromise($result)) {
173 173
                 /** @var ExtendedPromiseInterface $result */
174 174
                 return $result->then(function ($resolvedResult) use (
175
-                  $fieldName,
176
-                  $results
175
+                    $fieldName,
176
+                    $results
177 177
                 ) {
178 178
                     $results[$fieldName] = $resolvedResult;
179 179
                     return $results;
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 
188 188
         foreach ($fields as $fieldName => $fieldNodes) {
189 189
             $promise = $promise->then(function ($resolvedResults) use (
190
-              $resolve,
191
-              $fieldName,
192
-              $path,
193
-              $objectType,
194
-              $rootValue,
195
-              $fieldNodes
190
+                $resolve,
191
+                $fieldName,
192
+                $path,
193
+                $objectType,
194
+                $rootValue,
195
+                $fieldNodes
196 196
             ) {
197 197
                 return $resolve($resolvedResults, $fieldName, $path,
198
-                  $objectType, $rootValue, $fieldNodes);
198
+                    $objectType, $rootValue, $fieldNodes);
199 199
             });
200 200
         }
201 201
 
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
      * @throws \Throwable
223 223
      */
224 224
     protected function executeFields(
225
-      ObjectType $objectType,
226
-      $rootValue,
227
-      $path,
228
-      $fields
225
+        ObjectType $objectType,
226
+        $rootValue,
227
+        $path,
228
+        $fields
229 229
     ): array {
230 230
         $finalResults = [];
231 231
         $isContainsPromise = false;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
             try {
238 238
                 $result = $this->resolveField($objectType, $rootValue,
239
-                  $fieldNodes, $fieldPath);
239
+                    $fieldNodes, $fieldPath);
240 240
             } catch (UndefinedException $ex) {
241 241
                 continue;
242 242
             }
@@ -272,42 +272,42 @@  discard block
 block discarded – undo
272 272
      * @throws \Throwable
273 273
      */
274 274
     protected function resolveField(
275
-      ObjectType $parentType,
276
-      $rootValue,
277
-      $fieldNodes,
278
-      $path
275
+        ObjectType $parentType,
276
+        $rootValue,
277
+        $fieldNodes,
278
+        $path
279 279
     ) {
280 280
         /** @var FieldNode $fieldNode */
281 281
         $fieldNode = $fieldNodes[0];
282 282
 
283 283
         $field = $this->getFieldDefinition($this->context->getSchema(),
284
-          $parentType, $fieldNode->getNameValue());
284
+            $parentType, $fieldNode->getNameValue());
285 285
 
286 286
         if (null === $field) {
287 287
             throw new UndefinedException('Undefined field definition.');
288 288
         }
289 289
 
290 290
         $info = $this->buildResolveInfo($fieldNodes, $fieldNode, $field,
291
-          $parentType, $path, $this->context);
291
+            $parentType, $path, $this->context);
292 292
 
293 293
         $resolveFunction = $this->determineResolveFunction($field, $parentType,
294
-          $this->context);
294
+            $this->context);
295 295
 
296 296
         $result = $this->resolveFieldValueOrError(
297
-          $field,
298
-          $fieldNode,
299
-          $resolveFunction,
300
-          $rootValue,
301
-          $this->context,
302
-          $info
297
+            $field,
298
+            $fieldNode,
299
+            $resolveFunction,
300
+            $rootValue,
301
+            $this->context,
302
+            $info
303 303
         );
304 304
 
305 305
         $result = $this->completeValueCatchingError(
306
-          $field->getType(),
307
-          $fieldNodes,
308
-          $info,
309
-          $path,
310
-          $result// $result is passed as $source
306
+            $field->getType(),
307
+            $fieldNodes,
308
+            $info,
309
+            $path,
310
+            $result// $result is passed as $source
311 311
         );
312 312
 
313 313
         return $result;
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
      * @throws \Digia\GraphQL\Error\InvariantException
324 324
      */
325 325
     public function getFieldDefinition(
326
-      Schema $schema,
327
-      ObjectType $parentType,
328
-      string $fieldName
326
+        Schema $schema,
327
+        ObjectType $parentType,
328
+        string $fieldName
329 329
     ) {
330 330
         $schemaMetaFieldDefinition = SchemaMetaFieldDefinition();
331 331
         $typeMetaFieldDefinition = TypeMetaFieldDefinition();
@@ -359,24 +359,24 @@  discard block
 block discarded – undo
359 359
      * @return ResolveInfo
360 360
      */
361 361
     private function buildResolveInfo(
362
-      array $fieldNodes,
363
-      FieldNode $fieldNode,
364
-      Field $field,
365
-      ObjectType $parentType,
362
+        array $fieldNodes,
363
+        FieldNode $fieldNode,
364
+        Field $field,
365
+        ObjectType $parentType,
366 366
       ?array $path,
367
-      ExecutionContext $context
367
+        ExecutionContext $context
368 368
     ) {
369 369
         return new ResolveInfo(
370
-          $fieldNode->getNameValue(),
371
-          $fieldNodes,
372
-          $field->getType(),
373
-          $parentType,
374
-          $path,
375
-          $context->getSchema(),
376
-          $context->getFragments(),
377
-          $context->getRootValue(),
378
-          $context->getOperation(),
379
-          $context->getVariableValues()
370
+            $fieldNode->getNameValue(),
371
+            $fieldNodes,
372
+            $field->getType(),
373
+            $parentType,
374
+            $path,
375
+            $context->getSchema(),
376
+            $context->getFragments(),
377
+            $context->getRootValue(),
378
+            $context->getOperation(),
379
+            $context->getVariableValues()
380 380
         );
381 381
     }
382 382
 
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
      * @return callable|mixed|null
389 389
      */
390 390
     private function determineResolveFunction(
391
-      Field $field,
392
-      ObjectType $objectType,
393
-      ExecutionContext $context
391
+        Field $field,
392
+        ObjectType $objectType,
393
+        ExecutionContext $context
394 394
     ) {
395 395
 
396 396
         if ($field->hasResolve()) {
@@ -415,19 +415,19 @@  discard block
 block discarded – undo
415 415
      * @return array|\Throwable
416 416
      */
417 417
     private function resolveFieldValueOrError(
418
-      Field $field,
419
-      FieldNode $fieldNode,
418
+        Field $field,
419
+        FieldNode $fieldNode,
420 420
       ?callable $resolveFunction,
421
-      $rootValue,
422
-      ExecutionContext $context,
423
-      ResolveInfo $info
421
+        $rootValue,
422
+        ExecutionContext $context,
423
+        ResolveInfo $info
424 424
     ) {
425 425
         try {
426 426
             $args = coerceArgumentValues($field, $fieldNode,
427
-              $context->getVariableValues());
427
+                $context->getVariableValues());
428 428
 
429 429
             return $resolveFunction($rootValue, $args,
430
-              $context->getContextValue(), $info);
430
+                $context->getContextValue(), $info);
431 431
         } catch (\Throwable $error) {
432 432
             return $error;
433 433
         }
@@ -444,51 +444,51 @@  discard block
 block discarded – undo
444 444
      * @throws \Throwable
445 445
      */
446 446
     public function completeValueCatchingError(
447
-      TypeInterface $fieldType,
448
-      $fieldNodes,
449
-      ResolveInfo $info,
450
-      $path,
451
-      &$result
447
+        TypeInterface $fieldType,
448
+        $fieldNodes,
449
+        ResolveInfo $info,
450
+        $path,
451
+        &$result
452 452
     ) {
453 453
         if ($fieldType instanceof NonNullType) {
454 454
             return $this->completeValueWithLocatedError(
455
-              $fieldType,
456
-              $fieldNodes,
457
-              $info,
458
-              $path,
459
-              $result
455
+                $fieldType,
456
+                $fieldNodes,
457
+                $info,
458
+                $path,
459
+                $result
460 460
             );
461 461
         }
462 462
 
463 463
         try {
464 464
             $completed = $this->completeValueWithLocatedError(
465
-              $fieldType,
466
-              $fieldNodes,
467
-              $info,
468
-              $path,
469
-              $result
465
+                $fieldType,
466
+                $fieldNodes,
467
+                $info,
468
+                $path,
469
+                $result
470 470
             );
471 471
 
472 472
             if ($this->isPromise($completed)) {
473 473
                 $context = $this->context;
474 474
                 /** @var ExtendedPromiseInterface $completed */
475 475
                 return $completed->then(null,
476
-                  function ($error) use ($context, $fieldNodes, $path) {
477
-                      //@TODO Handle $error better
478
-                      if ($error instanceof \Exception) {
479
-                          $context->addError($this->buildLocatedError($error,
476
+                    function ($error) use ($context, $fieldNodes, $path) {
477
+                        //@TODO Handle $error better
478
+                        if ($error instanceof \Exception) {
479
+                            $context->addError($this->buildLocatedError($error,
480 480
                             $fieldNodes, $path));
481
-                      } else {
482
-                          $context->addError(
481
+                        } else {
482
+                            $context->addError(
483 483
                             $this->buildLocatedError(
484
-                              new ExecutionException($error ?? 'An unknown error occurred.'),
485
-                              $fieldNodes,
486
-                              $path
484
+                                new ExecutionException($error ?? 'An unknown error occurred.'),
485
+                                $fieldNodes,
486
+                                $path
487 487
                             )
488
-                          );
489
-                      }
490
-                      return new \React\Promise\FulfilledPromise(null);
491
-                  });
488
+                            );
489
+                        }
490
+                        return new \React\Promise\FulfilledPromise(null);
491
+                    });
492 492
             }
493 493
 
494 494
             return $completed;
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
             return null;
498 498
         } catch (\Exception $ex) {
499 499
             $this->context->addError($this->buildLocatedError($ex, $fieldNodes,
500
-              $path));
500
+                $path));
501 501
             return null;
502 502
         }
503 503
     }
@@ -512,19 +512,19 @@  discard block
 block discarded – undo
512 512
      * @throws \Throwable
513 513
      */
514 514
     public function completeValueWithLocatedError(
515
-      TypeInterface $fieldType,
516
-      $fieldNodes,
517
-      ResolveInfo $info,
518
-      $path,
519
-      $result
515
+        TypeInterface $fieldType,
516
+        $fieldNodes,
517
+        ResolveInfo $info,
518
+        $path,
519
+        $result
520 520
     ) {
521 521
         try {
522 522
             $completed = $this->completeValue(
523
-              $fieldType,
524
-              $fieldNodes,
525
-              $info,
526
-              $path,
527
-              $result
523
+                $fieldType,
524
+                $fieldNodes,
525
+                $info,
526
+                $path,
527
+                $result
528 528
             );
529 529
 
530 530
             return $completed;
@@ -545,22 +545,22 @@  discard block
 block discarded – undo
545 545
      * @throws \Throwable
546 546
      */
547 547
     private function completeValue(
548
-      TypeInterface $returnType,
549
-      $fieldNodes,
550
-      ResolveInfo $info,
551
-      $path,
552
-      &$result
548
+        TypeInterface $returnType,
549
+        $fieldNodes,
550
+        ResolveInfo $info,
551
+        $path,
552
+        &$result
553 553
     ) {
554 554
         if ($this->isPromise($result)) {
555 555
             /** @var ExtendedPromiseInterface $result */
556 556
             return $result->then(function (&$value) use (
557
-              $returnType,
558
-              $fieldNodes,
559
-              $info,
560
-              $path
557
+                $returnType,
558
+                $fieldNodes,
559
+                $info,
560
+                $path
561 561
             ) {
562 562
                 return $this->completeValue($returnType, $fieldNodes, $info,
563
-                  $path, $value);
563
+                    $path, $value);
564 564
             });
565 565
         }
566 566
 
@@ -575,19 +575,19 @@  discard block
 block discarded – undo
575 575
 
576 576
         if ($returnType instanceof NonNullType) {
577 577
             $completed = $this->completeValue(
578
-              $returnType->getOfType(),
579
-              $fieldNodes,
580
-              $info,
581
-              $path,
582
-              $result
578
+                $returnType->getOfType(),
579
+                $fieldNodes,
580
+                $info,
581
+                $path,
582
+                $result
583 583
             );
584 584
 
585 585
             if ($completed === null) {
586 586
                 throw new ExecutionException(
587
-                  sprintf(
587
+                    sprintf(
588 588
                     'Cannot return null for non-nullable field %s.%s.',
589 589
                     $info->getParentType(), $info->getFieldName()
590
-                  )
590
+                    )
591 591
                 );
592 592
             }
593 593
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
         // If field type is List, complete each item in the list with the inner type
598 598
         if ($returnType instanceof ListType) {
599 599
             return $this->completeListValue($returnType, $fieldNodes, $info,
600
-              $path, $result);
600
+                $path, $result);
601 601
         }
602 602
 
603 603
 
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
         //@TODO Make a function for checking abstract type?
611 611
         if ($returnType instanceof InterfaceType || $returnType instanceof UnionType) {
612 612
             return $this->completeAbstractValue($returnType, $fieldNodes, $info,
613
-              $path, $result);
613
+                $path, $result);
614 614
         }
615 615
 
616 616
         // Field type must be Object, Interface or Union and expect sub-selections.
617 617
         if ($returnType instanceof ObjectType) {
618 618
             return $this->completeObjectValue($returnType, $fieldNodes, $info,
619
-              $path, $result);
619
+                $path, $result);
620 620
         }
621 621
 
622 622
         throw new ExecutionException("Cannot complete value of unexpected type \"{$returnType}\".");
@@ -643,11 +643,11 @@  discard block
 block discarded – undo
643 643
      * @throws \Throwable
644 644
      */
645 645
     private function completeListValue(
646
-      ListType $returnType,
647
-      $fieldNodes,
648
-      ResolveInfo $info,
649
-      $path,
650
-      &$result
646
+        ListType $returnType,
647
+        $fieldNodes,
648
+        ResolveInfo $info,
649
+        $path,
650
+        &$result
651 651
     ) {
652 652
         $itemType = $returnType->getOfType();
653 653
 
@@ -656,11 +656,11 @@  discard block
 block discarded – undo
656 656
 
657 657
         if (!is_array($result) && !($result instanceof \Traversable)) {
658 658
             throw new \Exception(
659
-              sprintf(
659
+                sprintf(
660 660
                 'Expected Array or Traversable, but did not find one for field %s.%s.',
661 661
                 $info->getParentType()->getName(),
662 662
                 $info->getFieldName()
663
-              )
663
+                )
664 664
             );
665 665
         }
666 666
 
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
             $fieldPath = $path;
669 669
             $fieldPath[] = $key;
670 670
             $completedItem = $this->completeValueCatchingError($itemType,
671
-              $fieldNodes, $info, $fieldPath, $item);
671
+                $fieldNodes, $info, $fieldPath, $item);
672 672
             $completedItems[] = $completedItem;
673 673
             $containsPromise = $containsPromise || $this->isPromise($completedItem);
674 674
         }
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
         if ($serializedResult === null) {
691 691
             //@TODO Make a function for this type of exception
692 692
             throw new ExecutionException(
693
-              sprintf('Expected value of type "%s" but received: %s.',
693
+                sprintf('Expected value of type "%s" but received: %s.',
694 694
                 (string)$returnType, toString($result))
695 695
             );
696 696
         }
@@ -712,58 +712,58 @@  discard block
 block discarded – undo
712 712
      * @throws \Throwable
713 713
      */
714 714
     private function completeAbstractValue(
715
-      AbstractTypeInterface $returnType,
716
-      $fieldNodes,
717
-      ResolveInfo $info,
718
-      $path,
719
-      &$result
715
+        AbstractTypeInterface $returnType,
716
+        $fieldNodes,
717
+        ResolveInfo $info,
718
+        $path,
719
+        &$result
720 720
     ) {
721 721
         $runtimeType = $returnType->resolveType($result,
722
-          $this->context->getContextValue(), $info);
722
+            $this->context->getContextValue(), $info);
723 723
 
724 724
         if (null === $runtimeType) {
725 725
             //@TODO Show warning
726 726
             $runtimeType = $this->defaultTypeResolver($result,
727
-              $this->context->getContextValue(), $info, $returnType);
727
+                $this->context->getContextValue(), $info, $returnType);
728 728
         }
729 729
 
730 730
         if ($this->isPromise($runtimeType)) {
731 731
             /** @var ExtendedPromiseInterface $runtimeType */
732 732
             return $runtimeType->then(function ($resolvedRuntimeType) use (
733
-              $returnType,
734
-              $fieldNodes,
735
-              $info,
736
-              $path,
737
-              &$result
733
+                $returnType,
734
+                $fieldNodes,
735
+                $info,
736
+                $path,
737
+                &$result
738 738
             ) {
739 739
                 return $this->completeObjectValue(
740
-                  $this->ensureValidRuntimeType(
740
+                    $this->ensureValidRuntimeType(
741 741
                     $resolvedRuntimeType,
742 742
                     $returnType,
743 743
                     $fieldNodes,
744 744
                     $info,
745 745
                     $result
746
-                  ),
747
-                  $fieldNodes,
748
-                  $info,
749
-                  $path,
750
-                  $result
746
+                    ),
747
+                    $fieldNodes,
748
+                    $info,
749
+                    $path,
750
+                    $result
751 751
                 );
752 752
             });
753 753
         }
754 754
 
755 755
         return $this->completeObjectValue(
756
-          $this->ensureValidRuntimeType(
756
+            $this->ensureValidRuntimeType(
757 757
             $runtimeType,
758 758
             $returnType,
759 759
             $fieldNodes,
760 760
             $info,
761 761
             $result
762
-          ),
763
-          $fieldNodes,
764
-          $info,
765
-          $path,
766
-          $result
762
+            ),
763
+            $fieldNodes,
764
+            $info,
765
+            $path,
766
+            $result
767 767
         );
768 768
     }
769 769
 
@@ -777,10 +777,10 @@  discard block
 block discarded – undo
777 777
      * @throws ExecutionException
778 778
      */
779 779
     private function defaultTypeResolver(
780
-      $value,
781
-      $context,
782
-      ResolveInfo $info,
783
-      AbstractTypeInterface $abstractType
780
+        $value,
781
+        $context,
782
+        ResolveInfo $info,
783
+        AbstractTypeInterface $abstractType
784 784
     ) {
785 785
         $possibleTypes = $info->getSchema()->getPossibleTypes($abstractType);
786 786
         $promisedIsTypeOfResults = [];
@@ -808,14 +808,14 @@  discard block
 block discarded – undo
808 808
 
809 809
         if (!empty($promisedIsTypeOfResults)) {
810 810
             return \React\Promise\all($promisedIsTypeOfResults)
811
-              ->then(function ($isTypeOfResults) use ($possibleTypes) {
812
-                  foreach ($isTypeOfResults as $index => $result) {
813
-                      if ($result) {
814
-                          return $possibleTypes[$index];
815
-                      }
816
-                  }
817
-                  return null;
818
-              });
811
+                ->then(function ($isTypeOfResults) use ($possibleTypes) {
812
+                    foreach ($isTypeOfResults as $index => $result) {
813
+                        if ($result) {
814
+                            return $possibleTypes[$index];
815
+                        }
816
+                    }
817
+                    return null;
818
+                });
819 819
         }
820 820
 
821 821
         return null;
@@ -835,31 +835,31 @@  discard block
 block discarded – undo
835 835
      * @throws \Throwable
836 836
      */
837 837
     private function completeObjectValue(
838
-      ObjectType $returnType,
839
-      $fieldNodes,
840
-      ResolveInfo $info,
841
-      $path,
842
-      &$result
838
+        ObjectType $returnType,
839
+        $fieldNodes,
840
+        ResolveInfo $info,
841
+        $path,
842
+        &$result
843 843
     ) {
844 844
 
845 845
         if (null !== $returnType->getIsTypeOf()) {
846 846
             $isTypeOf = $returnType->isTypeOf($result,
847
-              $this->context->getContextValue(), $info);
847
+                $this->context->getContextValue(), $info);
848 848
             //@TODO check for promise?
849 849
             if (!$isTypeOf) {
850 850
                 throw new ExecutionException(
851
-                  sprintf('Expected value of type "%s" but received: %s.',
851
+                    sprintf('Expected value of type "%s" but received: %s.',
852 852
                     (string)$returnType, toString($result))
853 853
                 );
854 854
             }
855 855
         }
856 856
 
857 857
         return $this->collectAndExecuteSubFields(
858
-          $returnType,
859
-          $fieldNodes,
860
-          $info,
861
-          $path,
862
-          $result
858
+            $returnType,
859
+            $fieldNodes,
860
+            $info,
861
+            $path,
862
+            $result
863 863
         );
864 864
     }
865 865
 
@@ -877,11 +877,11 @@  discard block
 block discarded – undo
877 877
      * @throws \Throwable
878 878
      */
879 879
     private function collectAndExecuteSubFields(
880
-      ObjectType $returnType,
881
-      $fieldNodes,
882
-      ResolveInfo $info,
883
-      $path,
884
-      &$result
880
+        ObjectType $returnType,
881
+        $fieldNodes,
882
+        ResolveInfo $info,
883
+        $path,
884
+        &$result
885 885
     ) {
886 886
         $subFields = [];
887 887
         $visitedFragmentNames = [];
@@ -890,17 +890,17 @@  discard block
 block discarded – undo
890 890
             /** @var FieldNode $fieldNode */
891 891
             if ($fieldNode->getSelectionSet() !== null) {
892 892
                 $subFields = $this->collectFields(
893
-                  $returnType,
894
-                  $fieldNode->getSelectionSet(),
895
-                  $subFields,
896
-                  $visitedFragmentNames
893
+                    $returnType,
894
+                    $fieldNode->getSelectionSet(),
895
+                    $subFields,
896
+                    $visitedFragmentNames
897 897
                 );
898 898
             }
899 899
         }
900 900
 
901 901
         if (!empty($subFields)) {
902 902
             return $this->executeFields($returnType, $result, $path,
903
-              $subFields);
903
+                $subFields);
904 904
         }
905 905
 
906 906
         return $result;
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
      * @throws \Digia\GraphQL\Error\InvariantException
919 919
      */
920 920
     protected function collectFields(
921
-      ObjectType $runtimeType,
922
-      SelectionSetNode $selectionSet,
923
-      &$fields,
924
-      &$visitedFragmentNames
921
+        ObjectType $runtimeType,
922
+        SelectionSetNode $selectionSet,
923
+        &$fields,
924
+        &$visitedFragmentNames
925 925
     ) {
926 926
         foreach ($selectionSet->getSelections() as $selection) {
927 927
             // Check if this Node should be included first
@@ -939,13 +939,13 @@  discard block
 block discarded – undo
939 939
                 $fields[$fieldName][] = $selection;
940 940
             } elseif ($selection instanceof InlineFragmentNode) {
941 941
                 if (!$this->doesFragmentConditionMatch($selection,
942
-                  $runtimeType)) {
942
+                    $runtimeType)) {
943 943
                     continue;
944 944
                 }
945 945
 
946 946
                 $this->collectFields($runtimeType,
947
-                  $selection->getSelectionSet(), $fields,
948
-                  $visitedFragmentNames);
947
+                    $selection->getSelectionSet(), $fields,
948
+                    $visitedFragmentNames);
949 949
             } elseif ($selection instanceof FragmentSpreadNode) {
950 950
                 $fragmentName = $selection->getNameValue();
951 951
 
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
                 /** @var FragmentDefinitionNode $fragment */
958 958
                 $fragment = $this->context->getFragments()[$fragmentName];
959 959
                 $this->collectFields($runtimeType, $fragment->getSelectionSet(),
960
-                  $fields, $visitedFragmentNames);
960
+                    $fields, $visitedFragmentNames);
961 961
             }
962 962
         }
963 963
 
@@ -978,14 +978,14 @@  discard block
 block discarded – undo
978 978
         $contextVariables = $this->context->getVariableValues();
979 979
 
980 980
         $skip = coerceDirectiveValues(SkipDirective(), $node,
981
-          $contextVariables);
981
+            $contextVariables);
982 982
 
983 983
         if ($skip && $skip['if'] === true) {
984 984
             return false;
985 985
         }
986 986
 
987 987
         $include = coerceDirectiveValues(IncludeDirective(), $node,
988
-          $contextVariables);
988
+            $contextVariables);
989 989
 
990 990
         if ($include && $include['if'] === false) {
991 991
             return false;
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
     private function getFieldNameKey(FieldNode $node): string
1005 1005
     {
1006 1006
         return $node->getAlias() ? $node->getAlias()
1007
-          ->getValue() : $node->getNameValue();
1007
+            ->getValue() : $node->getNameValue();
1008 1008
     }
1009 1009
 
1010 1010
     /**
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
      * @throws InvalidTypeException
1016 1016
      */
1017 1017
     private function doesFragmentConditionMatch(
1018
-      NodeInterface $fragment,
1019
-      ObjectType $type
1018
+        NodeInterface $fragment,
1019
+        ObjectType $type
1020 1020
     ): bool {
1021 1021
         $typeConditionNode = $fragment->getTypeCondition();
1022 1022
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
         }
1026 1026
 
1027 1027
         $conditionalType = typeFromAST($this->context->getSchema(),
1028
-          $typeConditionNode);
1028
+            $typeConditionNode);
1029 1029
 
1030 1030
         if ($conditionalType === $type) {
1031 1031
             return true;
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 
1034 1034
         if ($conditionalType instanceof AbstractTypeInterface) {
1035 1035
             return $this->context->getSchema()
1036
-              ->isPossibleType($conditionalType, $type);
1036
+                ->isPossibleType($conditionalType, $type);
1037 1037
         }
1038 1038
 
1039 1039
         return false;
@@ -1050,11 +1050,11 @@  discard block
 block discarded – undo
1050 1050
      * @throws ExecutionException
1051 1051
      */
1052 1052
     private function ensureValidRuntimeType(
1053
-      $runtimeTypeOrName,
1054
-      AbstractTypeInterface $returnType,
1055
-      $fieldNodes,
1056
-      ResolveInfo $info,
1057
-      &$result
1053
+        $runtimeTypeOrName,
1054
+        AbstractTypeInterface $returnType,
1055
+        $fieldNodes,
1056
+        ResolveInfo $info,
1057
+        &$result
1058 1058
     ) {
1059 1059
         $runtimeType = is_string($runtimeTypeOrName)
1060 1060
           ? $this->context->getSchema()->getType($runtimeTypeOrName)
@@ -1068,25 +1068,25 @@  discard block
 block discarded – undo
1068 1068
             $fieldName = $info->getFieldName();
1069 1069
 
1070 1070
             throw new ExecutionException(
1071
-              "Abstract type {$returnTypeName} must resolve to an Object type at runtime " .
1072
-              "for field {$parentTypeName}.{$fieldName} with " .
1073
-              'value "' . $result . '", received "{$runtimeTypeName}".'
1071
+                "Abstract type {$returnTypeName} must resolve to an Object type at runtime " .
1072
+                "for field {$parentTypeName}.{$fieldName} with " .
1073
+                'value "' . $result . '", received "{$runtimeTypeName}".'
1074 1074
             );
1075 1075
         }
1076 1076
 
1077 1077
         if (!$this->context->getSchema()
1078
-          ->isPossibleType($returnType, $runtimeType)) {
1078
+            ->isPossibleType($returnType, $runtimeType)) {
1079 1079
             throw new ExecutionException(
1080
-              "Runtime Object type \"{$runtimeTypeName}\" is not a possible type for \"{$returnTypeName}\"."
1080
+                "Runtime Object type \"{$runtimeTypeName}\" is not a possible type for \"{$returnTypeName}\"."
1081 1081
             );
1082 1082
         }
1083 1083
 
1084 1084
         if ($runtimeType !== $this->context->getSchema()
1085 1085
             ->getType($runtimeType->getName())) {
1086 1086
             throw new ExecutionException(
1087
-              "Schema must contain unique named types but contains multiple types named \"{$runtimeTypeName}\". " .
1088
-              "Make sure that `resolveType` function of abstract type \"{$returnTypeName}\" returns the same " .
1089
-              "type instance as referenced anywhere else within the schema."
1087
+                "Schema must contain unique named types but contains multiple types named \"{$runtimeTypeName}\". " .
1088
+                "Make sure that `resolveType` function of abstract type \"{$returnTypeName}\" returns the same " .
1089
+                "type instance as referenced anywhere else within the schema."
1090 1090
             );
1091 1091
         }
1092 1092
 
@@ -1101,17 +1101,17 @@  discard block
 block discarded – undo
1101 1101
      * @return GraphQLException
1102 1102
      */
1103 1103
     protected function buildLocatedError(
1104
-      \Throwable $originalException,
1105
-      array $nodes = [],
1106
-      array $path = []
1104
+        \Throwable $originalException,
1105
+        array $nodes = [],
1106
+        array $path = []
1107 1107
     ): ExecutionException {
1108 1108
         return new ExecutionException(
1109
-          $originalException->getMessage(),
1110
-          $originalException instanceof GraphQLException ? $originalException->getNodes() : $nodes,
1111
-          $originalException instanceof GraphQLException ? $originalException->getSource() : null,
1112
-          $originalException instanceof GraphQLException ? $originalException->getPositions() : null,
1113
-          $originalException instanceof GraphQLException ? ($originalException->getPath() ?? $path) : $path,
1114
-          $originalException
1109
+            $originalException->getMessage(),
1110
+            $originalException instanceof GraphQLException ? $originalException->getNodes() : $nodes,
1111
+            $originalException instanceof GraphQLException ? $originalException->getSource() : null,
1112
+            $originalException instanceof GraphQLException ? $originalException->getPositions() : null,
1113
+            $originalException instanceof GraphQLException ? ($originalException->getPath() ?? $path) : $path,
1114
+            $originalException
1115 1115
         );
1116 1116
     }
1117 1117
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
         $promise = new \React\Promise\FulfilledPromise([]);
154 154
 
155
-        $resolve = function (
155
+        $resolve = function(
156 156
           $results,
157 157
           $fieldName,
158 158
           $path,
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
             if ($this->isPromise($result)) {
173 173
                 /** @var ExtendedPromiseInterface $result */
174
-                return $result->then(function ($resolvedResult) use (
174
+                return $result->then(function($resolvedResult) use (
175 175
                   $fieldName,
176 176
                   $results
177 177
                 ) {
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         };
187 187
 
188 188
         foreach ($fields as $fieldName => $fieldNodes) {
189
-            $promise = $promise->then(function ($resolvedResults) use (
189
+            $promise = $promise->then(function($resolvedResults) use (
190 190
               $resolve,
191 191
               $fieldName,
192 192
               $path,
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             });
200 200
         }
201 201
 
202
-        $promise->then(function ($resolvedResults) use (&$finalResults) {
202
+        $promise->then(function($resolvedResults) use (&$finalResults) {
203 203
             $finalResults = $resolvedResults ?? [];
204 204
         });
205 205
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         if ($isContainsPromise) {
250 250
             $keys = array_keys($finalResults);
251 251
             $promise = \React\Promise\all(array_values($finalResults));
252
-            $promise->then(function ($values) use ($keys, &$finalResults) {
252
+            $promise->then(function($values) use ($keys, &$finalResults) {
253 253
                 foreach ($values as $i => $value) {
254 254
                     $finalResults[$keys[$i]] = $value;
255 255
                 }
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
                 $context = $this->context;
474 474
                 /** @var ExtendedPromiseInterface $completed */
475 475
                 return $completed->then(null,
476
-                  function ($error) use ($context, $fieldNodes, $path) {
476
+                  function($error) use ($context, $fieldNodes, $path) {
477 477
                       //@TODO Handle $error better
478 478
                       if ($error instanceof \Exception) {
479 479
                           $context->addError($this->buildLocatedError($error,
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
     ) {
554 554
         if ($this->isPromise($result)) {
555 555
             /** @var ExtendedPromiseInterface $result */
556
-            return $result->then(function (&$value) use (
556
+            return $result->then(function(&$value) use (
557 557
               $returnType,
558 558
               $fieldNodes,
559 559
               $info,
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 
730 730
         if ($this->isPromise($runtimeType)) {
731 731
             /** @var ExtendedPromiseInterface $runtimeType */
732
-            return $runtimeType->then(function ($resolvedRuntimeType) use (
732
+            return $runtimeType->then(function($resolvedRuntimeType) use (
733 733
               $returnType,
734 734
               $fieldNodes,
735 735
               $info,
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 
809 809
         if (!empty($promisedIsTypeOfResults)) {
810 810
             return \React\Promise\all($promisedIsTypeOfResults)
811
-              ->then(function ($isTypeOfResults) use ($possibleTypes) {
811
+              ->then(function($isTypeOfResults) use ($possibleTypes) {
812 812
                   foreach ($isTypeOfResults as $index => $result) {
813 813
                       if ($result) {
814 814
                           return $possibleTypes[$index];
Please login to merge, or discard this patch.