Passed
Pull Request — master (#190)
by Sebastian
03:03
created
src/Util/TypeHelper.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
      * @return bool
30 30
      */
31 31
     public function isEqualType(
32
-      TypeInterface $typeA,
33
-      TypeInterface $typeB
32
+        TypeInterface $typeA,
33
+        TypeInterface $typeB
34 34
     ): bool {
35 35
         // Equivalent types are equal.
36 36
         if ($typeA === $typeB) {
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
      * @return bool
63 63
      */
64 64
     public function isTypeSubtypeOf(
65
-      SchemaInterface $schema,
66
-      TypeInterface $maybeSubtype,
67
-      TypeInterface $superType
65
+        SchemaInterface $schema,
66
+        TypeInterface $maybeSubtype,
67
+        TypeInterface $superType
68 68
     ): bool {
69 69
         // Equivalent type is a valid subtype.
70 70
         if ($maybeSubtype === $superType) {
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         if ($superType instanceof NonNullType) {
76 76
             if ($maybeSubtype instanceof NonNullType) {
77 77
                 return $this->isTypeSubtypeOf($schema,
78
-                  $maybeSubtype->getOfType(), $superType->getOfType());
78
+                    $maybeSubtype->getOfType(), $superType->getOfType());
79 79
             }
80 80
             return false;
81 81
         }
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
         if ($maybeSubtype instanceof NonNullType) {
84 84
             // If superType is nullable, maybeSubType may be non-null or nullable.
85 85
             return $this->isTypeSubtypeOf($schema, $maybeSubtype->getOfType(),
86
-              $superType);
86
+                $superType);
87 87
         }
88 88
 
89 89
         // If superType type is a list, maybeSubType type must also be a list.
90 90
         if ($superType instanceof ListType) {
91 91
             if ($maybeSubtype instanceof ListType) {
92 92
                 return $this->isTypeSubtypeOf($schema,
93
-                  $maybeSubtype->getOfType(), $superType->getOfType());
93
+                    $maybeSubtype->getOfType(), $superType->getOfType());
94 94
             }
95 95
             return false;
96 96
         }
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
      * @return bool
128 128
      */
129 129
     public function doTypesOverlap(
130
-      SchemaInterface $schema,
131
-      TypeInterface $typeA,
132
-      TypeInterface $typeB
130
+        SchemaInterface $schema,
131
+        TypeInterface $typeA,
132
+        TypeInterface $typeB
133 133
     ): bool {
134 134
         // Equivalent types overlap
135 135
         if ($typeA === $typeB) {
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
                 // If both types are abstract, then determine if there is any intersection
142 142
                 // between possible concrete types of each.
143 143
                 return arraySome($schema->getPossibleTypes($typeA),
144
-                  function (TypeInterface $type) use ($schema, $typeB) {
145
-                      return $schema->isPossibleType($typeB, $type);
146
-                  });
144
+                    function (TypeInterface $type) use ($schema, $typeB) {
145
+                        return $schema->isPossibleType($typeB, $type);
146
+                    });
147 147
             }
148 148
 
149 149
             // Determine if the latter type is a possible concrete type of the former.
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
      * @return bool
174 174
      */
175 175
     public function compareTypes(
176
-      TypeInterface $typeA,
177
-      TypeInterface $typeB
176
+        TypeInterface $typeA,
177
+        TypeInterface $typeB
178 178
     ): bool {
179 179
         if ($typeA instanceof ListType) {
180 180
             return $typeB instanceof ListType
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
      * @throws InvalidTypeException
213 213
      */
214 214
     public function fromAST(
215
-      SchemaInterface $schema,
216
-      TypeNodeInterface $typeNode
215
+        SchemaInterface $schema,
216
+        TypeNodeInterface $typeNode
217 217
     ): ?TypeInterface
218 218
     {
219 219
         $innerType = null;
@@ -233,6 +233,6 @@  discard block
 block discarded – undo
233 233
         }
234 234
 
235 235
         throw new InvalidTypeException(sprintf('Unexpected type kind: %s',
236
-          $typeNode->getKind()));
236
+            $typeNode->getKind()));
237 237
     }
238 238
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
                 // If both types are abstract, then determine if there is any intersection
142 142
                 // between possible concrete types of each.
143 143
                 return arraySome($schema->getPossibleTypes($typeA),
144
-                  function (TypeInterface $type) use ($schema, $typeB) {
144
+                  function(TypeInterface $type) use ($schema, $typeB) {
145 145
                       return $schema->isPossibleType($typeB, $type);
146 146
                   });
147 147
             }
Please login to merge, or discard this patch.
src/Util/ValueHelper.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
         }
