Completed
Pull Request — master (#77)
by Sebastian
02:39
created
src/Validator/SchemaValidator/SchemaValidator.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
      * @param Field                 $objField
58 58
      * @param AbstractInterfaceType $interface
59 59
      *
60
-     * @return bool
60
+     * @return boolean|null
61 61
      *
62 62
      * @throws ConfigurationException
63 63
      */
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 
9 9
 namespace Youshido\GraphQL\Validator\SchemaValidator;
10 10
 
11
-use Youshido\GraphQL\Config\AbstractConfig;
12 11
 use Youshido\GraphQL\Field\Field;
13 12
 use Youshido\GraphQL\Schema\AbstractSchema;
14 13
 use Youshido\GraphQL\Type\InterfaceType\AbstractInterfaceType;
Please login to merge, or discard this patch.
Tests/Schema/ProcessorTest.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -164,19 +164,19 @@
 block discarded – undo
164 164
         $this->assertEquals(['data' => ['me' => ['firstName' => 'JOHN']]], $processor->getResponseData());
165 165
 
166 166
         $schema->getMutationType()
167
-               ->addField(new Field([
168
-                   'name'    => 'increaseCounter',
169
-                   'type'    => new IntType(),
170
-                   'resolve' => function ($value, $args, ResolveInfo $info) {
171
-                       return $this->_counter += $args['amount'];
172
-                   },
173
-                   'args'    => [
174
-                       'amount' => [
175
-                           'type'    => new IntType(),
176
-                           'default' => 1
177
-                       ]
178
-                   ]
179
-               ]))->addField(new Field([
167
+                ->addField(new Field([
168
+                    'name'    => 'increaseCounter',
169
+                    'type'    => new IntType(),
170
+                    'resolve' => function ($value, $args, ResolveInfo $info) {
171
+                        return $this->_counter += $args['amount'];
172
+                    },
173
+                    'args'    => [
174
+                        'amount' => [
175
+                            'type'    => new IntType(),
176
+                            'default' => 1
177
+                        ]
178
+                    ]
179
+                ]))->addField(new Field([
180 180
                 'name'    => 'invalidResolveTypeMutation',
181 181
                 'type'    => new NonNullType(new IntType()),
182 182
                 'resolve' => function () {
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
                 'fields' => [
96 96
                     'list' => [
97 97
                         'type'    => new ListType(new StringType()),
98
-                        'resolve' => function () {
98
+                        'resolve' => function() {
99 99
                             return null;
100 100
                         }
101 101
                     ]
102 102
                 ]
103 103
             ])
104 104
         ]));
105
-        $data      = $processor->processPayload(' { list }')->getResponseData();
105
+        $data = $processor->processPayload(' { list }')->getResponseData();
106 106
         $this->assertEquals(['data' => ['list' => null]], $data);
107 107
     }
108 108
 
@@ -115,20 +115,20 @@  discard block
 block discarded – undo
115 115
                 'fields' => [
116 116
                     'list' => [
117 117
                         'type'    => new ListType(new StringType()),
118
-                        'resolve' => function () {
118
+                        'resolve' => function() {
119 119
                             return null;
120 120
                         }
121 121
                     ]
122 122
                 ]
123 123
             ])
124 124
         ]));
125
-        $data      = $processor->processPayload(' { __schema { subscriptionType { name } } }')->getResponseData();
125
+        $data = $processor->processPayload(' { __schema { subscriptionType { name } } }')->getResponseData();
126 126
         $this->assertEquals(['data' => ['__schema' => ['subscriptionType' => null]]], $data);
127 127
     }
128 128
 
129 129
     public function testSchemaOperations()
