Completed
Pull Request — master (#19)
by Daniel
03:45
created
src/Execution/Processor.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -152,7 +152,9 @@  discard block
 block discarded – undo
152 152
     protected function collectValueForQueryWithType(Query $query, AbstractType $fieldType, $resolvedValue)
153 153
     {
154 154
         $fieldType = $this->resolveValidator->resolveTypeIfAbstract($fieldType, $resolvedValue);
155
-        if (is_null($resolvedValue)) return null;
155
+        if (is_null($resolvedValue)) {
156
+            return null;
157
+        }
156 158
 
157 159
         $value = [];
158 160
         if ($fieldType->getKind() == TypeMap::KIND_LIST) {
@@ -234,8 +236,7 @@  discard block
 block discarded – undo
234 236
             $this->resolverStringResolver && ($resolveString = $field->getConfig()->getResolveString()) && ($resolveFunc = $this->resolverStringResolver->resolve($resolveString))
235 237
             )) {
236 238
             return $resolveFunc($contextValue, $this->parseArgumentsValues($field, $query), $resolveInfo);
237
-        }
238
-        elseif ($propertyValue = TypeService::getPropertyValue($contextValue, $field->getName())) {
239
+        } elseif ($propertyValue = TypeService::getPropertyValue($contextValue, $field->getName())) {
239 240
             return $propertyValue;
240 241
         } else {
241 242
             return $field->resolve($contextValue, $this->parseArgumentsValues($field, $query), $resolveInfo);
Please login to merge, or discard this patch.
src/Config/AbstractConfig.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -93,9 +93,9 @@
 block discarded – undo
93 93
         return $this->get('resolve', null);
94 94
     }
95 95
 
96
-  /**
97
-   * @return string|null
98
-   */
96
+    /**
97
+     * @return string|null
98
+     */
99 99
     public function getResolveString()
100 100
     {
101 101
         return $this->get('resolveString', null);
Please login to merge, or discard this patch.
Tests/Schema/ProcessorTest.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
     public function testSchemaOperations()
127 127
     {
128
-        $schema    = new Schema([
128
+        $schema = new Schema([
129 129
             'query' => new ObjectType([
130 130
                 'name'   => 'RootQuery',
131 131
                 'fields' => [
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
                                     'args'    => [
139 139
                                         'shorten' => new BooleanType()
140 140
                                     ],
141
-                                    'resolve' => function ($value, $args) {
141
+                                    'resolve' => function($value, $args) {
142 142
                                         return empty($args['shorten']) ? $value : $value;
143 143
                                     }
144 144
                                 ],
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                                 'code'      => new StringType(),
147 147
                             ]
148 148
                         ]),
149
-                        'resolve' => function ($value, $args) {
149
+                        'resolve' => function($value, $args) {
150 150
                             $data = ['firstName' => 'John', 'code' => '007'];
151 151
                             if (!empty($args['upper'])) {
152 152
                                 foreach ($data as $key => $value) {
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
                     ],
166 166
                     'randomUser'        => [
167 167
                         'type'    => new TestObjectType(),
168
-                        'resolve' => function () {
168
+                        'resolve' => function() {
169 169
                             return ['invalidField' => 'John'];
170 170
                         }
171 171
                     ],
172 172
                     'invalidValueQuery' => [
173 173
                         'type'    => new TestObjectType(),
174
-                        'resolve' => function () {
174
+                        'resolve' => function() {
175 175
                             return 'stringValue';
176 176
                         }
177 177
                     ],
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                ->addField(new Field([
197 197
                    'name'    => 'increaseCounter',
198 198
                    'type'    => new IntType(),
199
-                   'resolve' => function ($value, $args, ResolveInfo $info) {
199
+                   'resolve' => function($value, $args, ResolveInfo $info) {
200 200
                        return $this->_counter += $args['amount'];
201 201
                    },
202 202
                    'args'    => [
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
                ]))->addField(new Field([
209 209
                 'name'    => 'invalidResolveTypeMutation',
210 210
                 'type'    => new NonNullType(new IntType()),
211
-                'resolve' => function () {
211
+                'resolve' => function() {
212 212
                     return null;
213 213
                 }
214 214
             ]))->addField(new Field([
215 215
                 'name'    => 'interfacedMutation',
216 216
                 'type'    => new TestInterfaceType(),
217
-                'resolve' => function () {
217
+                'resolve' => function() {
218 218
                     return ['name' => 'John'];
219 219
                 }
220 220
             ]));
@@ -260,43 +260,43 @@  discard block
 block discarded – undo
260 260
                 'fields' => [
261 261
                     'listQuery'                 => [
262 262
                         'type'    => new ListType(new TestEnumType()),
263
-                        'resolve' => function () {
263
+                        'resolve' => function() {
264 264
                             return 'invalid list';
265 265
                         }
266 266
                     ],
267 267
                     'listEnumQuery'             => [
268 268
                         'type'    => new ListType(new TestEnumType()),
269
-                        'resolve' => function () {
269
+                        'resolve' => function() {
270 270
                             return ['invalid enum'];
271 271
                         }
272 272
                     ],
273 273
                     'invalidEnumQuery'          => [
274 274
                         'type'    => new TestEnumType(),
275
-                        'resolve' => function () {
275
+                        'resolve' => function() {
276 276
                             return 'invalid enum';
277 277
                         }
278 278
                     ],
279 279
                     'enumQuery'                 => [
280 280
                         'type'    => new TestEnumType(),
281
-                        'resolve' => function () {
281
+                        'resolve' => function() {
282 282
                             return 1;
283 283
                         }
284 284
                     ],
285 285
                     'invalidNonNullQuery'       => [
286 286
                         'type'    => new NonNullType(new IntType()),
287
-                        'resolve' => function () {
287
+                        'resolve' => function() {
288 288
                             return null;
289 289
                         }
290 290
                     ],
291 291
                     'invalidNonNullInsideQuery' => [
292 292
                         'type'    => new NonNullType(new IntType()),
293
-                        'resolve' => function () {
293
+                        'resolve' => function() {
294 294
                             return 'hello';
295 295
                         }
296 296
                     ],
297 297
                     'objectQuery'               => [
298 298
                         'type'    => new TestObjectType(),
299
-                        'resolve' => function () {
299
+                        'resolve' => function() {
300 300
                             return ['name' => 'John'];
301 301
                         }
302 302
                     ],
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
                                 'enum'   => new TestEnumType(),
309 309
                             ],
310 310
                         ]),
311
-                        'resolve' => function () {
311
+                        'resolve' => function() {
312 312
                             return [
313 313
                                 'object' => [
314 314
                                     'name' => 'John'
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
             ]
378 378
         ]);
379 379
 
380
-        $union        = new UnionType([
380
+        $union = new UnionType([
381 381
             'name'        => 'TestUnion',
382 382
             'types'       => [$object1, $object2],
383
-            'resolveType' => function ($object) use ($object1, $object2) {
383
+            'resolveType' => function($object) use ($object1, $object2) {
384 384
                 if (isset($object['id'])) {
385 385
                     return $object1;
386 386
                 }
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
         $invalidUnion = new UnionType([
392 392
             'name'        => 'TestUnion',
393 393
             'types'       => [$object1, $object2],
394
-            'resolveType' => function ($object) use ($object3) {
394
+            'resolveType' => function($object) use ($object3) {
395 395
                 return $object3;
396 396
             }
397 397
         ]);
398
-        $processor    = new Processor(new Schema([
398
+        $processor = new Processor(new Schema([
399 399
             'query' => new ObjectType([
400 400
                 'name'   => 'RootQuery',
401 401
                 'fields' => [
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
                         'args'    => [
405 405
                             'type' => ['type' => 'string']
406 406
                         ],
407
-                        'resolve' => function ($value, $args) {
407
+                        'resolve' => function($value, $args) {
408 408
                             if ($args['type'] == 'object1') {
409 409
                                 return [
410 410
                                     'id' => 43
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                     ],
419 419
                     'invalidUnion' => [
420 420
                         'type'    => $invalidUnion,
421
-                        'resolve' => function () {
421
+                        'resolve' => function() {
422 422
                             return ['name' => 'name resolved'];
423 423
                         }
424 424
                     ],
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
         $resolveFactory = $this->prophesize(ResolveStringResolverInterface::class);
455 455
         $resolveFactory->resolve('service_name:get')
456 456
             ->shouldBeCalled()
457
-            ->willReturn(function () {
457
+            ->willReturn(function() {
458 458
                 return 'hello';
459 459
             });
460 460
 
Please login to merge, or discard this patch.