40 40
 
41 41
         return arrayEvery($argumentsA,
42
-          function (ArgumentNode $argumentA) use ($argumentsB) {
43
-              $argumentB = find($argumentsB,
42
+            function (ArgumentNode $argumentA) use ($argumentsB) {
43
+                $argumentB = find($argumentsB,
44 44
                 function (ArgumentNode $argument) use ($argumentA) {
45 45
                     return $argument->getNameValue() === $argumentA->getNameValue();
46 46
                 });
47 47
 
48
-              if (null === $argumentB) {
49
-                  return false;
50
-              }
48
+                if (null === $argumentB) {
49
+                    return false;
50
+                }
51 51
 
52
-              return $this->compareValues($argumentA->getValue(),
52
+                return $this->compareValues($argumentA->getValue(),
53 53
                 $argumentB->getValue());
54
-          });
54
+            });
55 55
     }
56 56
 
57 57
     /**
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function fromAST(
97 97
       ?NodeInterface $node,
98
-      TypeInterface $type,
99
-      array $variables = []
98
+        TypeInterface $type,
99
+        array $variables = []
100 100
     ) {
101 101
         if (null === $node) {
102 102
             throw new ResolutionException('Node is not defined.');
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
             if (!isset($variables[$variableName])) {
118 118
                 throw new ResolutionException(
119
-                  \sprintf('Cannot resolve value for missing variable "%s".',
119
+                    \sprintf('Cannot resolve value for missing variable "%s".',
120 120
                     $variableName)
121 121
                 );
122 122
             }
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
      * @throws ResolutionException
158 158
      */
159 159
     protected function resolveNonNullType(
160
-      NodeInterface $node,
161
-      NonNullType $type,
162
-      array $variables = []
160
+        NodeInterface $node,
161
+        NonNullType $type,
162
+        array $variables = []
163 163
     ) {
164 164
         if ($node instanceof NullValueNode) {
165 165
             throw new ResolutionException('Cannot resolve non-null values from null value node.');
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
      * @throws ResolutionException
179 179
      */
180 180
     protected function resolveListType(
181
-      NodeInterface $node,
182
-      ListType $type,
183
-      array $variables = []
181
+        NodeInterface $node,
182
+        ListType $type,
183
+        array $variables = []
184 184
     ) {
185 185
         $itemType = $type->getOfType();
186 186
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
                     $resolvedValues[] = null;
199 199
                 } else {
200 200
                     $resolvedValues[] = $this->fromAST($value, $itemType,
201
-                      $variables);
201
+                        $variables);
202 202
                 }
203 203
             }
204 204
 
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
      * @return bool
216 216
      */
217 217
     protected function isMissingVariable(
218
-      ValueNodeInterface $node,
219
-      array $variables
218
+        ValueNodeInterface $node,
219
+        array $variables
220 220
     ): bool {
221 221
         return $node instanceof VariableNode && !isset($variables[$node->getNameValue()]);
222 222
     }
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
      * @throws ResolutionException
233 233
      */