130 130
     {
131
-        $schema    = new Schema([
131
+        $schema = new Schema([
132 132
             'query' => new ObjectType([
133 133
                 'name'   => 'RootQuery',
134 134
                 'fields' => [
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
                                     'args'    => [
142 142
                                         'shorten' => new BooleanType()
143 143
                                     ],
144
-                                    'resolve' => function ($value, $args) {
144
+                                    'resolve' => function($value, $args) {
145 145
                                         return empty($args['shorten']) ? $value['firstName'] : $value['firstName'];
146 146
                                     }
147 147
                                 ],
148 148
                                 'id_alias'  => [
149 149
                                     'type'    => new IdType(),
150
-                                    'resolve' => function ($value) {
150
+                                    'resolve' => function($value) {
151 151
                                         return $value['id'];
152 152
                                     }
153 153
                                 ],
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                                 'code'      => new StringType(),
156 156
                             ]
157 157
                         ]),
158
-                        'resolve' => function ($value, $args) {
158
+                        'resolve' => function($value, $args) {
159 159
                             $data = ['id' => '123', 'firstName' => 'John', 'code' => '007'];
160 160
                             if (!empty($args['upper'])) {
161 161
                                 foreach ($data as $key => $value) {
@@ -174,19 +174,19 @@  discard block
 block discarded – undo
174 174
                     ],
175 175
                     'randomUser'        => [
176 176
                         'type'    => new TestObjectType(),
177
-                        'resolve' => function () {
177
+                        'resolve' => function() {
178 178
                             return ['invalidField' => 'John'];
179 179
                         }
180 180
                     ],
181 181
                     'invalidValueQuery' => [
182 182
                         'type'    => new TestObjectType(),
183
-                        'resolve' => function () {
183
+                        'resolve' => function() {
184 184
                             return 'stringValue';
185 185
                         }
186 186
                     ],
187 187
                     'labels'            => [
188 188
                         'type'    => new ListType(new StringType()),
189
-                        'resolve' => function () {
189
+                        'resolve' => function() {
190 190
                             return ['one', 'two'];
191 191
                         }
192 192
                     ]
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                ->addField(new Field([
218 218
                    'name'    => 'increaseCounter',
219 219
                    'type'    => new IntType(),
220
-                   'resolve' => function ($value, $args, ResolveInfo $info) {
220
+                   'resolve' => function($value, $args, ResolveInfo $info) {
221 221
                        return $this->_counter += $args['amount'];
222 222
                    },
223 223
                    'args'    => [
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
                ]))->addField(new Field([
230 230
                 'name'    => 'invalidResolveTypeMutation',
231 231
                 'type'    => new NonNullType(new IntType()),
232
-                'resolve' => function () {
232
+                'resolve' => function() {
233 233
                     return null;
234 234
                 }
235 235
             ]))->addField(new Field([
236 236
                 'name'    => 'interfacedMutation',
237 237
                 'type'    => new TestInterfaceType(),
238
-                'resolve' => function () {
238
+                'resolve' => function() {
239 239
                     return ['name' => 'John'];
240 240
                 }
241 241
             ]));
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
                             ]))
305 305
                         ],
306 306
                         'type'    => new StringType(),
307
-                        'resolve' => function ($value, $args) {
307
+                        'resolve' => function($value, $args) {
308 308
                             return $args['argument1'];
309 309
                         }
310 310
                     ]
@@ -340,43 +340,43 @@  discard block
 block discarded – undo
340 340
                 'fields' => [
341 341
                     'listQuery'                 => [
342 342
                         'type'    => new ListType(new TestEnumType()),
343
-                        'resolve' => function () {
343
+                        'resolve' => function() {
344 344
                             return 'invalid list';
345 345
                         }
346 346
                     ],
347 347
                     'listEnumQuery'             => [
348 348
                         'type'    => new ListType(new TestEnumType()),
349
-                        'resolve' => function () {
349
+                        'resolve' => function() {
350 350
                             return ['invalid enum'];
351 351
                         }
352 352
                     ],
353 353
                     'invalidEnumQuery'          => [
354 354
                         'type'    => new TestEnumType(),
355
-                        'resolve' => function () {
355
+                        'resolve' => function() {
356 356
                             return 'invalid enum';
357 357
                         }
358 358
                     ],
359 359
                     'enumQuery'                 => [
360 360
                         'type'    => new TestEnumType(),
361
-                        'resolve' => function () {
361
+                        'resolve' => function() {
362 362
                             return 1;
363 363
                         }
364 364
                     ],
365 365
                     'invalidNonNullQuery'       => [
366 366
                         'type'    => new NonNullType(new IntType()),
367
-                        'resolve' => function () {
367
+                        'resolve' => function() {
368 368
                             return null;
369 369
                         }
370 370
                     ],
371 371
                     'invalidNonNullInsideQuery' => [
372 372
                         'type'    => new NonNullType(new IntType()),
373
-                        'resolve' => function () {
373
+                        'resolve' => function() {
374 374
                             return 'hello';
375 375
                         }
376 376
                     ],
377 377
                     'objectQuery'               => [
378 378
                         'type'    => new TestObjectType(),
379
-                        'resolve' => function () {
379
+                        'resolve' => function() {
380 380
                             return ['name' => 'John'];
381 381
                         }
382 382
                     ],
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
                                 'enum'   => new TestEnumType(),
389 389
                             ],
390 390
                         ]),
391
-                        'resolve' => function () {
391
+                        'resolve' => function() {
392 392
                             return [
393 393
                                 'object' => [
394 394
                                     'name' => 'John'
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
             ]
463 463
         ]);
464 464
 
465
-        $union        = new UnionType([
465
+        $union = new UnionType([
466 466
             'name'        => 'TestUnion',
467 467
             'types'       => [$object1, $object2],
468
-            'resolveType' => function ($object) use ($object1, $object2) {
468
+            'resolveType' => function($object) use ($object1, $object2) {
469 469
                 if (isset($object['id'])) {
470 470
                     return $object1;
471 471
                 }
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
         $invalidUnion = new UnionType([
477 477
             'name'        => 'TestUnion',
478 478
             'types'       => [$object1, $object2],
479
-            'resolveType' => function ($object) use ($object3) {
479
+            'resolveType' => function($object) use ($object3) {
480 480
                 return $object3;
481 481
             }
482 482
         ]);
483
-        $processor    = new Processor(new Schema([
483
+        $processor = new Processor(new Schema([
484 484
             'query' => new ObjectType([
485 485
                 'name'   => 'RootQuery',
486 486
                 'fields' => [
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
                             'type' => ['type' => 'string']
491 491
                         ],
492 492
                         'cost'    => 10,
493
-                        'resolve' => function ($value, $args) {
493
+                        'resolve' => function($value, $args) {
494 494
                             if ($args['type'] == 'object1') {
495 495
                                 return [
496 496
                                     'id' => 43
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
                     ],
505 505
                     'invalidUnion' => [
506 506
                         'type'    => $invalidUnion,
507
-                        'resolve' => function () {
507
+                        'resolve' => function() {
508 508
                             return ['name' => 'name resolved'];
509 509
                         }
510 510
                     ],
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
                 'fields' => [
560 560
                     'currentUser' => [
561 561
                         'type'    => new StringType(),
562
-                        'resolve' => function ($source, $args, ResolveInfo $info) {
562
+                        'resolve' => function($source, $args, ResolveInfo $info) {
563 563
                             return $info->getContainer()->get('user')['name'];
564 564
                         }
565 565
                     ]
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 
578 578
     public function testComplexityReducer()
579 579
     {
580
-        $schema    = new Schema(
580
+        $schema = new Schema(
581 581
             [
582 582
                 'query' => new ObjectType(
583 583
                     [
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
                                                 'args'    => [
594 594
                                                     'shorten' => new BooleanType()
595 595
                                                 ],
596
-                                                'resolve' => function ($value, $args) {
596
+                                                'resolve' => function($value, $args) {
597 597
                                                     return empty($args['shorten']) ? $value : $value;
598 598
                                                 }
599 599
                                             ],
@@ -602,19 +602,19 @@  discard block
 block discarded – undo
602 602
                                             'likes'     => [
603 603
                                                 'type'    => new IntType(),
604 604
                                                 'cost'    => 10,
605
-                                                'resolve' => function () {
605
+                                                'resolve' => function() {
606 606
                                                     return 42;
607 607
                                                 }
608 608
                                             ]
609 609
                                         ]
610 610
                                     ]
611 611
                                 ),
612
-                                'cost'    => function ($args, $context, $childCost) {
612
+                                'cost'    => function($args, $context, $childCost) {
613 613
                                     $argsCost = isset($args['cost']) ? $args['cost'] : 1;
614 614
 
615 615
                                     return 1 + $argsCost * $childCost;
616 616
                                 },
617
-                                'resolve' => function ($value, $args) {
617
+                                'resolve' => function($value, $args) {
618 618
                                     $data = ['firstName' => 'John', 'code' => '007'];
619 619
 
620 620
                                     return $data;
Please login to merge, or discard this patch.
Tests/Library/Type/ScalarTypeTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         foreach (TypeFactory::getScalarTypesNames() as $typeName) {
24 24
             $scalarType     = TypeFactory::getScalarType($typeName);
25
-            $testDataMethod = 'get' . $typeName . 'TestData';
25
+            $testDataMethod = 'get'.$typeName.'TestData';
26 26
 
27 27
             $this->assertNotEmpty($scalarType->getDescription());
28 28
             $this->assertEquals($scalarType->getKind(), TypeMap::KIND_SCALAR);
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
                 $this->assertParse($scalarType, $data, $serialized);
39 39
 
40 40
                 if ($isValid) {
41
-                    $this->assertTrue($scalarType->isValidValue($data), $typeName . ' validation for :' . serialize($data));
41
+                    $this->assertTrue($scalarType->isValidValue($data), $typeName.' validation for :'.serialize($data));
42 42
                 } else {
43
-                    $this->assertFalse($scalarType->isValidValue($data), $typeName . ' validation for :' . serialize($data));
43
+                    $this->assertFalse($scalarType->isValidValue($data), $typeName.' validation for :'.serialize($data));
44 44
                 }
45 45
             }
46 46
         }
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
     private function assertSerialization(AbstractScalarType $object, $input, $expected)
54 54
     {
55
-        $this->assertEquals($expected, $object->serialize($input), $object->getName() . ' serialize for: ' . serialize($input));
55
+        $this->assertEquals($expected, $object->serialize($input), $object->getName().' serialize for: '.serialize($input));
56 56
     }
57 57
 
58 58
     private function assertParse(AbstractScalarType $object, $input, $expected)
59 59
     {
60
-        $this->assertEquals($expected, $object->parseValue($input), $object->getName() . ' serialize for: ' . serialize($input));
60
+        $this->assertEquals($expected, $object->parseValue($input), $object->getName().' serialize for: '.serialize($input));
61 61
     }
62 62
 
63 63
 }
Please login to merge, or discard this patch.
Tests/Library/Type/InterfaceTypeTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
             'fields'      => [
44 44
                 'name' => new StringType()
45 45
             ],
46
-            'resolveType' => function ($object) {
46
+            'resolveType' => function($object) {
47 47
                 return $object;
48 48
             }
49 49
         ]);
Please login to merge, or discard this patch.
Tests/Library/Type/UnionTypeTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
                 new TestObjectType(),
33 33
                 $object
34 34
             ],
35
-            'resolveType' => function ($type) {
35
+            'resolveType' => function($type) {
36 36
                 return $type;
37 37
             }
38 38
         ]);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             'types'       => [
68 68
                 'test', new IntType()
69 69
             ],
70
-            'resolveType' => function ($type) {
70
+            'resolveType' => function($type) {
71 71
                 return $type;
72 72
             }
73 73
         ]);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             'types'       => [
85 85
                 new IntType()
86 86
             ],
87
-            'resolveType' => function ($type) {
87
+            'resolveType' => function($type) {
88 88
                 return $type;
89 89
             }
90 90
         ]);
Please login to merge, or discard this patch.
Tests/Library/Type/EnumTypeTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
                 'value' => 'disable'
103 103
             ]
104 104
         ];
105
-        $enumType   = new EnumType([
105
+        $enumType = new EnumType([
106 106
             'name'   => 'BoolEnum',
107 107
             'values' => $valuesData
108 108
         ]);
Please login to merge, or discard this patch.
Tests/Library/Field/FieldAwareConfigTraitTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
                 'type' => new IntType()
25 25
             ]
26 26
         ];
27
-        $config     = new ObjectTypeConfig([
27
+        $config = new ObjectTypeConfig([
28 28
             'name'   => 'UserType',
29 29
             'fields' => $fieldsData
30 30
         ]);
Please login to merge, or discard this patch.
Tests/Library/Field/FieldTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
         $fieldWithResolve = new Field([
37 37
             'name'    => 'title',
38 38
             'type'    => new StringType(),
39
-            'resolve' => function ($value, array $args, ResolveInfo $info) {
39
+            'resolve' => function($value, array $args, ResolveInfo $info) {
40 40
                 return $info->getReturnType()->serialize($value);
41 41
             }
42 42
         ]);
Please login to merge, or discard this patch.
Tests/Library/Config/FieldConfigTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         $fieldConfig = new FieldConfig([
21 21
             'name'    => 'FirstName',
22 22
             'type'    => new StringType(),
23
-            'resolve' => function ($value, $args = [], $type = null) {
23
+            'resolve' => function($value, $args = [], $type = null) {
24 24
                 return 'John';
25 25
             }
26 26
         ]);
Please login to merge, or discard this patch.