234 234
     protected function resolveInputObjectType(
235
-      NodeInterface $node,
236
-      InputObjectType $type,
237
-      array $variables = []
235
+        NodeInterface $node,
236
+        InputObjectType $type,
237
+        array $variables = []
238 238
     ) {
239 239
         if (!$node instanceof ObjectValueNode) {
240 240
             throw new ResolutionException('Input object values can only be resolved form object value nodes.');
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 
245 245
         /** @var ObjectFieldNode[] $fieldNodes */
246 246
         $fieldNodes = keyMap($node->getFields(),
247
-          function (ObjectFieldNode $value) {
248
-              return $value->getNameValue();
249
-          });
247
+            function (ObjectFieldNode $value) {
248
+                return $value->getNameValue();
249
+            });
250 250
 
251 251
         foreach ($type->getFields() as $field) {
252 252
             $name = $field->getName();
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             }
264 264
 
265 265
             $fieldValue = $this->fromAST($fieldNode->getValue(),
266
-              $field->getType(), $variables);
266
+                $field->getType(), $variables);
267 267
 
268 268
             $resolvedValues[$name] = $fieldValue;
269 269
         }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
         if (null === $enumValue) {
293 293
             throw new ResolutionException(\sprintf('Cannot resolve enum value for missing value "%s".',
294
-              $name));
294
+                $name));
295 295
         }
296 296
 
297 297
         return $enumValue->getValue();
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
      * @throws ResolutionException
307 307
      */
308 308
     protected function resolveScalarType(
309
-      NodeInterface $node,
310
-      ScalarType $type,
311
-      array $variables = []
309
+        NodeInterface $node,
310
+        ScalarType $type,
311
+        array $variables = []
312 312
     ) {
313 313
         // Scalars fulfill parsing a literal value via parseLiteral().
314 314
         // Invalid values represent a failure to parse correctly, in which case
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
         if (null === $result) {
325 325
             throw new ResolutionException(\sprintf('Failed to parse literal for scalar type "%s".',
326
-              (string)$type));
326
+                (string)$type));
327 327
         }
328 328
 
329 329
         return $result;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
         }
40 40
 
41 41
         return arrayEvery($argumentsA,
42
-          function (ArgumentNode $argumentA) use ($argumentsB) {
42
+          function(ArgumentNode $argumentA) use ($argumentsB) {
43 43
               $argumentB = find($argumentsB,
44
-                function (ArgumentNode $argument) use ($argumentA) {
44
+                function(ArgumentNode $argument) use ($argumentA) {
45 45
                     return $argument->getNameValue() === $argumentA->getNameValue();
46 46
                 });
47 47
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
         /** @var ObjectFieldNode[] $fieldNodes */
246 246
         $fieldNodes = keyMap($node->getFields(),
247
-          function (ObjectFieldNode $value) {
247
+          function(ObjectFieldNode $value) {
248 248
               return $value->getNameValue();
249 249
           });
250 250
 
Please login to merge, or discard this patch.
src/Util/NameHelper.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@
 block discarded – undo
44 44
 
45 45
         if (\strlen($name) > 1 && $name{0} === '_' && $name{1} === '_') {
46 46
             return new ValidationException(
47
-              sprintf('Name "%s" must not begin with "__", which is reserved by GraphQL introspection.',
47
+                sprintf('Name "%s" must not begin with "__", which is reserved by GraphQL introspection.',
48 48
                 $name),
49
-              $node instanceof NodeInterface ? [$node] : null
49
+                $node instanceof NodeInterface ? [$node] : null
50 50
             );
51 51
         }
52 52
 
53 53
         if (preg_match("/^[_a-zA-Z][_a-zA-Z0-9]*$/", $name) === 0) {
54 54
             return new ValidationException(
55
-              sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.',
55
+                sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.',
56 56
                 $name),
57
-              $node instanceof NodeInterface ? [$node] : null
57
+                $node instanceof NodeInterface ? [$node] : null
58 58
             );
59 59
         }
60 60
 
Please login to merge, or discard this patch.
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.